What is the last row of an origin for? - graphics

i have the rotation matrix
cos sin 0 0
-sin cos 0 0
0 0 0 0
0 0 0 1
If I were to change the last row to
1 1 1 1
will it rotate with (1,1,1) as the axis?
If not, what it do, and what does the '1' at row 4 column 4 do?

If you change the last row, it will change the 4th coordinate, which in turn will change the x,y,z coordinates of your vector. The 1 at the bottom right corner simply preserves the 4th coordinate after matrix multiplication.
The 4th coordinate is a "scaling factor" (called the Homogenious coordinate). It is used for perspective projection. In short, (x,y,z,w) is converted to (x/w,y/w,z/w).

Related

What if my dataset contains only 0 and 1? Can I check for correlation for them and get the significant results in Excel?

My data set looks like this:
P T O
1 1 0
1 0 1
1 1 1
0 1 0
1 1 0
My doubt is that we only have two values i.e. zero and one. That would logically mean that correlation can not compute the level of significance. My assumption is in this case it would be than calculating the coefficient based on occurrence of 4 combination i.e. {(1,1),(1,0),(0,1),(0,0)} rather than calculating in the magnitude of change in variables. But conversely if coefficient works only on magnitude of change, than is this the right method for my data set?
Could anyone tell me if I am on right track of thoughts or calculating such coefficient yields no significance?

What does fifth column of feColorMatrix stands for exactly

In mozilla's doc for feColorMatrix it is stated that
The SVG filter element changes colors based on a
transformation matrix. Every pixel's color value (represented by an
[R,G,B,A] vector) is matrix multiplied to create a new color.
However in feColorMatrix there are 5 columns, not 4.
In an excellent article that can be considered as a classical reference it is stated that:
The matrix here is actually calculating a final RGBA value in its
rows, giving each RGBA channel its own RGBA channel. The last number
is a multiplier.
But that does not explain a lot. As far as I understand, since after applying filter we basically modify exactly R, G, B and A channels and nothing else there's no need in this additional parameter. Indirectly there's an evidence for that in the article itself - all numerous examples of feColorMatrix-based filters provided - all have zeroes as fifth component. Also, why it's a multiplier?
In another famous article it is stated that:
For the other rows, you are creating each of the rgba output values as
the sum of the rgba input values multiplied by the corresponding
matrix value, plus a constant.
Calling it a constant added makes more sense than calling it a multiplier, however it's still unclear what does fifth component in feColor matrix stands for and what is unachievable without it - so that would be my question.
My last hope was the w3c reference but it's surprisingly vague as well.
The specification is clear although you do need to understand matrix math. The fifth column is a fixed offset. It's useful because if you want to add a specific amount of R/G/B/A to your output, that column is the only way to do it. Or if you want to recolor something to a specific color, that's also the way to do it.
For example - if you have multiple opaque colors in your input, but you want to recolor everything to rgba(255,51,0,1) then this is the matrix you would use.
0 0 0 0 1.0
0 0 0 0 0.2
0 0 0 0 0
0 0 0 1 0
aka
<feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 0.5 0 0 0 0 0 0 0 0 1 0"/>
Try out these sliders for yourself:
https://codepen.io/mullany/pen/qJCDk

does the ordering of the points in vtkCellArray imply adjacency?

I have a closed contour in the form of a polyline. I am accessing the point
through vtkPolyData.GetLines() and iterating through the cells in
vtkCellArray.
I want to calculate the angle bisector at each vertex of the line. Therefore
I need to know the coordinate of V_{i-1}, V_i and V_{i+1}.
In the vtkCellArray, [n0, p_1, p_2,... , p_n0, ... ] , if p_2 comes after
p_1 in the cell , does it mean that p_1 and p_2 are connected together?
Yes, it does. Just to test your case with vtkPolyLine, let's create a vtkPolyData with a single vtkPolyLine where the last point of the line is same as the first point. We will see that the resultant cell array has the same sequence (i.e. the last and first point are the same.)
import vtk as v
pts = v.vtkPoints()
pts.InsertNextPoint(0,0,0)
pts.InsertNextPoint(1,0,0)
pts.InsertNextPoint(2,0,0)
pts.InsertNextPoint(3,0,0)
polyLine = v.vtkPolyLine()
polyLine.GetPointIds().SetNumberOfIds(5)
polyLine.GetPointIds().SetId(0,0)
polyLine.GetPointIds().SetId(1,1)
polyLine.GetPointIds().SetId(2,2)
polyLine.GetPointIds().SetId(3,3)
polyLine.GetPointIds().SetId(4,0)
lines = v.vtkCellArray()
lines.InsertNextCell(polyLine)
pd = v.vtkPolyData()
pd.SetPoints(pts)
pd.SetLines(lines)
wr = v.vtkPolyDataWriter()
wr.SetFileName('Lines.vtk')
wr.SetInputData(pd)
wr.Write()
The file Lines.vtk contains the following:
# vtk DataFile Version 4.2
vtk output
ASCII
DATASET POLYDATA
POINTS 4 float
0 0 0 1 0 0 2 0 0
3 0 0
LINES 1 6
5 0 1 2 3 0 # This line has 5 points and last and first point are the same (0)

Gnuplot summing y values for same x values

I have a dataset which looks like this:
0 1 0.1
0 0 0.1
0 1 0.1
1 0 0.2
0 1 0.2
1 0 0.2
...
I now want to do the following operations on each different value in the third column of the table:
Example for 0.1:
First column values summed: 0+0+0=0
Second column values summed: 1+0+1=2
Now I want to substract these two 2-0=2 and in a last step divide them by the occurrences.
2/3 =0.667
The same for 0.2 and my plot should then plot at x=0.1, y=0.667.
I hope my problem is with the example understandable.
You can use the smooth unique option to do exactly this: sum up all y-values belonging to the same x-value and then divide the result by the number of occurences. For the second column, upon which the operation is performed, you use the difference between the second and first column:
plot 'file.txt' using 3:($2 - $1) smooth unique
However, it seems like you'll run in a strange bug then. This works only correct, if you insert an empty or commented row at the beginning of your data file:
The result with the following file.txt
#
0 1 0.1
0 0 0.1
0 1 0.1
1 0 0.2
0 1 0.2
1 0 0.2
is

heatmap with category data

I'm trying to draw a heatmap via gnuplot. The problem is: how to accumulate data with gnuplot.
Starting with one dataset:
0 0 0
0 1 1
1 0 2
1 1 3
that can be easily plot via
set view map
splot 'test.data' using 2:1:3 with image
The problem is: there is not only one dataset, but many. See this example data:
0 0 0
0 1 1
1 0 2
1 1 3
0 0 3
0 1 2
1 0 1
1 1 20
It has repeating x/y-values. Is it possible to use gnuplot to sum up the third column (the "data-column" like displayed here:
0 0 0 0 0 3 0 0 3
0 1 1 0 1 2 0 1 3
1 0 2 + 1 0 1 = 1 0 3
1 1 3 1 1 20 1 1 23
My first idea was to use every like in plot 'test.data' using 2:1:3 every 4 with image. But this doesn't work. Does anyone have an idea how to do this?
For the interested ones: i want to plot a heatmap of my fitbit data:
https://gist.github.com/senfi/c0d13a2c91fae13bc5f5
This file contains nine weeks of counted steps i made. the first column is the day of the week (sunday to saturday). The second column represents 5-minute-steps through the day starting at 0:00am. Plotting a single week looks nice, but plotting the sum/average of the last two years may look pretty awesome. Of course, i will post a picture, if we figure it out how to plot this. Feel free to use the steps-data.
This looks like a job for awk to me. awk can be called from within gnuplot like this:
sp '<awk ''{a[$1,$2]+=$3}END{for(i in a){split(i,s,SUBSEP);print s[2],s[1],a[i]}}'' test.data' w image
The awk script accumulates the value of the third column into the array a. The key for each value is the string [$1 SUBSEP $2] (equivalent to [$1,$2]). $N is the value of column N. SUBSEP is a built in variable whose value we don't need to worry about, we just refer to it again later.
When the whole file has been read (the END block), split is used to recover the first two columns by breaking up the array keys. The two parts of the key are printed, followed by the accumulated value. I rearranged the column order in awk as well (print s[2],s[1],a[i]) so that back in gnuplot, using 2:1:3 is no longer needed.

Resources