Geometry module
- Last UpdatedJun 29, 2026
- 3 minute read
The Geometry module provides a set of static, utility methods for common geometric computations in 3D space. It includes point and line projection onto planes, line–line intersection, perpendicular computation, and quaternion generation from direction vectors.
This module is a dependency for the Measure module to properly calculate diameter measures.
The module is defined in the Geometry namespace and all methods are exposed as public static members of the Geometry::Stubs class, so they can be called directly from any script without instantiation.
Including the module
To include the Geometry module in your project, add the following line to your project.
<Module name="gemoerty_module" version="1.0.0" moduleType="GeometryModule" />
The module needs to be included only once. It will not trigger errors if instantiated multiple times.
Public interface
The public interface for the Geometry module.
|
Method |
Signature |
Description |
|---|---|---|
|
ProjectLineToPlane |
List<vector3> ProjectLineToPlane(vector3 planePoint, vector3 planeNormal, vector3 linePoint, vector3 lineDirection) |
Projects a line onto a plane. Returns a List<vector3> with two elements: the projected line point (index 0) and the projected line direction (index 1). Input arguments are:
|
|
ProjectPointToPlane |
vector3 ProjectPointToPlane(vector3 planePoint, vector3 planeNormal, vector3 point) |
Projects a single point onto a plane and returns the projected vector3 position. Input arguments are:
|
|
ProjectVectorToPlane |
vector3 ProjectVectorToPlane(vector3 planeNormal, vector3 vector) |
Projects a direction vector onto a plane and returns the resulting vector3. If the input vector is parallel to the plane normal, the result is Vector3.Zero; the caller is responsible for checking this case. Input arguments are:
|
|
GetPerpAtDistance |
bool GetPerpAtDistance(vector3 linePoint, vector3 lineDirection, double distance, vector3 planeDirection, List<vector3> result) |
Computes a perpendicular line at a given distance along an input line, within a reference plane. Returns true on success and populates result with two elements: the perpendicular origin point (index 0) and the perpendicular direction (index 1). Returns false if the perpendicular direction cannot be computed (for example, when the line direction and plane direction are nearly parallel). Input arguments are:
|
|
QuatFromVectors |
quaternion QuatFromVectors(vector3 startVector, vector3 endVector) |
Computes the rotation quaternion that transforms startVector into endVector. Both input vectors are assumed to be normalized. The returned quaternion represents the shortest-arc rotation between the two directions. Input arguments are:
|
|
IntersectLinesInPlane |
bool IntersectLinesInPlane(vector3 pA, vector3 dA, vector3 pB, vector3 dB, List<double> outResult) |
Computes the intersection of two lines that are assumed to lie in the same plane. Returns true if an intersection exists and populates outResult with three double values representing the X, Y, and Z components of the intersection point. Returns false if the lines are parallel (cross product of directions is zero). Input arguments are:
|
Use example
// Project a line onto the XZ plane (Y = 0)
vector3 planePoint = {0, 0, 0};
vector3 planeNormal = {0, 1, 0};
vector3 linePoint = {1, 5, 0};
vector3 lineDirection = {0, 0, 1};
List<vector3> projected = Geometry::Stubs.ProjectLineToPlane(planePoint, planeNormal, linePoint, lineDirection);
// projected[0] is the projected point, projected[1] is the projected direction
// Find intersection of two lines in a plane
vector3 pA = {0, 0, 0};
vector3 dA = {1, 0, 0};
vector3 pB = {0, 0, 1};
vector3 dB = {0, 0, 1};
List<double> intersection = {0, 0, 0};
bool found = Geometry::Stubs.IntersectLinesInPlane(pA, dA, pB, dB, intersection);
if (found)
{
vector3 point = {intersection[0], intersection[1], intersection[2]};
Runtime::Environment.Print("Intersection at: " + point);
}