How do you copy an array formula down a column in Calc? - openoffice-calc

I have the following array formula in cell B2:
=INDEX($M$2:$O$110;MATCH(1;($M$2:$M$110=C2)*($N$2:$N$110=E2);0);3)
and I want to copy it down a column, so I want:
B2 {=INDEX($M$2:$O$110;MATCH(1;($M$2:$M$110=C2)*($N$2:$N$110=E2);0);3)}
B3 {=INDEX($M$2:$O$110;MATCH(1;($M$2:$M$110=C3)*($N$2:$N$110=E3);0);3)}
B4 {=INDEX($M$2:$O$110;MATCH(1;($M$2:$M$110=C4)*($N$2:$N$110=E4);0);3)}
etc
I enter the formula into B2, I press CTRL+SHIFT+ENTER, then I copy the formula down the B column. This only gives me:
=INDEX($M$2:$O$110;MATCH(1;($M$2:$M$110=C2)*($N$2:$N$110=E2);0);3)
The relative reference to C2 and E2 seems to be treated as an absolute reference. I want E2 and C2 to change.
I'm using OpenOffice Calc, so I have ; instead of , in the functions.

In Calc (OpenOffice or LibreOffice) you will always create one array formula for the whole overlined area if you fill down or sidewards a array formula with the fill handle (small black dot in the bottom right corner of the active cell).
If you need to create single array formulas for each cell, then you have to copy the formula, then select the destination cells and paste the formula.
You can also copy, not fill, if you hold Ctrl + Shift while dragging the fill handler.

Related

Python normalise data when number of rows are not equal

I was wondering if anyone has a way of normalising column when the row numbers are not equal (see attached picture). For example in my data, I need to divide S1 by S2. however S1 includes data for multiple points (0,0) (0,1), (1,0) and (2,0).
I fI just divide S1/S2 I will get normalised data for (0,0) which is S1(0,0)/S2(0,0). I would like to each data point to S2:
S1(0,0)/S2(0,0)
S1(0,1)/S2(0,0)
S1(1,0)/S2(0,0)
S1(2,0)/S2(0,0)
Sorry if it is too simple but I have just started to learn Python.
enter image description here

How to create an elbow connector from scratch programatically?

An "elbow connector" in MS-Word is a 3-segment line with a control point in the middle as shown
where if I move the yellow control point sideways, then the length of the two lines on either side change accordingly while the end points remain the same. (Please ignore the "2" in the picture)
I am trying to understand how this works so that I can re-create this. Is there a "line equation" for such a line? I have some points (x,y) that are already in the shape of this elbow connector but I would like to incorporate the functionality of changing the lines on either side by controlling the control point. How would I go about re-creating this?
By dissecting the lines like:
For moving the center(M) only sideways, length of lines 2 and 3 remains the same so the problem becomes how to calculate length (and direction) of the lines 1 and 4.
That can be calculated like:
line1_length = B.x - M.x;
line4_length = M.x - A.x;
For directions a comparison should first be made like:
if(B.x > M.x)...
.
.
.
if(M.x > A.x)...
.
.
.
Beginning points is already known as the position of A and the position of B. By knowing the lengths and directions of lines 1 and 4, the end points can be determined.
Good luck!

Determine when a cell is blank

At work, I needed that if the value of a cell is equal to the cell next to it, then the background color changes to red, but it is doing it for blank cells, so it may be confusing for others.
Is there a way to avoid blank cells?
I have this formula:
=IF($D2=$C2,TRUE)
then background color changes to red (not sure if the correct formula, but it worked at the beginning, I am doing this in the Conditional Format Rules in Google Sheets).
I used this:
=IF($D1=$C1,IF(ISBLANK($D1),FALSE,TRUE))
I set the range to be C1:D1000. Your formula was putting the formatted color on the row above the data being checked. This formula checks if they are equal. Then if so it checks if one is blank. You don't have to check if they are both blank, the formula already knows that they are equal. So then if they are equal, return false, otherwise return true.
Clear formatting from C2 to wherever in ColumnD suits and with that selected then Format - Conditional formatting..., Custom formula is and:
=($C2=$D2)*($C2<>"")
Then select formatting of choice and Done.

Whats the easiest way to change several values at predetermined locations in a 2D vector?

Ok so I have a 2d vector of chars that I call a grid. Lets just say its 70 x 30. When the grid is created, it automatically fills each position with 'x'
I have a function that displays the grid. So I call this function and a 70x30 grid of x's is displayed to the console.
I have another function that I want to call to essentially replace the char at certain x,y coordinates of the grid with a different char. The points aren't exactly random/scattered. I'm basically starting from a point on the edge of the grid, and drawing zigzagged lines to another edge. All points are predetermined. Theres a lot of points to plot, so manually doing it seems inefficient.
Here's how I was thinking to do it:
Create a double for loop, width and height, calling them i and j
If i = (a || b || c || d...) && j = (e || f || g..)
And essentially do that tedious process for each possible scenario..
Surely there is a much easier and simpler way lol. Any suggestions will be greatly appreciated. Thanks!
If the points can be pre-determined by having a map (as in for a level editor or otherwised fixed pattern), then make a dictionary of x/y co-ordinates to what the tile becomes. Iterate over the dictionary and do each replacement.
If the points aren't pre-determined but follow a pattern, such as lines or blobs, then write a method that draws the line/blob/whatever and call it over and over. The method decides which tiles to replace and replaces those.
Btw, there's a trick when doing 2D checking and processing like this which is called having a 'delta', for instance xdelta=-1, ydelta=0 is west and xdelta=1, ydelta=1 is northeast. By having a delta you can run a function two, four or eight times with different deltas and it'll move in different directions by just using the delta's directions instead of needing to try all eight directions on its own - the delta can also be used to drive the bounds checking if you want, as you can't go out of bounds in a direction you're not proceeding in for example. Then you can go further and have an enumeration of all directions, functions that invert a direction, that turn a direction 90/45 degrees (if it's enumerated it's very simple, you just add 2 or 1 to the enumeration and return the new direction), etc, making processing very easy now.
So I might have something like
function drawLine(int xstart, int ystart, int xdelta, intydelta)
that starts at xstart,ystart, replaces the tile with O, adds xdelta to x, adds ydelta to y, replaces the tile with O, etc until it falls off the edge.

The camera's up, focus and position values after interaction

After interacting with the XTK camera in some way -- translation, rotation, zooming -- is there a way to retrieve from the camera the new values of the position, the focus and the up vector? It looks like the getter and setters are defined in the camera javascript, but the attributes corresponding to these are not updated during the interaction. The value returned by camera.position, for instance, is not updated even following a translation.
Is there either a mechanism that can provide these values, or a way to add an additional watcher to all interactions that modify the camera?
the position, up vector and focus are used to configure the 3d space at first. then, all interactions just modify the created view matrix.
You can query the view matrix like this
ren = new X.renderer3D()
console.log(ren.camera.view + "") // prints the view matrix as a string
I see a few solutions depending of who does the job.
First : adding a option to the cameras to enable tracking (disabled by default), an option that would update up/position/focus would be easy no ? Since it's just to multiply the previous vector by the transformation matrix at the same moment than we multiply the view matrix by the transformation matrix. But it may bring an additionnal cost in operations. Or we can compute it like in my "Second"
Second : if my memories are good, the transformation matrix T in a base B(O(x,y,z),i,*j*,k) has a well known-structure no ? Something like this (maybe I forget a transposition) :
i1 j1 k1 u1
i2 j2 k2 u2
i3 j3 k3 u3
0 0 0 1
Where :
([u1,u2,u3])=T(0(x,y,z)) i.e. gives the translation in the base B
([i1,i2,i3])=T(**i**)
([j1,j2,j3])=T(**j**)
([k1,k2,k3])=T(**k**)
Then if you want the 3 angles it is very harsh (see euler's calculations), but if you want something else it could be easier. For example you want the up vector which is the image of the "k" vector of the base B by our transformation T, so it is [j1,j2,j3] no ? Then, you cannot get easy the focus point, but you can easy get the focus vector : it is [k1,k2,k3] ! (actualy maybe it is -1*[k1,k2,k3]). If you look well the LookAt_ method of X.camera3D, it does not give a focus point to webgl but a normalized focus vector : the point position doesn't matter, you just need 1 point on the focus vector, and you can compute it now, no ? It's just a sum of currentposition & currentfocusvector coordinates.
I wish my memories are well and I am not saying total sh*t.
Just one question : there is a setter for the view matrix, so why do you want to store & set up/focus/position instead of directly storing and setting view ?
PS : caution, There could be a scale operator k, so the matrix would be different different, but I don't think there is in xtk.
PS 2 : in bold are vectors. [number,number,number] is a 3D vector shown by his coordinates.