Skip to content

File GeometryUtils.h

FileList > src > utils > GeometryUtils.h

Go to the source code of this file

  • #include "glm/glm.hpp"

Public Functions

Type Name
void ExtendLineSeg (glm::vec3 & pt1, glm::vec3 & pt2, float extendLen)
Make a line segment longer by a certain length.
bool FormLongestLineSeg (const std::vector< glm::vec3 > & pts, glm::vec3 & pt1, glm::vec3 & pt2)
From a list of points, find 2 point that forms the longest line segment.
float GetAngleBetweenVectors (glm::vec3 v1, glm::vec3 v2, bool useDegree=false)
Get the angle between 2 vectors.
bool GetIntersectLineOf2Planes (glm::vec3 p1Norm, glm::vec3 pt1, glm::vec3 p2Norm, glm::vec3 pt2, glm::vec3 & lineVec, glm::vec3 & linePt)
Get the Intersect Line Of 2 Planes.
bool GetIntersectPointOf2Lines (glm::vec3 dir1, glm::vec3 pt1, glm::vec3 dir2, glm::vec3 pt2, glm::vec3 & pt)
Get the Intersect Point Of 2 Lines.
bool GetIntersectPointOfLineAndLineSeg (glm::vec3 lineVec, glm::vec3 linePt, glm::vec3 lineSegPt1, glm::vec3 lineSegPt2, glm::vec3 & ptInLineSeg)
Get the Intersect Point Of Line And Line Seg object.
bool GetIntersectPointOfLineAndPlane (glm::vec3 lineVec, glm::vec3 linePt, glm::vec3 planeNormal, glm::vec3 planePt, glm::vec3 & intersectPt)
Get the Intersect Point Of Line And Plane object.
bool GetIntersectPointOfLineSegAndPlane (glm::vec3 lineSegPt1, glm::vec3 lineSegPt2, glm::vec3 planeNormal, glm::vec3 planePt, glm::vec3 & intersectPt)
Get the Intersect Point Of Line Seg And Plane object.
glm::vec3 GetNearestPtOnLine (glm::vec3 lineVec, glm::vec3 linePt, glm::vec3 pt)
Get the Nearest Pt On Line object.
glm::vec3 GetProjectionPointOnPlane (glm::vec3 planeNormal, glm::vec3 planePt, glm::vec3 pt)
Get the projection point of a point on a plane.
bool IsPointBetweenLineSeg (glm::vec3 pt, glm::vec3 lineSegPt1, glm::vec3 lineSegPt2)
Check if a point is between a line segment, no matter if the point is on the line segment or not.
bool IsSameDirection (glm::vec3 v1, glm::vec3 v2)
Check if 2 vectors are in the same direction (angle < 180 degree)

Public Functions Documentation

function ExtendLineSeg

Make a line segment longer by a certain length.

inline void ExtendLineSeg (
    glm::vec3 & pt1,
    glm::vec3 & pt2,
    float extendLen
) 

Parameters:

  • pt1 Start of the line segment
  • pt2 End of the line segment
  • extendLen Length to extend

function FormLongestLineSeg

From a list of points, find 2 point that forms the longest line segment.

inline bool FormLongestLineSeg (
    const std::vector< glm::vec3 > & pts,
    glm::vec3 & pt1,
    glm::vec3 & pt2
) 

Parameters:

  • pts Candidate points
  • pt1 Start of the line segment
  • pt2 End of the line segment

Returns:

true if the line segment is formed successfully


function GetAngleBetweenVectors

Get the angle between 2 vectors.

inline float GetAngleBetweenVectors (
    glm::vec3 v1,
    glm::vec3 v2,
    bool useDegree=false
) 

Parameters:

  • v1
  • v2

Returns:

float


function GetIntersectLineOf2Planes

Get the Intersect Line Of 2 Planes.

inline bool GetIntersectLineOf2Planes (
    glm::vec3 p1Norm,
    glm::vec3 pt1,
    glm::vec3 p2Norm,
    glm::vec3 pt2,
    glm::vec3 & lineVec,
    glm::vec3 & linePt
) 

Parameters:

  • p1Norm
  • pt1
  • p2Norm
  • pt2
  • lineVec
  • linePt

Returns:

true if intersect, false if not


function GetIntersectPointOf2Lines

Get the Intersect Point Of 2 Lines.

inline bool GetIntersectPointOf2Lines (
    glm::vec3 dir1,
    glm::vec3 pt1,
    glm::vec3 dir2,
    glm::vec3 pt2,
    glm::vec3 & pt
) 

Parameters:

  • dir1
  • pt1
  • dir2
  • pt2
  • pt

Returns:

true if intersect, false if not


function GetIntersectPointOfLineAndLineSeg

Get the Intersect Point Of Line And Line Seg object.

inline bool GetIntersectPointOfLineAndLineSeg (
    glm::vec3 lineVec,
    glm::vec3 linePt,
    glm::vec3 lineSegPt1,
    glm::vec3 lineSegPt2,
    glm::vec3 & ptInLineSeg
) 

Parameters:

  • lineVec
  • linePt
  • lineSegPt1
  • lineSegPt2
  • ptInLineSeg

Returns:

true if intersect, false if not


function GetIntersectPointOfLineAndPlane

Get the Intersect Point Of Line And Plane object.

inline bool GetIntersectPointOfLineAndPlane (
    glm::vec3 lineVec,
    glm::vec3 linePt,
    glm::vec3 planeNormal,
    glm::vec3 planePt,
    glm::vec3 & intersectPt
) 

Parameters:

  • lineVec
  • linePt
  • planeNormal
  • planePt
  • intersectPt

Returns:

true if intersect, false if not


function GetIntersectPointOfLineSegAndPlane

Get the Intersect Point Of Line Seg And Plane object.

inline bool GetIntersectPointOfLineSegAndPlane (
    glm::vec3 lineSegPt1,
    glm::vec3 lineSegPt2,
    glm::vec3 planeNormal,
    glm::vec3 planePt,
    glm::vec3 & intersectPt
) 

Parameters:

  • lineSegPt1
  • lineSegPt2
  • planeNormal
  • planePt
  • intersectPt

Returns:

true

Returns:

false


function GetNearestPtOnLine

Get the Nearest Pt On Line object.

inline glm::vec3 GetNearestPtOnLine (
    glm::vec3 lineVec,
    glm::vec3 linePt,
    glm::vec3 pt
) 

Parameters:

  • lineVec
  • linePt
  • pt

Returns:

glm::vec3


function GetProjectionPointOnPlane

Get the projection point of a point on a plane.

inline glm::vec3 GetProjectionPointOnPlane (
    glm::vec3 planeNormal,
    glm::vec3 planePt,
    glm::vec3 pt
) 

Parameters:

  • planeNormal Normal of the plane
  • planePt A point on the plane
  • point The point to project

Returns:

glm::vec3 The projection point


function IsPointBetweenLineSeg

Check if a point is between a line segment, no matter if the point is on the line segment or not.

inline bool IsPointBetweenLineSeg (
    glm::vec3 pt,
    glm::vec3 lineSegPt1,
    glm::vec3 lineSegPt2
) 

Parameters:

  • pt Point to check
  • lineSegPt1 Start of the line segment
  • lineSegPt2 End of the line segment

Returns:

true if the point is between the line segment


function IsSameDirection

Check if 2 vectors are in the same direction (angle < 180 degree)

inline bool IsSameDirection (
    glm::vec3 v1,
    glm::vec3 v2
) 

Parameters:

  • v1
  • v2

Returns:

true if in the same direction



The documentation for this class was generated from the following file src/utils/GeometryUtils.h