# Unigine::Geometry Class

This class is used to represent a collection of generic 3d math functions such as line plane intersection, closest points on two lines, etc.

## voidgetClosestPointOnLine ( const Math::dvec3 & point, const Math::dvec3 & p0, const Math::dvec3 & p1, Math::dvec3 & ret ) #

Scans the specified line segment and searches for the point closest to the reference point. The found point will be put to the return vector.

### Arguments

• const Math::dvec3 & point - Reference point.
• const Math::dvec3 & p0 - Line start point.
• const Math::dvec3 & p1 - Line end point.
• Math::dvec3 & ret - Return vector.

## voidgetClosestPointOnLine ( const Math::vec3 & point, const Math::vec3 & p0, const Math::vec3 & p1, Math::vec3 & ret ) #

Scans the specified line segment and searches for the point closest to the reference point. The found point will be put to the return vector.

### Arguments

• const Math::vec3 & point - Reference point.
• const Math::vec3 & p0 - Line start point.
• const Math::vec3 & p1 - Line end point.
• Math::vec3 & ret - Return vector.

## intgetClosestPointOnTriangle ( const Math::dvec3 & point, const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2, Math::dvec3 & ret ) #

Scans the specified triangle and searches for the point closest to the reference point. The found point will be put to the return vector.

### Arguments

• const Math::dvec3 & point - Reference point.
• const Math::dvec3 & v0 - The first vertex of the triangle.
• const Math::dvec3 & v1 - The second vertex of the triangle.
• const Math::dvec3 & v2 - The third vertex of the triangle.
• Math::dvec3 & ret - Return vector.

### Return value

1 if the point is inside the triangle; otherwise, 0

## intgetClosestPointOnTriangle ( const Math::vec3 & point, const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2, Math::vec3 & ret ) #

Scans the specified triangle and searches for the point closest to the reference point. The found point will be put to the return vector.

### Arguments

• const Math::vec3 & point - Reference point.
• const Math::vec3 & v0 - The first vertex of the triangle.
• const Math::vec3 & v1 - The second vertex of the triangle.
• const Math::vec3 & v2 - The third vertex of the triangle.
• Math::vec3 & ret - Return vector.

### Return value

1 if the point is inside the triangle; otherwise, 0

## intgetClosestPointsOnLines ( const Math::dvec3 & p00, const Math::dvec3 & p01, const Math::dvec3 & p10, const Math::dvec3 & p11, Math::dvec3 & ret_0, Math::dvec3 & ret_1 ) #

Scans the two specified lines and searches for the pair of closest points. The closest points of the first and the second lines will be put to the respective return vector.

### Arguments

• const Math::dvec3 & p00 - Start point of the first line.
• const Math::dvec3 & p01 - End point of the first line.
• const Math::dvec3 & p10 - Start point of the second line.
• const Math::dvec3 & p11 - End point of the second line.
• Math::dvec3 & ret_0 - First return vector.
• Math::dvec3 & ret_1 - Second return vector.

### Return value

1 if the lines cross; otherwise, 0

## intgetClosestPointsOnLines ( const Math::vec3 & p00, const Math::vec3 & p01, const Math::vec3 & p10, const Math::vec3 & p11, Math::vec3 & ret_0, Math::vec3 & ret_1 ) #

Scans the two specified lines and searches for the pair of closest points. The closest points of the first and the second lines will be put to the respective return vectors.

### Arguments

• const Math::vec3 & p00 - Start point of the first line.
• const Math::vec3 & p01 - End point of the first line.
• const Math::vec3 & p10 - Start point of the second line.
• const Math::vec3 & p11 - End point of the second line.
• Math::vec3 & ret_0 - First return vector.
• Math::vec3 & ret_1 - Second return vector.

### Return value

1 if the lines cross; otherwise, 0

## intirayBoundBoxIntersection ( const Math::dvec3 & point, const Math::dvec3 & idirection, const Math::dvec3 & min, const Math::dvec3 & max ) #

Checks if there is an intersection between a ray and a bounding box. The same function as rayBoundBoxIntersection(), but it uses the inverse of the ray direction, which increases performance.

### Arguments

• const Math::dvec3 & point - Starting point of the ray.
• const Math::dvec3 & idirection - Inverse direction of the ray.
• const Math::dvec3 & min - Min coordinates of the axis-aligned bounding box.
• const Math::dvec3 & max - Max coordinates of the axis-aligned bounding box.

### Return value

1 if the given ray intersects the given bounding box; otherwise, 0.

## intirayBoundBoxIntersection ( const Math::vec3 & point, const Math::vec3 & idirection, const Math::vec3 & min, const Math::vec3 & max ) #

Checks if there is an intersection between a ray and a bounding box. The same function as rayBoundBoxIntersection(), but it uses the inverse of the ray direction, which increases performance.

### Arguments

• const Math::vec3 & point - Starting point of the ray.
• const Math::vec3 & idirection - Inverse direction of the ray.
• const Math::vec3 & min - Min coordinates of the axis-aligned bounding box.
• const Math::vec3 & max - Max coordinates of the axis-aligned bounding box.

### Return value

1 if the given ray intersects the given bounding box; otherwise, 0.

## intlinePlaneIntersection ( const Math::vec3 & p0, const Math::vec3 & p1, const Math::vec4 & plane ) #

Checks if there is an intersection between a line and a plane.

### Arguments

• const Math::vec3 & p0 - Start point of the line.
• const Math::vec3 & p1 - End point of the line.
• const Math::vec4 & plane - Plane.

### Return value

1 if the given line intersects the given plane; otherwise, 0.

## intlinePlaneIntersection ( const Math::vec3 & p0, const Math::vec3 & p1, const Math::vec3 & plane_point, const Math::vec3 & plane_normal, Math::vec3 & ret ) #

Calculates the intersection of a line and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::vec3 & p0 - Start point of the line.
• const Math::vec3 & p1 - End point of the line.
• const Math::vec3 & plane_point - Point of the plane.
• const Math::vec3 & plane_normal - Normal to the plane.
• Math::vec3 & ret - Return vector.

### Return value

1 if the given line intersects the given plane; otherwise, 0.

## intlinePlaneIntersection ( const Math::dvec3 & p0, const Math::dvec3 & p1, const Math::dvec3 & plane_point, const Math::dvec3 & plane_normal ) #

Checks if there is an intersection between a line and a plane.

### Arguments

• const Math::dvec3 & p0 - Start point of the line.
• const Math::dvec3 & p1 - Start point of the line.
• const Math::dvec3 & plane_point - Point of the plane.
• const Math::dvec3 & plane_normal - Normal to the plane.

### Return value

1 if the given line intersects the given plane; otherwise, 0.

## intlinePlaneIntersection ( const Math::dvec3 & p0, const Math::dvec3 & p1, const Math::dvec3 & plane_point, const Math::dvec3 & plane_normal, Math::dvec3 & ret ) #

Calculates the intersection of a line and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::dvec3 & p0 - Start point of the line.
• const Math::dvec3 & p1 - End point of the line.
• const Math::dvec3 & plane_point - Point of the plane.
• const Math::dvec3 & plane_normal - Normal to the plane.
• Math::dvec3 & ret - Return vector.

### Return value

1 if the given line intersects the given plane; otherwise, 0.

## intlinePlaneIntersection ( const Math::vec3 & p0, const Math::vec3 & p1, const Math::vec3 & plane_point, const Math::vec3 & plane_normal ) #

Checks if there is an intersection between a line and a plane.

### Arguments

• const Math::vec3 & p0 - Start point of the line.
• const Math::vec3 & p1 - End point of the line.
• const Math::vec3 & plane_point - Point of the plane.
• const Math::vec3 & plane_normal - Normal to the plane.

### Return value

1 if the given line intersects the given plane; otherwise, 0.

## intlinePlaneIntersection ( const Math::dvec3 & p0, const Math::dvec3 & p1, const Math::dvec4 & plane, Math::dvec3 & ret ) #

Calculates the intersection of a line and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::dvec3 & p0 - Start point of the line.
• const Math::dvec3 & p1 - End point of the line.
• const Math::dvec4 & plane - Plane.
• Math::dvec3 & ret - Return vector.

### Return value

1 if the given line intersects the given plane; otherwise, 0.

## intlinePlaneIntersection ( const Math::vec3 & p0, const Math::vec3 & p1, const Math::vec4 & plane, Math::vec3 & ret ) #

Calculates the intersection of a line and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::vec3 & p0 - Start point of the line.
• const Math::vec3 & p1 - End point of the line.
• const Math::vec4 & plane - Plane.
• Math::vec3 & ret - Return vector.

### Return value

1 if the given line intersects the given plane; otherwise, 0.

## intlinePlaneIntersection ( const Math::dvec3 & p0, const Math::dvec3 & p1, const Math::dvec4 & plane ) #

Checks if there is an intersection between a line and a plane.

### Arguments

• const Math::dvec3 & p0 - Start point of the line.
• const Math::dvec3 & p1 - End point of the line.
• const Math::dvec4 & plane - Plane.

### Return value

1 if the given line intersects the given plane; otherwise, 0.

## floatnormalizeAngle ( float angle ) #

Normalizes the angle in [-180, 180 ] range.

### Arguments

• float angle - Input angle.

### Return value

Normalized angle, in degrees.

## voidorthoBasis ( const Math::vec3 & v, Math::vec3 & tangent, Math::vec3 & binormal ) #

Creates an ortho transformation. Output tangent and binormal vectors will be put to corresponding return vector.

### Arguments

• const Math::vec3 & v - Input vector.
• Math::vec3 & tangent - Return vector.
• Math::vec3 & binormal - Return vector.

## voidorthoBasis ( const Math::dvec3 & v, Math::dvec3 & tangent, Math::dvec3 & binormal ) #

Creates an ortho transformation. Output tangent and binormal vectors will be put to corresponding return vectors.

### Arguments

• const Math::dvec3 & v - Input vector.
• Math::dvec3 & tangent - Return vector.
• Math::dvec3 & binormal - Return vector.

## Math::quatorthoTangent ( const Math::vec3 & tangent, const Math::vec3 & binormal, const Math::vec3 & normal ) #

Creates the ortho triangle tangent space basis.

### Arguments

• const Math::vec3 & tangent - Tangent vector.
• const Math::vec3 & binormal - Binormal vector.
• const Math::vec3 & normal - Normal vector.

Tangent basis.

## Math::quatorthoTangent ( const Math::vec4 & tangent, const Math::vec3 & normal ) #

Creates the ortho triangle tangent space basis.

### Arguments

• const Math::vec4 & tangent - Tangent vector.
• const Math::vec3 & normal - Normal vector.

Tangent basis.

## voidorthoTransform ( const Math::dvec3 & v, Math::dmat4 & transform ) #

Creates an ortho transformation. The transformation will be put to the return matrix.

### Arguments

• const Math::dvec3 & v - Input vector.
• Math::dmat4 & transform - Return matrix.

## voidorthoTransform ( const Math::vec3 & v, Math::mat4 & transform ) #

Creates an ortho transformation. The transformation will be put to the return matrix.

### Arguments

• const Math::vec3 & v - Input vector.
• Math::mat4 & transform - Return matrix.

## floatpointPolygonDistance ( const Math::vec3 & point, const Math::vec3 * vertex, int[] indices, const Math::vec4 & plane ) #

Returns the distance from a point to a polygon.

### Arguments

• const Math::vec3 & point - Point.
• const Math::vec3 * vertex - Pointer to vertex structure.
• int[] indices - Array of vertex indices.
• const Math::vec4 & plane - Polygon plane.

Distance.

## doublepointPolygonDistance ( const Math::dvec3 & point, const Math::dvec3 * vertex, int[] indices, const Math::dvec4 & plane ) #

Returns the distance from a point to a polygon.

### Arguments

• const Math::dvec3 & point - Point.
• const Math::dvec3 * vertex - Pointer to vertex structure.
• int[] indices - Array of vertex indices.
• const Math::dvec4 & plane - Polygon plane.

Distance.

## intpointPolygonInside ( const Math::vec3 & point, const Math::vec3 * vertex, int[] indices, const Math::vec3 & normal ) #

Checks if a point is inside a polygon.

### Arguments

• const Math::vec3 & point - Point.
• const Math::vec3 * vertex - Pointer to vertex structure.
• int[] indices - Array of vertex indices.
• const Math::vec3 & normal - Normal to the polygon plane.

### Return value

1 if the point is inside the given polygon; otherwise, 0.

## intpointPolygonInside ( const Math::dvec3 & point, const Math::dvec3 * vertex, int[] indices, const Math::dvec3 & normal ) #

Checks if a point is inside a polygon.

### Arguments

• const Math::dvec3 & point - Point.
• const Math::dvec3 * vertex - Pointer to vertex structure.
• int[] indices - Array of vertex indices.
• const Math::dvec3 & normal - Normal to the polygon plane.

### Return value

1 if the point is inside the given polygon; otherwise, 0.

## voidpointTriangleCoordinates ( const Math::vec3 & point, const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2, float & a, float & b ) #

Calculates barycentric triangle coordinates. The coordinates will be put to corresponding return variables.

### Arguments

• const Math::vec3 & point - Point.
• const Math::vec3 & v0 - The first vertex of the triangle.
• const Math::vec3 & v1 - The second vertex of the triangle.
• const Math::vec3 & v2 - The third vertex of the triangle.
• float & a - Return variable.
• float & b - Return variable.

## voidpointTriangleCoordinates ( const Math::dvec3 & point, const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2, double & a, double & b ) #

Calculates barycentric triangle coordinates. The coordinates will be put to corresponding return variables.

### Arguments

• const Math::dvec3 & point - Point.
• const Math::dvec3 & v0 - The first vertex of the triangle.
• const Math::dvec3 & v1 - The second vertex of the triangle.
• const Math::dvec3 & v2 - The third vertex of the triangle.
• double & a - Return variable.
• double & b - Return variable.

## doublepointTriangleDistance ( const Math::dvec3 & point, const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2, const Math::dvec4 & plane ) #

Returns the closest distance from a point to a triangle.

### Arguments

• const Math::dvec3 & point - Point.
• const Math::dvec3 & v0 - The first vertex of the triangle.
• const Math::dvec3 & v1 - The second vertex of the triangle.
• const Math::dvec3 & v2 - The third vertex of the triangle.
• const Math::dvec4 & plane - Triangle plane.

Distance.

## floatpointTriangleDistance ( const Math::vec3 & point, const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2, const Math::vec4 & plane ) #

Returns the closest distance from a point to a triangle.

### Arguments

• const Math::vec3 & point - Point.
• const Math::vec3 & v0 - The first vertex of the triangle.
• const Math::vec3 & v1 - The second vertex of the triangle.
• const Math::vec3 & v2 - The third vertex of the triangle.
• const Math::vec4 & plane - Triangle plane.

Distance.

## intpointTriangleInside ( const Math::vec3 & point, const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2, const Math::vec3 & normal ) #

Checks if a point is inside a triangle.

### Arguments

• const Math::vec3 & point - Point.
• const Math::vec3 & v0 - The first vertex of the triangle.
• const Math::vec3 & v1 - The second vertex of the triangle.
• const Math::vec3 & v2 - The third vertex of the triangle.
• const Math::vec3 & normal - Normal to the triangle plane.

### Return value

1 if the point is inside the given triangle; otherwise, 0.

## intpointTriangleInside ( const Math::dvec3 & point, const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2, const Math::dvec3 & normal ) #

Checks if a point is inside a triangle.

### Arguments

• const Math::dvec3 & point - Point.
• const Math::dvec3 & v0 - The first vertex of the triangle.
• const Math::dvec3 & v1 - The second vertex of the triangle.
• const Math::dvec3 & v2 - The third vertex of the triangle.
• const Math::dvec3 & normal - Normal to the triangle plane.

### Return value

1 if the point is inside the given triangle; otherwise, 0.

## intpointTriangleInside ( const Math::dvec3 & point, const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2 ) #

Checks if a point is inside a triangle.

### Arguments

• const Math::dvec3 & point - Point.
• const Math::dvec3 & v0 - The first vertex of the triangle.
• const Math::dvec3 & v1 - The second vertex of the triangle.
• const Math::dvec3 & v2 - The third vertex of the triangle.

### Return value

1 if the point is inside the given triangle; otherwise, 0.

## intpointTriangleInside ( const Math::vec3 & point, const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2 ) #

Checks if a point is inside a triangle.

### Arguments

• const Math::vec3 & point - Point.
• const Math::vec3 & v0 - The first vertex of the triangle.
• const Math::vec3 & v1 - The second vertex of the triangle.
• const Math::vec3 & v2 - The third vertex of the triangle.

### Return value

1 if the point is inside the given triangle; otherwise, 0.

## Math::vec4polygonPlane ( const Math::vec3 * vertex, int[] indices ) #

Returns the polygon plane.

### Arguments

• const Math::vec3 * vertex - Pointer to vertex structure.
• int[] indices - Array of vertex indices.

Polygon plane.

## Math::dvec4polygonPlane ( const Math::dvec3 * vertex, int[] indices ) #

Returns the polygon plane.

### Arguments

• const Math::dvec3 * vertex - Pointer to vertex structure.
• int[] indices - Array of vertex indices.

Polygon plane.

## Math::vec3projectOntoPlane ( const Math::vec3 & v, const Math::vec3 & plane_normal ) #

Calculates the projection of a vector onto a given plane.

### Arguments

• const Math::vec3 & v - Input vector.
• const Math::vec3 & plane_normal - Normal to the plane.

### Return value

Projection of the input vector onto the plane.

## Math::dvec3projectOntoPlane ( const Math::dvec3 & v, const Math::dvec3 & plane_normal ) #

Calculates the projection of a vector onto a given plane.

### Arguments

• const Math::dvec3 & v - Input vector.
• const Math::dvec3 & plane_normal - Normal to the plane.

### Return value

Projection of the input vector onto the plane.

## intrayBoundBoxIntersection ( const Math::dvec3 & point, const Math::dvec3 & direction, const Math::dvec3 & min, const Math::dvec3 & max ) #

Checks if a ray intersects a bounding box. The same function as irayBoundBoxIntersection(), but the latter has higher performance due to reduction of division operations, as the ray direction is replaced by the pre-calculated inverse of the ray direction.

### Arguments

• const Math::dvec3 & point - Starting point of the ray.
• const Math::dvec3 & direction - Direction of the ray.
• const Math::dvec3 & min - Min coordinates of the axis-aligned bounding box.
• const Math::dvec3 & max - Max coordinates of the axis-aligned bounding box.

### Return value

1 if the given ray intersects the given bounding box; otherwise, 0.

## intrayBoundBoxIntersection ( const Math::vec3 & point, const Math::vec3 & direction, const Math::vec3 & min, const Math::vec3 & max ) #

Checks if a ray intersects a bounding box. The same function as irayBoundBoxIntersection(), but the latter has higher performance due to reduction of division operations, as the ray direction is replaced by the pre-calculated inverse of the ray direction.

### Arguments

• const Math::vec3 & point - Starting point of the ray.
• const Math::vec3 & direction - Direction of the ray.
• const Math::vec3 & min - Min coordinates of the axis-aligned bounding box.
• const Math::vec3 & max - Max coordinates of the axis-aligned bounding box.

### Return value

1 if the given ray intersects the given bounding box; otherwise, 0.

## intrayPlaneIntersection ( const Math::vec3 & point, const Math::vec3 & direction, const Math::vec4 & plane ) #

Checks if a ray intersects a plane.

### Arguments

• const Math::vec3 & point - Starting point of the ray.
• const Math::vec3 & direction - Direction of the ray.
• const Math::vec4 & plane - Plane.

### Return value

1 if the given ray intersects the given plane; otherwise, 0.

## intrayPlaneIntersection ( const Math::vec3 & point, const Math::vec3 & direction, const Math::vec3 & plane_point, const Math::vec3 & plane_normal ) #

Checks if a ray intersects a plane.

### Arguments

• const Math::vec3 & point - Starting point of the ray.
• const Math::vec3 & direction - Direction of the ray.
• const Math::vec3 & plane_point - Point on the plane.
• const Math::vec3 & plane_normal - Normal to the plane.

### Return value

1 if the given ray intersects the given plane; otherwise, 0.

## intrayPlaneIntersection ( const Math::dvec3 & point, const Math::dvec3 & direction, const Math::dvec4 & plane, Math::dvec3 & ret ) #

Calculates the intersection of a ray and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::dvec3 & point - Starting point of the ray.
• const Math::dvec3 & direction - Direction of the ray.
• const Math::dvec4 & plane - Plane.
• Math::dvec3 & ret - Return vector.

### Return value

1 if the given ray intersects the given plane; otherwise, 0.

## intrayPlaneIntersection ( const Math::vec3 & point, const Math::vec3 & direction, const Math::vec3 & plane_point, const Math::vec3 & plane_normal, Math::vec3 & ret ) #

Calculates the intersection of a ray and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::vec3 & point - Starting point of the ray.
• const Math::vec3 & direction - Direction of the ray.
• const Math::vec3 & plane_point - Point on the plane.
• const Math::vec3 & plane_normal - Normal to the plane.
• Math::vec3 & ret - Return vector.

### Return value

1 if the given ray intersects the given plane; otherwise, 0.

## intrayPlaneIntersection ( const Math::vec3 & point, const Math::vec3 & direction, const Math::vec4 & plane, Math::vec3 & ret ) #

Calculates the intersection of a ray and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::vec3 & point - Starting point of the ray.
• const Math::vec3 & direction - Direction of the ray.
• const Math::vec4 & plane - Plane.
• Math::vec3 & ret - Return vector.

### Return value

1 if the given ray intersects the given plane; otherwise, 0.

## intrayPlaneIntersection ( const Math::dvec3 & point, const Math::dvec3 & direction, const Math::dvec3 & plane_point, const Math::dvec3 & plane_normal ) #

Checks if a ray intersects a plane.

### Arguments

• const Math::dvec3 & point - Starting point of the ray.
• const Math::dvec3 & direction - Direction of the ray.
• const Math::dvec3 & plane_point - Point on the plane.
• const Math::dvec3 & plane_normal - Normal to the plane.

### Return value

1 if the given ray intersects the given plane; otherwise, 0.

## intrayPlaneIntersection ( const Math::dvec3 & point, const Math::dvec3 & direction, const Math::dvec3 & plane_point, const Math::dvec3 & plane_normal, Math::dvec3 & ret ) #

Calculates the intersection of a ray and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::dvec3 & point - Starting point of the ray.
• const Math::dvec3 & direction - Direction of the ray.
• const Math::dvec3 & plane_point - Point on the plane.
• const Math::dvec3 & plane_normal - Normal to the plane.
• Math::dvec3 & ret - Return vector.

### Return value

1 if the given ray intersects the given plane; otherwise, 0.

## intrayPlaneIntersection ( const Math::dvec3 & point, const Math::dvec3 & direction, const Math::dvec4 & plane ) #

Checks if a ray intersects a plane.

### Arguments

• const Math::dvec3 & point - Starting point of the ray.
• const Math::dvec3 & direction - Direction of the ray.
• const Math::dvec4 & plane - Plane.

### Return value

1 if the given ray intersects the given plane; otherwise, 0.

## intrayTriangleIntersection ( const Math::vec3 & point, const Math::vec3 & direction, const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2 ) #

Checks if a ray intersects a triangle.

### Arguments

• const Math::vec3 & point - Starting point of the ray.
• const Math::vec3 & direction - Direction of the ray.
• const Math::vec3 & v0 - The first triangle vertex.
• const Math::vec3 & v1 - The second triangle vertex.
• const Math::vec3 & v2 - The third triangle vertex.

### Return value

1 if the given ray intersects the given triangle; otherwise, 0.

## intrayTriangleIntersection ( const Math::dvec3 & point, const Math::dvec3 & direction, const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2 ) #

Checks if a ray intersects a triangle.

### Arguments

• const Math::dvec3 & point - Starting point of the ray.
• const Math::dvec3 & direction - Direction of the ray.
• const Math::dvec3 & v0 - The first triangle vertex.
• const Math::dvec3 & v1 - The second triangle vertex.
• const Math::dvec3 & v2 - The third triangle vertex.

### Return value

1 if the given ray intersects the given triangle; otherwise, 0.

## intsegmentPlaneIntersection ( const Math::vec3 & p0, const Math::vec3 & p1, const Math::vec4 & plane, Math::vec3 & ret ) #

Calculates the intersection of a segment and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::vec3 & p0 - Start point of the line segment.
• const Math::vec3 & p1 - End point of the line segment.
• const Math::vec4 & plane - Plane.
• Math::vec3 & ret - Return vector.

### Return value

1 if the given ray intersects the given triangle; otherwise, 0.

## intsegmentPlaneIntersection ( const Math::vec3 & p0, const Math::vec3 & p1, const Math::vec3 & plane_point, const Math::vec3 & plane_normal ) #

Checks if a segment intersects a plane.

### Arguments

• const Math::vec3 & p0 - Start point of the line segment.
• const Math::vec3 & p1 - End point of the line segment.
• const Math::vec3 & plane_point - Point on the plane.
• const Math::vec3 & plane_normal - Normal to the plane.

### Return value

1 if the given segment intersects the given plane; otherwise, 0.

## intsegmentPlaneIntersection ( const Math::vec3 & p0, const Math::vec3 & p1, const Math::vec4 & plane ) #

Checks if a segment intersects a plane.

### Arguments

• const Math::vec3 & p0 - Start point of the line segment.
• const Math::vec3 & p1 - End point of the line segment.
• const Math::vec4 & plane - Plane.

### Return value

1 if the given segment intersects the given plane; otherwise, 0.

## intsegmentPlaneIntersection ( const Math::vec3 & p0, const Math::vec3 & p1, const Math::vec3 & plane_point, const Math::vec3 & plane_normal, Math::vec3 & ret ) #

Calculates the intersection of a line segment and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::vec3 & p0 - Start point of the line segment.
• const Math::vec3 & p1 - End point of the line segment.
• const Math::vec3 & plane_point - Point on the plane.
• const Math::vec3 & plane_normal - Normal to the plane.
• Math::vec3 & ret - Return vector.

### Return value

1 if the given segment intersects the given plane; otherwise, 0.

## intsegmentPlaneIntersection ( const Math::dvec3 & p0, const Math::dvec3 & p1, const Math::dvec4 & plane ) #

Checks if a segment intersects a plane.

### Arguments

• const Math::dvec3 & p0 - Start point of the line segment.
• const Math::dvec3 & p1 - End point of the line segment.
• const Math::dvec4 & plane - Plane.

### Return value

1 if the given segment intersects the given plane; otherwise, 0.

## intsegmentPlaneIntersection ( const Math::dvec3 & p0, const Math::dvec3 & p1, const Math::dvec3 & plane_point, const Math::dvec3 & plane_normal ) #

Checks if a segment intersects a plane.

### Arguments

• const Math::dvec3 & p0 - Start point of the line segment.
• const Math::dvec3 & p1 - End point of the line segment.
• const Math::dvec3 & plane_point - Point on the plane.
• const Math::dvec3 & plane_normal - Normal to the plane.

### Return value

1 if the given segment intersects the given plane; otherwise, 0.

## intsegmentPlaneIntersection ( const Math::dvec3 & p0, const Math::dvec3 & p1, const Math::dvec4 & plane, Math::dvec3 & ret ) #

Calculates the intersection of a line segment and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::dvec3 & p0 - Start point of the line segment.
• const Math::dvec3 & p1 - End point of the line segment.
• const Math::dvec4 & plane - Plane.
• Math::dvec3 & ret - Return vector.

### Return value

1 if the given segment intersects the given plane; otherwise, 0.

## intsegmentPlaneIntersection ( const Math::dvec3 & p0, const Math::dvec3 & p1, const Math::dvec3 & plane_point, const Math::dvec3 & plane_normal, Math::dvec3 & ret ) #

Calculates the intersection of a line segment and a plane. If the function returns 1, the point of intersection will be put to the return vector.

### Arguments

• const Math::dvec3 & p0 - Start point of the line segment.
• const Math::dvec3 & p1 - End point of the line segment.
• const Math::dvec3 & plane_point - Point on the plane.
• const Math::dvec3 & plane_normal - Normal to the plane.
• Math::dvec3 & ret - Return vector.

### Return value

1 if the given segment intersects the given plane; otherwise, 0.

## doubletriangleArea ( const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2 ) #

Returns the triangle area.

### Arguments

• const Math::dvec3 & v0 - The first triangle vertex.
• const Math::dvec3 & v1 - The second triangle vertex.
• const Math::dvec3 & v2 - The third triangle vertex.

Triangle area.

## floattriangleArea ( const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2 ) #

Returns the triangle area.

### Arguments

• const Math::vec3 & v0 - The first triangle vertex.
• const Math::vec3 & v1 - The second triangle vertex.
• const Math::vec3 & v2 - The third triangle vertex.

Triangle area.

## Math::dvec3triangleNormal ( const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2 ) #

Returns the triangle normal vector.

### Arguments

• const Math::dvec3 & v0 - The first triangle vertex.
• const Math::dvec3 & v1 - The second triangle vertex.
• const Math::dvec3 & v2 - The third triangle vertex.

### Return value

Triangle normal vector.

## Math::vec3triangleNormal ( const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2 ) #

Returns the triangle normal vector.

### Arguments

• const Math::vec3 & v0 - The first triangle vertex.
• const Math::vec3 & v1 - The second triangle vertex.
• const Math::vec3 & v2 - The third triangle vertex.

### Return value

Triangle normal vector.

## Math::vec4trianglePlane ( const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2 ) #

Returns the triangle plane.

### Arguments

• const Math::vec3 & v0 - The first triangle vertex.
• const Math::vec3 & v1 - The second triangle vertex.
• const Math::vec3 & v2 - The third triangle vertex.

Triangle plane.

## Math::dvec4trianglePlane ( const Math::dvec3 & v0, const Math::dvec3 & v1, const Math::dvec3 & v2 ) #

Returns the triangle plane.

### Arguments

• const Math::dvec3 & v0 - The first triangle vertex.
• const Math::dvec3 & v1 - The second triangle vertex.
• const Math::dvec3 & v2 - The third triangle vertex.

Triangle plane.

## Math::vec4triangleTangent ( const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2, const Math::vec2 & t0, const Math::vec2 & t1, const Math::vec2 & t2 ) #

Returns the triangle tangent space.

### Arguments

• const Math::vec3 & v0 - The first triangle vertex.
• const Math::vec3 & v1 - The second triangle vertex.
• const Math::vec3 & v2 - The third triangle vertex.
• const Math::vec2 & t0 - Tangent vector of the first triangle vertex.
• const Math::vec2 & t1 - Tangent vector of the second triangle vertex.
• const Math::vec2 & t2 - Tangent vector of the third triangle vertex.

### Return value

Triangle tangent space vector.

## Math::vec4triangleTangent ( const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2, const Math::vec2 & t0, const Math::vec2 & t1, const Math::vec2 & t2, const Math::vec3 & normal ) #

Returns the triangle tangent space.

### Arguments

• const Math::vec3 & v0 - The first triangle vertex.
• const Math::vec3 & v1 - The second triangle vertex.
• const Math::vec3 & v2 - The third triangle vertex.
• const Math::vec2 & t0 - Tangent vector of the first triangle vertex.
• const Math::vec2 & t1 - Tangent vector of the second triangle vertex.
• const Math::vec2 & t2 - Tangent vector of the third triangle vertex.
• const Math::vec3 & normal - Normal.

### Return value

Triangle tangent space vector.

## Math::vec4triangleTangent ( const Math::vec3 & v0, const Math::vec3 & v1, const Math::vec3 & v2 ) #

Returns the triangle tangent space.

### Arguments

• const Math::vec3 & v0 - The first triangle vertex.
• const Math::vec3 & v1 - The second triangle vertex.
• const Math::vec3 & v2 - The third triangle vertex.

### Return value

Triangle tangent space vector.
Last update: 2022-05-16