XII Release 0.1.0
Loading...
Searching...
No Matches
xiiIntersectionUtils Namespace Reference

Copyright (c) Theophilus Eriata. All Rights Reserved. More...

Functions

XII_FOUNDATION_DLL bool RayTriangleIntersection (const xiiVec3 &vRayStartPos, const xiiVec3 &vRayDir, const xiiVec3 &vVertex0, const xiiVec3 &vVertex1, const xiiVec3 &vVertex2, float *out_pIntersectionTime=nullptr, xiiVec3 *out_pIntersectionPoint=nullptr)
 Copyright (c) Theophilus Eriata. All Rights Reserved.
XII_FOUNDATION_DLL bool RayTriangleIntersection (const xiiVec3d &vRayStartPos, const xiiVec3d &vRayDir, const xiiVec3d &vVertex0, const xiiVec3d &vVertex1, const xiiVec3d &vVertex2, double *out_pIntersectionTime=nullptr, xiiVec3d *out_pIntersectionPoint=nullptr)
XII_FOUNDATION_DLL bool RayPolygonIntersection (const xiiVec3 &vRayStartPos, const xiiVec3 &vRayDir, const xiiVec3 *pPolygonVertices, xiiUInt32 uiNumVertices, float *out_pIntersectionTime=nullptr, xiiVec3 *out_pIntersectionPoint=nullptr, xiiUInt32 uiVertexStride=sizeof(xiiVec3))
XII_FOUNDATION_DLL bool RayPolygonIntersection (const xiiVec3d &vRayStartPos, const xiiVec3d &vRayDir, const xiiVec3d *pPolygonVertices, xiiUInt32 uiNumVertices, double *out_pIntersectionTime=nullptr, xiiVec3d *out_pIntersectionPoint=nullptr, xiiUInt32 uiVertexStride=sizeof(xiiVec3d))
XII_FOUNDATION_DLL xiiVec3 ClosestPoint_PointLineSegment (const xiiVec3 &vStartPoint, const xiiVec3 &vLineSegmentPos0, const xiiVec3 &vLineSegmentPos1, float *out_pFractionAlongSegment=nullptr)
XII_FOUNDATION_DLL xiiVec3d ClosestPoint_PointLineSegment (const xiiVec3d &vStartPoint, const xiiVec3d &vLineSegmentPos0, const xiiVec3d &vLineSegmentPos1, double *out_pFractionAlongSegment=nullptr)
XII_FOUNDATION_DLL bool Ray2DLine2D (const xiiVec2 &vRayStartPos, const xiiVec2 &vRayDir, const xiiVec2 &vLineSegmentPos0, const xiiVec2 &vLineSegmentPos1, float *out_pIntersectionTime=nullptr, xiiVec2 *out_pIntersectionPoint=nullptr)
 Computes the intersection point and time of the 2D ray with the 2D line segment. Returns true, if there is an intersection.
XII_FOUNDATION_DLL bool Ray2DLine2D (const xiiVec2d &vRayStartPos, const xiiVec2d &vRayDir, const xiiVec2d &vLineSegmentPos0, const xiiVec2d &vLineSegmentPos1, double *out_pIntersectionTime=nullptr, xiiVec2d *out_pIntersectionPoint=nullptr)
 Computes the intersection point and time of the 2D ray with the 2D line segment. Returns true, if there is an intersection.
XII_FOUNDATION_DLL bool IsPointOnLine (const xiiVec3 &vLineStart, const xiiVec3 &vLineEnd, const xiiVec3 &vPoint, float fMaxDist=0.01f)
 Tests whether a point is located on a line.
XII_FOUNDATION_DLL bool IsPointOnLine (const xiiVec3d &vLineStart, const xiiVec3d &vLineEnd, const xiiVec3d &vPoint, double fMaxDist=0.001)
 Tests whether a point is located on a line.

Detailed Description

Copyright (c) Theophilus Eriata. All Rights Reserved.

Function Documentation

◆ ClosestPoint_PointLineSegment() [1/2]

xiiVec3 xiiIntersectionUtils::ClosestPoint_PointLineSegment ( const xiiVec3 & vStartPoint,
const xiiVec3 & vLineSegmentPos0,
const xiiVec3 & vLineSegmentPos1,
float * out_pFractionAlongSegment = nullptr )

Returns point on the line segment that is closest to vStartPoint. Optionally also returns the fraction along the segment, where that point is located.

◆ ClosestPoint_PointLineSegment() [2/2]

xiiVec3d xiiIntersectionUtils::ClosestPoint_PointLineSegment ( const xiiVec3d & vStartPoint,
const xiiVec3d & vLineSegmentPos0,
const xiiVec3d & vLineSegmentPos1,
double * out_pFractionAlongSegment = nullptr )

Returns point on the line segment that is closest to vStartPoint. Optionally also returns the fraction along the segment, where that point is located.

◆ RayPolygonIntersection() [1/2]

bool xiiIntersectionUtils::RayPolygonIntersection ( const xiiVec3 & vRayStartPos,
const xiiVec3 & vRayDir,
const xiiVec3 * pPolygonVertices,
xiiUInt32 uiNumVertices,
float * out_pIntersectionTime = nullptr,
xiiVec3 * out_pIntersectionPoint = nullptr,
xiiUInt32 uiVertexStride = sizeof(xiiVec3) )

Checks whether a ray intersects with a polygon.

The vertex winding order does not matter, polygons will be hit from both sides.

Parameters
vRayStartPosThe start position of the ray.
vRayDirThe direction of the ray. This does not need to be normalized. Depending on its length, out_fIntersectionTime will be scaled differently.
pPolygonVerticesPointer to the first vertex of the polygon.
uiNumVerticesThe number of vertices in the polygon.
out_fIntersectionTimeThe 'time' at which the ray intersects the polygon. If vRayDir is normalized, this is the exact distance. out_fIntersectionPoint == vRayStartPos + vRayDir * out_fIntersectionTime This parameter is optional and may be set to nullptr.
out_fIntersectionPointThe point where the ray intersects the polygon. out_fIntersectionPoint == vRayStartPos + vRayDir * out_fIntersectionTime This parameter is optional and may be set to nullptr.
uiVertexStrideThe stride in bytes between each vertex in the pPolygonVertices array. If the array is tightly packed, this will equal sizeof(xiiVec3), but it can be larger, if the vertices are interleaved with other data.
Returns
True, if the ray intersects the polygon, false otherwise.

◆ RayPolygonIntersection() [2/2]

bool xiiIntersectionUtils::RayPolygonIntersection ( const xiiVec3d & vRayStartPos,
const xiiVec3d & vRayDir,
const xiiVec3d * pPolygonVertices,
xiiUInt32 uiNumVertices,
double * out_pIntersectionTime = nullptr,
xiiVec3d * out_pIntersectionPoint = nullptr,
xiiUInt32 uiVertexStride = sizeof(xiiVec3d) )

Checks whether a ray intersects with a polygon.

The vertex winding order does not matter, polygons will be hit from both sides.

Parameters
vRayStartPosThe start position of the ray.
vRayDirThe direction of the ray. This does not need to be normalized. Depending on its length, out_fIntersectionTime will be scaled differently.
pPolygonVerticesPointer to the first vertex of the polygon.
uiNumVerticesThe number of vertices in the polygon.
out_fIntersectionTimeThe 'time' at which the ray intersects the polygon. If vRayDir is normalized, this is the exact distance. out_fIntersectionPoint == vRayStartPos + vRayDir * out_fIntersectionTime This parameter is optional and may be set to nullptr.
out_fIntersectionPointThe point where the ray intersects the polygon. out_fIntersectionPoint == vRayStartPos + vRayDir * out_fIntersectionTime This parameter is optional and may be set to nullptr.
uiVertexStrideThe stride in bytes between each vertex in the pPolygonVertices array. If the array is tightly packed, this will equal sizeof(xiiVec3d), but it can be larger, if the vertices are interleaved with other data.
Returns
True, if the ray intersects the polygon, false otherwise.

◆ RayTriangleIntersection() [1/2]

bool xiiIntersectionUtils::RayTriangleIntersection ( const xiiVec3 & vRayStartPos,
const xiiVec3 & vRayDir,
const xiiVec3 & vVertex0,
const xiiVec3 & vVertex1,
const xiiVec3 & vVertex2,
float * out_pIntersectionTime = nullptr,
xiiVec3 * out_pIntersectionPoint = nullptr )

Copyright (c) Theophilus Eriata. All Rights Reserved.

Checks whether a ray intersects with a triangle.

The vertex winding order does not matter, triangles will be hit from both sides.

Parameters
vRayStartPosThe start position of the ray.
vRayDirThe direction of the ray. This does not need to be normalized. Depending on its length, out_fIntersectionTime will be scaled differently.
vVertex0,vVertex1,vVertex2The three vertices forming the triangle.
out_fIntersectionTimeThe 'time' at which the ray intersects the triangle. If vRayDir is normalized, this is the exact distance. out_fIntersectionPoint == vRayStartPos + vRayDir * out_fIntersectionTime This parameter is optional and may be set to nullptr.
out_fIntersectionPointThe point where the ray intersects the triangle. out_fIntersectionPoint == vRayStartPos + vRayDir * out_fIntersectionTime This parameter is optional and may be set to nullptr.
Returns
True, if the ray intersects the triangle, false otherwise.

◆ RayTriangleIntersection() [2/2]

bool xiiIntersectionUtils::RayTriangleIntersection ( const xiiVec3d & vRayStartPos,
const xiiVec3d & vRayDir,
const xiiVec3d & vVertex0,
const xiiVec3d & vVertex1,
const xiiVec3d & vVertex2,
double * out_pIntersectionTime = nullptr,
xiiVec3d * out_pIntersectionPoint = nullptr )

Checks whether a ray intersects with a triangle.

The vertex winding order does not matter, triangles will be hit from both sides.

Parameters
vRayStartPosThe start position of the ray.
vRayDirThe direction of the ray. This does not need to be normalized. Depending on its length, out_fIntersectionTime will be scaled differently.
vVertex0,vVertex1,vVertex2The three vertices forming the triangle.
out_fIntersectionTimeThe 'time' at which the ray intersects the triangle. If vRayDir is normalized, this is the exact distance. out_fIntersectionPoint == vRayStartPos + vRayDir * out_fIntersectionTime This parameter is optional and may be set to nullptr.
out_fIntersectionPointThe point where the ray intersects the triangle. out_fIntersectionPoint == vRayStartPos + vRayDir * out_fIntersectionTime This parameter is optional and may be set to nullptr.
Returns
True, if the ray intersects the triangle, false otherwise.