gstlearn  1.0.0
CCC
GeometryHelper Class Reference

#include <GeometryHelper.hpp>

Inheritance diagram for GeometryHelper:
GH

Static Public Member Functions

static void rotationGetSinCos (double angle, double *cosa, double *sina)
 
static void rotationMatrixIdentityInPlace (int ndim, VectorDouble &rot)
 
static void rotation2DMatrixInPlace (double angle, VectorDouble &rot)
 
static void rotation3DMatrixInPlace (double alpha, double beta, double gamma, VectorDouble &rot)
 
static void rotationMatrixInPlace (int ndim, const VectorDouble &angles, VectorDouble &rot)
 
static VectorDouble rotationMatrix (int ndim, const VectorDouble &angles)
 
static void rotationGetAnglesInPlace (int ndim, const double *rot, double *angles)
 
static void rotationGetAnglesInPlace (const VectorDouble &rot, VectorDouble &angles)
 
static void rotationCopy (int ndim, const double *rotin, double *rotout)
 
static bool rotationIsIdentity (int ndim, double *rot, double eps=EPSILON10)
 
static MatrixSquareGeneral EulerToRotation (const VectorDouble &angles, const ERotation &convrot=ERotation::fromKey("SXYZ"))
 
static void rotationGetRandomDirection (double ct, double st, double *a, double *codir)
 
static void rotationGetDirection2D (const VectorDouble &angles, VectorDouble &codir)
 
static void rotationGetDirectionDefault (int ndim, VectorDouble &codir)
 
static void rotationGetAnglesFromCodirInPlace (const VectorDouble &codir, VectorDouble &angles)
 
static VectorDouble rotationGetAngles (const VectorDouble &codir, bool flagResize=false)
 
static VectorDouble rotationToEuler (const MatrixSquareGeneral &mat, const ERotation &convrot=ERotation::fromKey("SXYZ"), double eps=EPSILON10)
 
static void mergeBoxes (VectorDouble &mini1, VectorDouble &maxi1, VectorDouble &mini2, VectorDouble &maxi2)
 
static double distancePointToSegment (double x0, double y0, double x1, double y1, double x2, double y2, double *xd, double *yd, int *nint)
 
static int segmentIntersect (double xd1, double yd1, double xe1, double ye1, double xd2, double yd2, double xe2, double ye2, double *xint, double *yint)
 
static bool isSegmentIntersect (double xd1, double yd1, double xe1, double ye1, double xd2, double yd2, double xe2, double ye2)
 
static double geodeticAngularDistance (double long1, double lat1, double long2, double lat2, double radius=1.)
 
static void geodeticAngles (double long1, double lat1, double long2, double lat2, double long3, double lat3, double *a, double *b, double *c, double *A, double *B, double *C)
 
static double geodeticTrianglePerimeter (double long1, double lat1, double long2, double lat2, double long3, double lat3)
 
static double geodeticTriangleSurface (double long1, double lat1, double long2, double lat2, double long3, double lat3)
 
static bool isInSphericalTriangle (double *coor, double surface, double *pts1, double *pts2, double *pts3, double *wgts, double eps=EPSILON6)
 
static bool isInSphericalTriangleOptimized (const double *coor, double *ptsa, double *ptsb, double *ptsc, double *wgts, double eps=EPSILON6)
 
static VectorVectorDouble convertLongLat (const VectorDouble &longitude, const VectorDouble &latitude, double dilate=1., double radius_arg=1.)
 
static void convertCart2Sph (double x, double y, double z, double *rlong, double *rlat, double radius_arg=1.)
 
static void convertSph2Cart (double rlong, double rlat, double *x, double *y, double *z, double radius_arg=1.)
 
static MatrixSquareGeneral gradXYToRotmat (double dzoverdx, double dzoverdy)
 
static MatrixRectangulargetDirectionsInR3 (const MatrixRectangular *U)
 
static MatrixRectangulargetDirectionsInRn (const MatrixRectangular *U)
 
static double formatAngle (double anglein)
 
static VectorDouble formatAngles (const VectorDouble &anglesin)
 
static VectorDouble rayTriangleIntersect (const VectorDouble &dir, const VectorDouble &v0, const VectorDouble &v1, const VectorDouble &v2)
 
static VectorVectorDouble sphBarCoord (const VectorVectorDouble &sphPts, const MatrixRectangular &apices, const MatrixInt &meshes)
 
static double getCosineAngularTolerance (double tolang)
 

Static Private Member Functions

static void _decodeConvRot (const ERotation &convrot, int *firstaxis, int *parity, int *repetition, int *frame)
 

Member Function Documentation

◆ _decodeConvRot()

void GeometryHelper::_decodeConvRot ( const ERotation &  convrot,
int *  firstaxis,
int *  parity,
int *  repetition,
int *  frame 
)
staticprivate

◆ convertCart2Sph()

void GeometryHelper::convertCart2Sph ( double  x,
double  y,
double  z,
double *  rlong,
double *  rlat,
double  radius_arg = 1. 
)
static

Convert the cartesian coordinates into spherical coordinates

Parameters
[in]xFirst cartesian coordinate
[in]ySecond cartesian coordinate
[in]zThird cartesian coordinate
[in]radius_argRadius of the sphere (Earth if TEST)
[out]rlongLongitude (in degrees)
[out]rlatLatitude (in degrees)

◆ convertLongLat()

VectorVectorDouble GeometryHelper::convertLongLat ( const VectorDouble longitude,
const VectorDouble latitude,
double  dilate = 1.,
double  radius_arg = 1. 
)
static

Returns the Vector of Sample coordinates in 3-D from Longitude-Latitude

Parameters
longitudeArray of longitude values
latitudeArray of latitude values
dilateDilation applied to radius
radius_argRadius (if note defined, taken from variety definition)
Returns

◆ convertSph2Cart()

void GeometryHelper::convertSph2Cart ( double  rlong,
double  rlat,
double *  x,
double *  y,
double *  z,
double  radius_arg = 1. 
)
static

Convert the spherical coordinates into cartesian coordinates

Parameters
[in]rlongLongitude (in degrees)
[in]rlatLatitude (in degrees)
[in]radius_argradius of the sphere (Earth if TEST)
[out]xFirst cartesian coordinate
[out]ySecond cartesian coordinate
[out]zThird cartesian coordinate

◆ distancePointToSegment()

double GeometryHelper::distancePointToSegment ( double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2,
double *  xd,
double *  yd,
int *  nint 
)
static

Find the shortest distance between the point (x0,y0) and the segment with the two end points (x1,y1) and (x2,y2)

Returns
Minimum algebraic distance (positive or negative)
Parameters
[in]x0,y0Coordinates of the target point
[in]x1,y1Coordinate of the first end-point of the segment
[in]x2,y2Coordinate of the second end-point of the segment
[out]xd,ydCoordinates of the closest point
[out]nint=1 if the projection belongs to the segment =0 if it is set to one of the segment vertices

◆ EulerToRotation()

MatrixSquareGeneral GeometryHelper::EulerToRotation ( const VectorDouble angles,
const ERotation &  convrot = ERotation::fromKey(                                                 "SXYZ") 
)
static

Returns the Rotation matrix, starting from the Euler angles

Parameters
anglesOrdered list of Euler angles
convrotRotation convention
Returns
Remarks
The code is coming from the following reference (BSD license)
https://github.com/matthew-brett/transforms3d/blob/master/transforms3d/euler.py

◆ formatAngle()

double GeometryHelper::formatAngle ( double  anglein)
static

◆ formatAngles()

VectorDouble GeometryHelper::formatAngles ( const VectorDouble anglesin)
static

◆ geodeticAngles()

void GeometryHelper::geodeticAngles ( double  long1,
double  lat1,
double  long2,
double  lat2,
double  long3,
double  lat3,
double *  a,
double *  b,
double *  c,
double *  A,
double *  B,
double *  C 
)
static

Calculate all geodetic angles from a spherical triangle

Parameters
[in]long1Longitude of the first point (in degrees)
[in]lat1Latitude of the first point (in degrees)
[in]long2Longitude of the second point (in degrees)
[in]lat2Latitude of the second point (in degrees)
[in]long3Longitude of the third point (in degrees)
[in]lat3Latitude of the third point (in degrees)
[out]aAngle (P2,O,P3)
[out]bAngle (P3,O,P1)
[out]cAngle (P1,O,P2)
[out]AAngle (P2,P1,P3)
[out]BAngle (P3,P2,P1)
[out]CAngle (P1,P3,P2)

◆ geodeticAngularDistance()

double GeometryHelper::geodeticAngularDistance ( double  long1,
double  lat1,
double  long2,
double  lat2,
double  radius = 1. 
)
static

Calculate the geodetic angular distance between two points on the sphere

Returns
Angular distance
Parameters
[in]long1Longitude of the first point (in degrees)
[in]lat1Latitude of the first point (in degrees)
[in]long2Longitude of the second point (in degrees)
[in]lat2Latitude of the second point (in degrees)
[in]radiusRadius of the sphere

◆ geodeticTrianglePerimeter()

double GeometryHelper::geodeticTrianglePerimeter ( double  long1,
double  lat1,
double  long2,
double  lat2,
double  long3,
double  lat3 
)
static

Calculate the perimeter of the spherical triangle

Returns
The Perimeter of the spherical triangle
Parameters
[in]long1Longitude of the first point (in degrees)
[in]lat1Latitude of the first point (in degrees)
[in]long2Longitude of the second point (in degrees)
[in]lat2Latitude of the second point (in degrees)
[in]long3Longitude of the third point (in degrees)
[in]lat3Latitude of the third point (in degrees)

◆ geodeticTriangleSurface()

double GeometryHelper::geodeticTriangleSurface ( double  long1,
double  lat1,
double  long2,
double  lat2,
double  long3,
double  lat3 
)
static

Calculate the surface of the spherical triangle

Returns
The Surface of the spherical triangle (with unit radius)
Parameters
[in]long1Longitude of the first point (in degrees)
[in]lat1Latitude of the first point (in degrees)
[in]long2Longitude of the second point (in degrees)
[in]lat2Latitude of the second point (in degrees)
[in]long3Longitude of the third point (in degrees)
[in]lat3Latitude of the third point (in degrees)

◆ getCosineAngularTolerance()

double GeometryHelper::getCosineAngularTolerance ( double  tolang)
static

Returns the cosine of the angular tolerance

Parameters
[in]tolangAngular tolerance

◆ getDirectionsInR3()

MatrixRectangular * GeometryHelper::getDirectionsInR3 ( const MatrixRectangular U)
static

◆ getDirectionsInRn()

MatrixRectangular * GeometryHelper::getDirectionsInRn ( const MatrixRectangular U)
static

Function to compute directions in Rd

Parameters
Ua matrix [n, d] of uniform values between [0,1]. 'n' is the number of direction and 'd' is the dimension of the space
Returns
A vector of a matrix [n, d] of the coordinates of the 'n' directions in the Euclidean space Rd.

◆ gradXYToRotmat()

MatrixSquareGeneral GeometryHelper::gradXYToRotmat ( double  dzoverdx,
double  dzoverdy 
)
static

Calculate the rotation matrix starting from the partial derivatives along X and Y of a tilted plane

Parameters
dzoverdxPartial derivative along X
dzoverdyPartial derivative along Y

◆ isInSphericalTriangle()

bool GeometryHelper::isInSphericalTriangle ( double *  coor,
double  surface,
double *  pts1,
double *  pts2,
double *  pts3,
double *  wgts,
double  eps = EPSILON6 
)
static

Is a point inside a spherical triangle

Returns
1 if the point belongs to the spherical triangle; 0 otherwise
Parameters
[in]coorCoordinates of the target point (long,lat)
[in]surfaceSurface of the spherical triangle
[in]pts1Coordinates of the first point of the triangle
[in]pts2Coordinates of the second point of the triangle
[in]pts3Coordinates of the third point of the triangle
[in]epsTolerance
[out]wgtsArray of weights

◆ isInSphericalTriangleOptimized()

bool GeometryHelper::isInSphericalTriangleOptimized ( const double *  coor,
double *  ptsa,
double *  ptsb,
double *  ptsc,
double *  wgts,
double  eps = EPSILON6 
)
static

Is a point inside a spherical triangle

Returns
True if the point belongs to the spherical triangle; False otherwise
Parameters
[in]coorCoordinates of the target point (long,lat)
[in]ptsaCoordinates of the first point of the triangle
[in]ptsbCoordinates of the second point of the triangle
[in]ptscCoordinates of the third point of the triangle
[in]epsTolerance
[out]wgtsArray of weights

◆ isSegmentIntersect()

bool GeometryHelper::isSegmentIntersect ( double  xd1,
double  yd1,
double  xe1,
double  ye1,
double  xd2,
double  yd2,
double  xe2,
double  ye2 
)
static

Check if two 2-D segments intersect

Returns
True if there is an intersection; False otherwise
Parameters
[in]xd1,yd1Starting point for the first segment
[in]xe1,ye1Ending point for the first segment
[in]xd2,yd2Starting point for the second segment
[in]xe2,ye2Ending point for the second segment

◆ mergeBoxes()

void GeometryHelper::mergeBoxes ( VectorDouble mini1,
VectorDouble maxi1,
VectorDouble mini2,
VectorDouble maxi2 
)
static

Merge the extensions of the boxes (parallel to main axes)

Parameters
[in]mini1Input array containing the minimum along each axis
[in]maxi1Input array containing the maximum along each axis
[in]mini2Output array containing the minimum along each axis
[in]maxi2Output array containing the maximum along each axis

◆ rayTriangleIntersect()

VectorDouble GeometryHelper::rayTriangleIntersect ( const VectorDouble dir,
const VectorDouble v0,
const VectorDouble v1,
const VectorDouble v2 
)
static

◆ rotation2DMatrixInPlace()

void GeometryHelper::rotation2DMatrixInPlace ( double  angle,
VectorDouble rot 
)
static

Calculates the 2-D rotation matrix

Parameters
[in]angleRotation angle (in degrees)
[out]rotRotation matrix (Dimension = 4)

◆ rotation3DMatrixInPlace()

void GeometryHelper::rotation3DMatrixInPlace ( double  alpha,
double  beta,
double  gamma,
VectorDouble rot 
)
static

Calculates the 3-D rotation matrix

Parameters
[in]alphaangle (in degrees) / oz
[in]betaangle (in degrees) / oy'
[in]gammaangle (in degrees) / ox''
[out]rotdirect rotation matrix (Dimension = 9)

◆ rotationCopy()

void GeometryHelper::rotationCopy ( int  ndim,
const double *  rotin,
double *  rotout 
)
static

Copy a rotation matrix

Parameters
[in]ndimSpace dimension
[in]rotinInput rotation matrix
[out]rotoutOutput rotation matrix (already allocated)

◆ rotationGetAngles()

VectorDouble GeometryHelper::rotationGetAngles ( const VectorDouble codir,
bool  flagResize = false 
)
static

From the vector of direction coefficients (codir) returns the vector of angles

Parameters
codirInput vector giving the direction coefficients
flagResizeWhen TRUE (and if in 2-D) the returned vector is resized to 1
Returns

◆ rotationGetAnglesFromCodirInPlace()

void GeometryHelper::rotationGetAnglesFromCodirInPlace ( const VectorDouble codir,
VectorDouble angles 
)
static

Calculates the rotation angle from the direction coefficient

Parameters
[in]codirDirection vector (Dimension = ndim)
[out]anglesRotation angles (Dimension = ndim)

◆ rotationGetAnglesInPlace() [1/2]

void GeometryHelper::rotationGetAnglesInPlace ( const VectorDouble rot,
VectorDouble angles 
)
static

◆ rotationGetAnglesInPlace() [2/2]

void GeometryHelper::rotationGetAnglesInPlace ( int  ndim,
const double *  rot,
double *  angles 
)
static

Calculates the rotation angles from the rotation matrix

Parameters
[in]ndimSpace dimension
[in]rotRotation matrix (Dimension = 9)
[out]anglesRotation angles (Dimension = ndim)

◆ rotationGetDirection2D()

void GeometryHelper::rotationGetDirection2D ( const VectorDouble angles,
VectorDouble codir 
)
static

Convert angles to a set of Directions

Parameters
[in]anglesVector giving the angles characteristics (in degrees) As this provides rotation in 2D, 'angles' is dimensioned to 'ndir' (one angle requires a single value)
[out]codirVector of the direction (Dim: ndir * ndim)
Remarks
'ndir' is given by the dimension of 'angles', 'ndim' is given by 'codir'

◆ rotationGetDirectionDefault()

void GeometryHelper::rotationGetDirectionDefault ( int  ndim,
VectorDouble codir 
)
static

Create a Direction (used as default)

Parameters
[in]ndimNumber of space dimensions
[out]codirVector of the direction (Dim: ndim)

◆ rotationGetRandomDirection()

void GeometryHelper::rotationGetRandomDirection ( double  ct,
double  st,
double *  a,
double *  codir 
)
static

Rotation of a Direction in 3-D

Parameters
[in]ct,stCosine and Sine of the rotation angle
[in]aRandom direction
[in,out]codirDirection to be rotated

◆ rotationGetSinCos()

void GeometryHelper::rotationGetSinCos ( double  angle,
double *  cosa,
double *  sina 
)
static

Calculates the trigonometric features

Parameters
[in]angleinput angle (in degrees)
[out]cosacosine function
[out]sinasine function

◆ rotationIsIdentity()

bool GeometryHelper::rotationIsIdentity ( int  ndim,
double *  rot,
double  eps = EPSILON10 
)
static

Starting from a rotation matrix, check it is different from the Identity

Returns
False if a rotation is defined; True if it is an Identity
Parameters
[in]ndimSpace dimension
[in]rotRotation matrix
[in]epsTolerance

◆ rotationMatrix()

VectorDouble GeometryHelper::rotationMatrix ( int  ndim,
const VectorDouble angles 
)
static

Calculates the rotation matrix. Returns the rotation matrix as a VectorDouble

Parameters
[in]ndimSpace dimension
[in]anglesArray of angles

◆ rotationMatrixIdentityInPlace()

void GeometryHelper::rotationMatrixIdentityInPlace ( int  ndim,
VectorDouble rot 
)
static

Initialize a rotation matrix

Parameters
[in]ndimSpace dimension
[out]rotRotation matrix

◆ rotationMatrixInPlace()

void GeometryHelper::rotationMatrixInPlace ( int  ndim,
const VectorDouble angles,
VectorDouble rot 
)
static

Calculates the rotation matrix

Parameters
[in]ndimSpace dimension
[in]anglesArray of angles
[out]rotdirect rotation matrix (dimensionned to ndim*ndim)

◆ rotationToEuler()

VectorDouble GeometryHelper::rotationToEuler ( const MatrixSquareGeneral M,
const ERotation &  convrot = ERotation::fromKey(                                          "SXYZ"),
double  eps = EPSILON10 
)
static

Returns the Euler angles, starting from a rotation matrix

Parameters
MInput matrix
convrotRotation convention
epsTolerance
Returns
Remarks
The code is coming from the following reference (BSD license)
https://github.com/matthew-brett/transforms3d/blob/master/transforms3d/euler.py

◆ segmentIntersect()

int GeometryHelper::segmentIntersect ( double  xd1,
double  yd1,
double  xe1,
double  ye1,
double  xd2,
double  yd2,
double  xe2,
double  ye2,
double *  xint,
double *  yint 
)
static

Calculate the intersection between two segments

Returns
0 there is an intersection; 1 if there is no intersection
Parameters
[in]xd1,yd1Starting point for the first segment
[in]xe1,ye1Ending point for the first segment
[in]xd2,yd2Starting point for the second segment
[in]xe2,ye2Ending point for the second segment
[out]xint,yintCoordinates of the intersection

◆ sphBarCoord()

VectorVectorDouble GeometryHelper::sphBarCoord ( const VectorVectorDouble sphPts,
const MatrixRectangular apices,
const MatrixInt meshes 
)
static

Calculate the Barycenter coordinates of points with in the Spherical Meshing

Parameters
sphPtsCoordinates of target samples (dim = np * 3)
apicesCoordinates of the apices of the Meshing
meshesMesh information of the Meshing
Returns
A vector of barycenters (dimension = 4 * np) where
  • 1: rank of the triangle
  • 2, 3, 4: barycentric coordinates

The documentation for this class was generated from the following files: