struct plane2
Defined at line 168 of file ../../src/ui/lib/escher/geometry/types.h
A "plane2" is simply a line that exists on the z = 0 (XY) plane.
In standard form this would be written Ax + By + C = 0, where
(A,B) are the coordinates of the normal vector of the plane and
C is the distance to the origin along that normal vector. (AB)
is represented by the parameter "direction" and 'C' is represented
by the parameter "distance". This is analogous to the equation of
a plane in 3D which is given by the equation Ax + By + Cz + D = 0.
To generate a "plane2" (line) that represents the intersection of
an arbitrary 3D (clip) plane and the Z = 0 plane, we simply have
to solve the following system of equations:
1) Ax + By + Cz + D = 0
2) z = 0
This can be achieved by simply substituting equation 2 into equation
1 to yield Ax + By + D = 0, which is the same as our line equation
as given above, meaning that for any arbitrary 3D plane, we can find
its line of intersection on the Z = 0 plane by simply deleting the
original Z component.
We do however require that the normal vector (AB) is normalized,
despite the fact that mathematically the line equation Ax + By + C = 0
does not require a normalized (AB) to be a valid line equation.
It is easy to renormalize the equation by realizing that the line
equation can be rewritten as dot(AB, XY) = -D which itself can be
expanded out to be |AB| * |XY| * cosTheta = -D. Dividing both
sides of the equation by |AB| yields:
(|AB|/|AB|) * |XY| * cosTheta = -D / |AB| =
|XY| * cosTheta = -D / |AB|
So what this means in terms of our implementation is just that we
have to drop the Z component from the incoming direction, renormalize
the remaining two components, and then divide the distance by the
pre-normalized 2D direction.
One last thing to note is that this only works if the incoming 3D plane
is NOT parallel to the Z = 0 plane. This means we need to check if the
direction of the incoming plane is (0,0,1) or (0,0,-1) using FX_DCHECK
to make sure this is not the case. We use a small epsilon value to
check within the vicinity of z=1 to account for any floating point wackiness.
Public Methods
void plane2 (const planeN<vec3> & plane)
Project a 3D plane onto the Z=0 plane, as described above.
Defined at line 172 of file ../../src/ui/lib/escher/geometry/types.h