Conscience Core
Functions
conscience_utils::geom Namespace Reference

Functions

bool isPointGreaterThan (const CscPoint3d *a, const CscPoint3d *b)
 
bool equalCscPoint3d (const CscPoint3d *a, const CscPoint3d *b)
 
void removeDuplicatePositionsPerf (vector< CscPoint3d * > *positions)
 
double degToRad (const double &degree)
 
float degToRad (const float &degree)
 
double radToDeg (const double &radian)
 
double getShortestAngleSigned (const double &fromAngle, const double &toAngle)
 
double averageOfAngleInRad (const vector< double > &angles)
 
double averageOfAngleInDeg (const vector< double > &angles)
 
double angleAdjustment (const double &angle)
 
double angleAdjustmentRadsPiToMinusPi (const double &angle)
 
CscQuaternion toQuaternion (double yaw, double pitch, double roll)
 Quaternion is a matrix representation of a rotation in a 3D space. Used to simplify some calculs. More...
 
double calculateAngleBetweenTwoPosition (CscPoint3d *secondPosition, CscPoint3d *firstPosition)
 
double distanceBetween (double x1, double y1, double x2, double y2)
 
CscQuaternion multiplyQuaternion (const CscQuaternion &quaternion1, const CscQuaternion &quaternion2)
 
CscPoint3drotatePointWithQuaternion (CscPoint3d *point, const CscQuaternion &quaternion)
 
CscPoint3dtransformPointFromMatrix (const CscPoint3d *point, const vector< double > &matrix)
 
vector< double > multiplyMatrices (const vector< double > &matrix1, vector< double > &matrix2)
 
Vec4 multiplyMatrixVec4 (const double matrix[4][4], const Vec4 &vec)
 
void multiplyMat4 (const double a[4][4], const double b[4][4], double result[4][4])
 
string mat4ToString (const double matrix[4][4])
 
string vec3ToString (const Vec3 &vec)
 
void copyMat4 (const double source[4][4], double target[4][4])
 
bool comparePoint3d (const CscPoint3d *p1, const CscPoint3d *p2)
 Compares two 3D points for equality, if a point is nullptr , return true only if the second is nullptr. More...
 
double getPointsHighestX (const std::vector< const CscPoint3d * > &areaVertices, optional< double > precision)
 
double getPointsLowestX (const std::vector< const CscPoint3d * > &areaVertices, optional< double > precision)
 
double getPointsHighestZ (const std::vector< const CscPoint3d * > &areaVertices, optional< double > precision)
 
double getPointsLowestZ (const std::vector< const CscPoint3d * > &areaVertices, optional< double > precision)
 
bool isPointInsideArea (const std::vector< const CscPoint3d * > &areaVertices, CscPoint3d *pointToCheck)
 
float getMinXForUpStep (float upMin, float upMax, const vector< CscPoint3d * > *positions)
 
float getMaxXForUpStep (float upMin, float upMax, const vector< CscPoint3d * > *positions)
 
float getMinYForUpStep (float upMin, float upMax, const vector< CscPoint3d * > *positions)
 
float getMaxYForUpStep (float upMin, float upMax, const vector< CscPoint3d * > *positions)
 
CscPoint3dzUpToYup (CscPoint3d *position)
 
CscPoint3dgetMinPoint (vector< CscPoint3d * > *positions)
 
CscPoint3dgetMaxPoint (vector< CscPoint3d * > *positions)
 
void removeDuplicatePositions (vector< CscPoint3d * > *positions)
 
double dotXZ (const CscPoint3d &a, const CscPoint3d &b)
 
double normXZ (const CscPoint3d &v)
 
CscPoint3d normalizeXZ (const CscPoint3d &v)
 
CscPoint3d perpendicularXZ (const CscPoint3d &v)
 
double signedDistanceToLineXZ (const CscPoint3d &p, const CscPoint3d &origin, const CscPoint3d &normal)
 
bool pointInTriangleXZWithEpsilon (const CscPoint3d &pt, const CscPoint3d &a, const CscPoint3d &b, const CscPoint3d &c, double epsilon)
 
bool pointInQuadXZWithEpsilon (const CscPoint3d &pt, const CscPoint3d &p1, const CscPoint3d &p2, const CscPoint3d &p3, const CscPoint3d &p4, double epsilon)
 
vector< CscPoint3d * > slicePolygonsAtY (const vector< CscPolygon * > &polygons, double ySlice, double precisionCm=5.0)
 Computes the 2D slice (plan cut) at Y = ySlice and returns a flat list of unique points. Internally builds closed contours and welds nearby vertices (tolerance = precisionCm). The result is a clean set of points that form continuous walls when drawn with nearest-neighbour or contour lines. More...
 
CscPoint3drotatePointWithQuaternion (const CscPoint3d *point, const CscQuaternion &quaternion)
 
vector< double > multiplyMatrices (const vector< double > &matrix1, const vector< double > &matrix2)
 
CscPoint3dgetMinPoint (std::vector< CscPoint3d * > *positions)
 
CscPoint3dgetMaxPoint (std::vector< CscPoint3d * > *positions)
 
void removeDuplicatePositions (std::vector< CscPoint3d * > *positions)
 
void removeDuplicatePositionsPerf (std::vector< CscPoint3d * > *positions)
 
double getIntersectionOverUnion (const cv::Rect2d &bb1, const cv::Rect2d &bb2)
 
bool isRotationMatrix (const cv::Mat &R)
 
void rotateMatrix (const cv::Mat &src, double angleDegrees, cv::Mat &target, cv::Scalar fillColor)
 
cv::Vec3f rotationMatrixToEulerAngles (const cv::Mat &R)
 
bool matIsEqual (const cv::Mat &img1, const cv::Mat &img2)
 
template<typename T >
bool isIncludedInOther (const cv::Rect_< T > &rect1, const cv::Rect_< T > &rect2)
 
template<typename T >
cv::Point_< T > rectangleCenter (const cv::Rect_< T > &rect)
 
template<typename T >
distanceBetween (const cv::Point_< T > &point, const cv::Point_< T > &point2)
 
template<typename T >
cv::Point_< T > pointsCenter (const cv::Point_< T > &point, const cv::Point_< T > &point2)
 
template<typename T >
distanceBetween (const cv::Rect_< T > &rectangle1, const cv::Rect_< T > &rectangle2)
 
template<typename T >
string rectToString (const cv::Rect_< T > &rect)
 
template<typename T >
string pointToString (const cv::Point_< T > &point)
 
template<typename T >
string sizeToString (const cv::Size_< T > &size)
 
template<typename T >
cv::Rect_< T > averageRectangle (const vector< cv::Rect_< T >> &rectangles)
 
template<typename T >
bool equals (const cv::Size_< T > &size1, const cv::Size_< T > &size2)
 
template<typename T >
double anglePointsInRad (const cv::Point_< T > &point, const cv::Point_< T > &point2)
 

Function Documentation

◆ angleAdjustment()

double conscience_utils::geom::angleAdjustment ( const double &  angle)

Reduces the results in-between [-180;180] interval counterclock-wise. parameter in degree

◆ angleAdjustmentRadsPiToMinusPi()

double conscience_utils::geom::angleAdjustmentRadsPiToMinusPi ( const double &  angle)

Reduces the results in-between [PI;-PI] interval

◆ anglePointsInRad()

template<typename T >
double conscience_utils::geom::anglePointsInRad ( const cv::Point_< T > &  point,
const cv::Point_< T > &  point2 
)

computes angle between two points. point is the reference, point 2 is the other drawing the line of the angle

◆ averageOfAngleInDeg()

double conscience_utils::geom::averageOfAngleInDeg ( const vector< double > &  angles)

parameters in degrees and returns in degrees. interval [-180;180]

◆ averageOfAngleInRad()

double conscience_utils::geom::averageOfAngleInRad ( const vector< double > &  angles)

parameters in radians and returns in radians. interval [-π;π]

◆ averageRectangle()

template<typename T >
cv::Rect_<T> conscience_utils::geom::averageRectangle ( const vector< cv::Rect_< T >> &  rectangles)

◆ calculateAngleBetweenTwoPosition()

double conscience_utils::geom::calculateAngleBetweenTwoPosition ( CscPoint3d secondPosition,
CscPoint3d firstPosition 
)

Angle calculation in a -180 to 180 degree trigonometry. Warning : the importance of order in parameter, switching the 2 position will change the resuls.

◆ comparePoint3d()

bool conscience_utils::geom::comparePoint3d ( const CscPoint3d p1,
const CscPoint3d p2 
)

Compares two 3D points for equality, if a point is nullptr , return true only if the second is nullptr.

◆ copyMat4()

void conscience_utils::geom::copyMat4 ( const double  source[4][4],
double  target[4][4] 
)

◆ degToRad() [1/2]

double conscience_utils::geom::degToRad ( const double &  degree)

Results will be defined in-between [-π;π] counterclock-wise

◆ degToRad() [2/2]

float conscience_utils::geom::degToRad ( const float &  degree)

◆ distanceBetween() [1/3]

template<typename T >
T conscience_utils::geom::distanceBetween ( const cv::Point_< T > &  point,
const cv::Point_< T > &  point2 
)

◆ distanceBetween() [2/3]

template<typename T >
T conscience_utils::geom::distanceBetween ( const cv::Rect_< T > &  rectangle1,
const cv::Rect_< T > &  rectangle2 
)

Distance between rectangles centers

◆ distanceBetween() [3/3]

double conscience_utils::geom::distanceBetween ( double  x1,
double  y1,
double  x2,
double  y2 
)

◆ dotXZ()

double conscience_utils::geom::dotXZ ( const CscPoint3d a,
const CscPoint3d b 
)

Returns the scalar product of two 3D vectors, considering only their X and Z components.

◆ equalCscPoint3d()

bool conscience_utils::geom::equalCscPoint3d ( const CscPoint3d a,
const CscPoint3d b 
)

◆ equals()

template<typename T >
bool conscience_utils::geom::equals ( const cv::Size_< T > &  size1,
const cv::Size_< T > &  size2 
)

◆ getIntersectionOverUnion()

double conscience_utils::geom::getIntersectionOverUnion ( const cv::Rect2d &  bb1,
const cv::Rect2d &  bb2 
)

◆ getMaxPoint() [1/2]

CscPoint3d* conscience_utils::geom::getMaxPoint ( std::vector< CscPoint3d * > *  positions)

◆ getMaxPoint() [2/2]

CscPoint3d* conscience_utils::geom::getMaxPoint ( vector< CscPoint3d * > *  positions)

◆ getMaxXForUpStep()

float conscience_utils::geom::getMaxXForUpStep ( float  upMin,
float  upMax,
const vector< CscPoint3d * > *  positions 
)

◆ getMaxYForUpStep()

float conscience_utils::geom::getMaxYForUpStep ( float  upMin,
float  upMax,
const vector< CscPoint3d * > *  positions 
)

◆ getMinPoint() [1/2]

CscPoint3d* conscience_utils::geom::getMinPoint ( std::vector< CscPoint3d * > *  positions)

◆ getMinPoint() [2/2]

CscPoint3d* conscience_utils::geom::getMinPoint ( vector< CscPoint3d * > *  positions)

◆ getMinXForUpStep()

float conscience_utils::geom::getMinXForUpStep ( float  upMin,
float  upMax,
const vector< CscPoint3d * > *  positions 
)

◆ getMinYForUpStep()

float conscience_utils::geom::getMinYForUpStep ( float  upMin,
float  upMax,
const vector< CscPoint3d * > *  positions 
)

◆ getPointsHighestX()

double conscience_utils::geom::getPointsHighestX ( const std::vector< const CscPoint3d * > &  areaVertices,
optional< double >  precision 
)

◆ getPointsHighestZ()

double conscience_utils::geom::getPointsHighestZ ( const std::vector< const CscPoint3d * > &  areaVertices,
optional< double >  precision 
)

◆ getPointsLowestX()

double conscience_utils::geom::getPointsLowestX ( const std::vector< const CscPoint3d * > &  areaVertices,
optional< double >  precision 
)

◆ getPointsLowestZ()

double conscience_utils::geom::getPointsLowestZ ( const std::vector< const CscPoint3d * > &  areaVertices,
optional< double >  precision 
)

◆ getShortestAngleSigned()

double conscience_utils::geom::getShortestAngleSigned ( const double &  fromAngle,
const double &  toAngle 
)

Angle calculation in a -180 to 180 degree trigonometry. Warning : the importance of order in parameter, switching the 2 angles will change the resuls.

◆ isIncludedInOther()

template<typename T >
bool conscience_utils::geom::isIncludedInOther ( const cv::Rect_< T > &  rect1,
const cv::Rect_< T > &  rect2 
)

Returns true if first rectangle is inside second, and vice & versa

◆ isPointGreaterThan()

bool conscience_utils::geom::isPointGreaterThan ( const CscPoint3d a,
const CscPoint3d b 
)

◆ isPointInsideArea()

bool conscience_utils::geom::isPointInsideArea ( const std::vector< const CscPoint3d * > &  areaVertices,
CscPoint3d pointToCheck 
)

◆ isRotationMatrix()

bool conscience_utils::geom::isRotationMatrix ( const cv::Mat &  R)

◆ mat4ToString()

string conscience_utils::geom::mat4ToString ( const double  matrix[4][4])

◆ matIsEqual()

bool conscience_utils::geom::matIsEqual ( const cv::Mat &  img1,
const cv::Mat &  img2 
)

◆ multiplyMat4()

void conscience_utils::geom::multiplyMat4 ( const double  a[4][4],
const double  b[4][4],
double  result[4][4] 
)

◆ multiplyMatrices() [1/2]

vector<double> conscience_utils::geom::multiplyMatrices ( const vector< double > &  matrix1,
const vector< double > &  matrix2 
)

◆ multiplyMatrices() [2/2]

vector<double> conscience_utils::geom::multiplyMatrices ( const vector< double > &  matrix1,
vector< double > &  matrix2 
)

◆ multiplyMatrixVec4()

Vec4 conscience_utils::geom::multiplyMatrixVec4 ( const double  matrix[4][4],
const Vec4 vec 
)

◆ multiplyQuaternion()

CscQuaternion conscience_utils::geom::multiplyQuaternion ( const CscQuaternion quaternion1,
const CscQuaternion quaternion2 
)

return a NEW quaternion corresponding to the multiplication of the 2 quaternions given

◆ normalizeXZ()

CscPoint3d conscience_utils::geom::normalizeXZ ( const CscPoint3d v)

Returns a unit vector (length = 1) in the same XZ direction as the input vector. If the vector is zero-length in the XZ plane, returns a zero vector.

◆ normXZ()

double conscience_utils::geom::normXZ ( const CscPoint3d v)

Computes the Euclidean norm (length) of a vector using only its X and Z components.

◆ perpendicularXZ()

CscPoint3d conscience_utils::geom::perpendicularXZ ( const CscPoint3d v)

Returns a vector rotated 90 degrees to the left (counter-clockwise) in the XZ plane. The Y component is always set to zero.

◆ pointInQuadXZWithEpsilon()

bool conscience_utils::geom::pointInQuadXZWithEpsilon ( const CscPoint3d pt,
const CscPoint3d p1,
const CscPoint3d p2,
const CscPoint3d p3,
const CscPoint3d p4,
double  epsilon 
)

Checks if a point is inside a quadrilateral (p1->p2->p3->p4, XZ plane) with an epsilon tolerance

◆ pointInTriangleXZWithEpsilon()

bool conscience_utils::geom::pointInTriangleXZWithEpsilon ( const CscPoint3d pt,
const CscPoint3d a,
const CscPoint3d b,
const CscPoint3d c,
double  epsilon 
)

Checks if a point is inside a triangle (XZ plane) with an epsilon tolerance

◆ pointsCenter()

template<typename T >
cv::Point_<T> conscience_utils::geom::pointsCenter ( const cv::Point_< T > &  point,
const cv::Point_< T > &  point2 
)
inline

◆ pointToString()

template<typename T >
string conscience_utils::geom::pointToString ( const cv::Point_< T > &  point)

◆ radToDeg()

double conscience_utils::geom::radToDeg ( const double &  radian)

Results will be defined in-between [-180;180] counterclock-wise

◆ rectangleCenter()

template<typename T >
cv::Point_<T> conscience_utils::geom::rectangleCenter ( const cv::Rect_< T > &  rect)

◆ rectToString()

template<typename T >
string conscience_utils::geom::rectToString ( const cv::Rect_< T > &  rect)

◆ removeDuplicatePositions() [1/2]

void conscience_utils::geom::removeDuplicatePositions ( std::vector< CscPoint3d * > *  positions)

◆ removeDuplicatePositions() [2/2]

void conscience_utils::geom::removeDuplicatePositions ( vector< CscPoint3d * > *  positions)

◆ removeDuplicatePositionsPerf() [1/2]

void conscience_utils::geom::removeDuplicatePositionsPerf ( std::vector< CscPoint3d * > *  positions)

◆ removeDuplicatePositionsPerf() [2/2]

void conscience_utils::geom::removeDuplicatePositionsPerf ( vector< CscPoint3d * > *  positions)

◆ rotateMatrix()

void conscience_utils::geom::rotateMatrix ( const cv::Mat &  src,
double  angleDegrees,
cv::Mat &  target,
cv::Scalar  fillColor 
)

◆ rotatePointWithQuaternion() [1/2]

CscPoint3d* conscience_utils::geom::rotatePointWithQuaternion ( const CscPoint3d point,
const CscQuaternion quaternion 
)

return a NEW point corresponding to point rotate with the quaternion

◆ rotatePointWithQuaternion() [2/2]

CscPoint3d* conscience_utils::geom::rotatePointWithQuaternion ( CscPoint3d point,
const CscQuaternion quaternion 
)

◆ rotationMatrixToEulerAngles()

cv::Vec3f conscience_utils::geom::rotationMatrixToEulerAngles ( const cv::Mat &  R)

◆ signedDistanceToLineXZ()

double conscience_utils::geom::signedDistanceToLineXZ ( const CscPoint3d p,
const CscPoint3d origin,
const CscPoint3d normal 
)

Computes the signed distance from point p to a line defined by an origin and a unit normal vector in the XZ plane. The sign indicates which side of the line the point is on.

◆ sizeToString()

template<typename T >
string conscience_utils::geom::sizeToString ( const cv::Size_< T > &  size)

◆ slicePolygonsAtY()

vector< CscPoint3d * > conscience_utils::geom::slicePolygonsAtY ( const vector< CscPolygon * > &  polygons,
double  ySlice,
double  precisionCm = 5.0 
)

Computes the 2D slice (plan cut) at Y = ySlice and returns a flat list of unique points. Internally builds closed contours and welds nearby vertices (tolerance = precisionCm). The result is a clean set of points that form continuous walls when drawn with nearest-neighbour or contour lines.

Parameters
polygonsInput triangle mesh (coordinates in centimeters)
ySliceY level of the cutting plane (in centimeters)
precisionCmTolerance in centimeters for welding nearby intersection points Default = 5.0 cm
Returns
std::vector<CscPoint3d*> containing all unique slice points. Caller owns the memory – must DELETE the pointers when finished.

◆ toQuaternion()

CscQuaternion conscience_utils::geom::toQuaternion ( double  yaw,
double  pitch,
double  roll 
)

Quaternion is a matrix representation of a rotation in a 3D space. Used to simplify some calculs.

◆ transformPointFromMatrix()

CscPoint3d * conscience_utils::geom::transformPointFromMatrix ( const CscPoint3d point,
const vector< double > &  matrix 
)

◆ vec3ToString()

string conscience_utils::geom::vec3ToString ( const Vec3 vec)

◆ zUpToYup()

CscPoint3d * conscience_utils::geom::zUpToYup ( CscPoint3d position)