Plane
Module of libSIMDx86

The Plane module of libSIMDx86 gives
functions to accelerate basic operations used with planes. A plane
represents a 3D surface, infinitely thin, with a normal that points
orthogonal to the surface. Given any three points, there is a plane
that unites them. Planes can be used to divide a world in half for
quick sorting, for example, a near view plane can be used to test
object's bounding spheres against to tell whether they are in view or
not, rather than later in the pipeline where it is much more
expensive. Planes can also be used for collision detection, such as
using a plane as a floor surface in which all objects may not go
behind (thus, not fall through the floor). Planes are expressed in
Hesse normal form, that is: ax + by + cz + dw = 0 (where w = 1.0 for
3D vectors). In order for these functions to produce correct results,
the plane must be normalized.

typedef
struct SIMDx86Plane

{

float
a, b, c, d;

} SIMDx86Plane ALIGNED;

void SIMDx86Plane_FromPolygon(SIMDx86Plane* pOut, const SIMDx86Polygon* pPoly);

This function constructs a plane from a polygon's three points. The plane is not normalized.

void SIMDx86Plane_FromPoints(SIMDx86Plane* pOut, const SIMDx86Vector* pA, const SIMDx86Vector* pB,const SIMDx86Vector* pC);

This function constructs a plane from three points. The plane is not normalized.

float SIMDx86Plane_DistToPoint(const SIMDx86Plane* pPlane, const SIMDx86Vector* pPoint);

This function returns the unsigned distance between a point and a plane.

float SIMDx86Plane_DistToSphere(const SIMDx86Plane* pPlane, const SIMDx86Sphere* pSphere);

This function returns the unsigned distance between a point and a sphere. A value of zero indicates intersection, but not the depth of the intersection.

float SIMDx86Plane_DistToOrigin(const SIMDx86Plane* pPlane);

This
function returns the unsigned distance between the plane and the
origin. This is the 'd' component when the plane is normalized.

float SIMDx86Plane_Dot(const SIMDx86Plane* pPlane, const SIMDx86Vector* pVec);

This function returns the dot product between a plane and a point with w = 1.0. This is useful for classifying a point in relation to a plane: a value of less than zero implies the point it behind the plane, a value of zero implies the point is on the plane, and value of greater than zero implies the point is in front of the plane.

float
SIMDx86Plane_Dot4(const
SIMDx86Plane* pPlane, const
float*
pVec4);

This function returns the dot product between a plane and a 4D point. This is useful for classifying a point in relation to a plane: a value of less than zero implies the point it behind the plane, a value of zero implies the point is on the plane, and value of greater than zero implies the point is in front of the plane.

float
SIMDx86Plane_DotNormal(const
SIMDx86Plane* pPlane, const
SIMDx86Vector* pVec);

This functions returns the dot product between the plane's normal and another normal. This represents the cosine of the angle between the two, if both are normalized.

float
SIMDx86Plane_DotPlane(const
SIMDx86Plane* pPlane1, const
SIMDx86Plane* pPlane2)

This functions returns the dot product between the two planes' normals. This represents the cosine of the dihedral angle between the two, if both are normalized.

void
SIMDx86Plane_Normalize(SIMDx86Plane* pOut);

This
function normalizes the plane such that the magnitude of its normal
is 1 and modifies 'd' component appropriately.^{ }

void
SIMDx86Plane_NormalizeOf(SIMDx86Plane* pOut, const
SIMDx86Plane* pIn);

This
function stores the normalized plane pIn
into pOut,
while pIn
is unaffected.^{ }