z-value of a projected 3d point - graphics

After a 3d point has been transformed by a perspective projection matrix, what do the Z coordinate stand for? Distance from the 'eye'? Distance from the near clip plane? None of this?
Edit
I've set up a matrix using the glFustrum definition found here.
Then, I transform a 3D point with that matrix.
I'm left with a 3D point where X and Y are the coordinates of the point on the near frustum face, and Z, supposedly a depth information that I have a hard time exploiting.
Thanks!

The transformed z (that you use as denominator for dividing x and y) is the distance from the eye in the perpendicular direction to the projection plane, scaled so that the projection plane is at distance 1.

It's been a while for me, but if you have the X and Y coordinates on the frustrum, does not the Z control the layer order?

Related

In geometry nodes how can I align instances to both a curve and ground plane?

Given this simple setup:
Node Tree
Viewport Preview
How can I align the planes instances such that the y axis of each plane is parallel to the curve, and the x axis of the planes are parallel to the ground plane (x and Y axis)?
I've tried various combinations with "Align Eular to Vector" node, but as soon as the curve does not face a specific axis the planes get tilted and the alignment to ground plane is lost.
any suggestions?
So after some research I found a solution to my own question. I'm posting it in case anyone else needs to find this out.
Note that I'm not a mathematician and there might be a shorter solution (or specific nodes that I'm not aware of that can perform some of the steps). Also note that this is a solution for instances on a straight line which is what I was aiming for, I didn't test this setup on a curved line but my guess is that it will not work.
For that you'll need to perform step 3 for every point or something like that.
Ok here we go:
Generate instances on a line with the instance on point node.
Auto orient the instances on the z axis with the align Euler to vector node based on the normal of the line.
Calculate a vector between 2 points on the line (which point is not important since the line is straight but the order of the subtraction does!). To calculate the vector from point 1 to point 2 you'll have to subtract point 1 from point 2 (like so: point 2 - point 1).
Calculate the angle between the new vector and the vector of the ground plane [0,0,1]. to do that use this formula:
θ = arccosine ( dot product/ ( length(v1) * length(v2) ) ).
Calculate the complementary angle which is 90 degrees - θ
*** convert 90 to radians of course
rotate the instances on x axis by the result value.
Node Tree
Result
If there is a shorter/easier solution, let me know.

Calculate equidistant point with minimal distance from 3 points in N-dimensional space

I'm trying to code the Ritter's bounding sphere algorithm in arbitrary dimensions, and I'm stuck on the part of creating a sphere which would have 3 given points on it's edge, or in other words, a sphere which would be defined by 3 points in N-dimensional space.
That sphere's center would be the minimal-distance equidistant point from the (defining) 3 points.
I know how to solve it in 2-D (circumcenter of a triangle defined by 3 points), and I've seen some vector calculations for 3D, but I don't know what the best method would be for N-D, and if it's even possible.
(I'd also appreciate any other advice about the smallest bounding sphere calculations in ND, in case I'm going in the wrong direction.)
so if I get it right:
Wanted point p is intersection between 3 hyper-spheres of the same radius r where the centers of hyper-spheres are your points p0,p1,p2 and radius r is minimum of all possible solutions. In n-D is arbitrary point defined as (x1,x2,x3,...xn)
so solve following equations:
|p-p0|=r
|p-p1|=r
|p-p2|=r
where p,r are unknowns and p0,p1,p2 are knowns. This lead to 3*n equations and n+1 unknowns. So get all the nonzero r solutions and select the minimal. To compute correctly chose some non trivial equation (0=r) from each sphere to form system of n+1 =equations and n+1 unknowns and solve it.
[notes]
To ease up the processing you can have your equations in this form:
(p.xi-p0.xi)^2=r^2
and use sqrt(r^2) only after solution is found (ignoring negative radius).
there is also another simpler approach possible:
You can compute the plane in which the points p0,p1,p2 lies so just find u,v coordinates of these points inside this plane. Then solve your problem in 2D on (u,v) coordinates and after that convert found solution form (u,v) back to your n-D space.
n=(p1-p0)x(p2-p0); // x is cross product
u=(p1-p0); u/=|u|;
v=u x n; v/=|v|; // x is cross product
if memory of mine serves me well then conversion n-D -> u,v is done like this:
P0=(0,0);
P1=(|p1-p0|,0);
P2=(dot(p2-p0,u),dot(p2-p0,v));
where P0,P1,P2 are 2D points in (u,v) coordinate system of the plane corresponding to points p0,p1,p2 in n-D space.
conversion back is done like this:
p=(P.u*u)+(P.v*v);
My Bounding Sphere algorithm only calculates a near-optimal sphere, in 3 dimensions.
Fischer has an exact, minimal bounding hyper-sphere (N dimensions.) See his paper: http://people.inf.ethz.ch/gaertner/texts/own_work/seb.pdf.
His (C++/Java)code: https://github.com/hbf/miniball.
Jack Ritter
jack#houseofwords.com

Why quaternion is defined by [vector,w] why not by [point,w]?

A quaternion rotation defines a point in 3d-space and rotation around the axis of that point.
I am trying to understand why quaternion rotation requires a vector and rotation, why not just a 3d point in space and rotation ?
eg : In the following picture a hand points to a point in 3d-space which can be rotated around its axis.
http://s29.postimg.org/ih79tirnr/quarternion.jpg
Thanks
Actually, the x, y and z components of a quaternion define a vector pointing in the direction of the axis of rotation. The w component defines the amount of the rotation along that axis. So, the x, y and z don't actually signify a point at all. As the amount of rotation changes, the length of the x, y, z vector will change but the vector always points in the same direction. It doesn't make sense, therefore, to consider this to be a point in space. It's merely a direction and a rotation around that axis.
I once defined a new class that included a quaternion to define the transformation of an object along with a vector to describe the translation of the object. The object could then represent a complete transformation in 3D space similar to a 3x4 transformation matrix.

Depth of object and depth perception

What is the relationship between the depth of the target 3D object that you wish to draw perception on, and the perceptive depth that is visible.
E.g. if I know a square is x by y by z and I wish to draw it in perspective at distance d hwo do I know how long the z (depth) line should be drawn in relation to the vanishing point (should I draw it 2/3's of the way or 1/5th of the way).
Is there a relation between the two, like; multiply the depth by DepthObject / distanceToVanishingPoint = perceptiveDepth.
THanks.
With perspective projection, your view frustum appears like a triangle from a top (x, z) view. You have a nice theorem which explains the relation between sides of triangles and parallel lines.
For a more practical solution, you should have a closer look at projection matrices.

rotate a plane around a diagonal

I would like to rotate a plane, not around a single (X or Y) axis, but around the diagonal (45 degrees between X and Y). How do I calculate the Rx and Ry given the Rdiagonal?
(Rdiagonal is the amount of rotation I would like to achieve around the diagonal axis).
To clarify: just take a yellow PostIt and draw cross on it (a horizonal and a vertical line). These are the X and Y axes. Rotating around these axes is easy (assuming you can just specify Rx and Ry). But I would like to rotate around the diagonal axis. What are the Rx and Ry in that case?
I think it's something like Rx = Rdiagonal / sqrt(2). But I'm not sure.
This is probably more of a mathoverflow question, but I found some information here about rotation around an arbitrary axis. It provides the derivation for the translation and rotation matrices.
Your plane will most certainly given by some points (depending on the dimensionality). You can then use a rotation matrix to transform these points: new = R * old. Afterwards, construct your plane from these points.
To get the right rotation matrix, see the entry at wikipedia.

Resources