Geometric Utility Functions

This topic documents some global utility functions for doing geometric computations.

  • BaryCoords() - Given three points in 2D space (or 3D space) forming a triangle, and a fourth point in the plane of that triangle, this function returns the barycentric coordinates of that point relative to the triangle. Note: If the face (or set of 3 points) is degenerate, i.e. if it has a zero length normal vector ((p1-p0)^(p2-p0)), the methods return Point3(-1,1,1).
  • RayHitsBox() - Returns TRUE if the specified ray intersects the specified box; otherwise FALSE.
  • DistPtToLine() - Computes the distance of point q from the line with endpoints p0 and p1.
  • Dist3DPtToLine() - Computes the distance of point q from the line with endpoints p0 and p1.
  • ComputeBumpVectors() - Computes the 3 Bump basis vectors from the UVW's at the triangle. Takes as input the coordinates of triangle vertices (usually in camera space). The output is the 3 bump basis vectors (normalized) corresponding to the U,V,and W axes
  • ComputeBumpVec2D() - Computes the 2 Bump basis vectors from the UV, VW, or WU at a triangle. The axis value is 0 for UV (AXIS_UV), 1 for VW (AXIS_VW), and 2 for WU (AXIS_WU). The output of this function are 2 bump basis vectors (normalized) corresponding to the specified axes.
  • CompressNormal() - Compresses a unit vector from a Point3 to a ULONG and returns it. Note that it is only accurate to 1 part in 512.
  • DeCompressNormal() - Decompresses a unit vector into a Point3.
  • ArbAxies() - This is used to come up with an arbitrary axis system given an "up" direction. This conforms to the AutoCAD algorithm.

See Also