Visual Computing Library  devel
Loading...
Searching...
No Matches
Core Algorithms

List of Core algorithms. More...

Collaboration diagram for Core Algorithms:

Modules

 Core Bounding Box Algorithms
 List of overloaded boundingBox functions that take in input an object (or a Range of objects) and return its/their bounding box.
 
 Core Box Algorithms
 List of utility functions for boxes having different dimensions.
 
 Core Create Algorithms
 List core algorithms for creating generic objects.
 
 Core Distance Algorithms
 List of distance algorithms.
 
 Core Intersection Algorithms
 List of intersection algorithms.
 
 Polygon Core Algorithms
 List of Core Polygon algorithms.
 

Functions

template<Point3Concept PointType>
bool vcl::arePointsCoplanar (const PointType &p0, const PointType &p1, const PointType &p2, const PointType &p3)
 Checks if 4 points are coplanar.
 
template<FaceConcept FaceType, Point3Concept PointType>
bool vcl::facePointVisibility (const FaceType &face, const PointType &point)
 Checks if a point is visible from a face, i.e., if the point is in the half-space defined by the face.
 
template<FaceConcept FaceType, Point3Concept PointType>
auto vcl::halfSpaceDeterminant (const FaceType &face, const PointType &point)
 Compute the determinant of the half-space defined by the triangle and the point.
 
template<Point3Concept PointType>
auto vcl::halfSpaceDeterminant (const PointType &p0, const PointType &p1, const PointType &p2, const PointType &p)
 Compute the determinant of the half-space defined by the triangle (p1, p2, p3) and the point p.
 
template<Triangle3Concept TriangleType, Point3Concept PointType>
auto vcl::halfSpaceDeterminant (const TriangleType &triangle, const PointType &point)
 Compute the determinant of the half-space defined by the triangle and the point.
 
int vcl::poissonRandomNumber (double lambda, std::mt19937 &gen)
 algorithm poisson random number (Knuth): init: Let L ← e^−λ, k ← 0 and p ← 1. do: k ← k + 1. Generate uniform random number u in [0,1] and let p ← p × u. while p > L. return k − 1.
 
template<Point3Concept PointType>
PointType vcl::randomTriangleBarycentricCoordinate (std::mt19937 &gen)
 Generate the barycentric coords of a random point over a triangle, with a uniform distribution over the triangle. It uses the parallelogram folding trick.
 
template<Matrix33Or44Concept MatrixType>
MatrixType vcl::removeScalingFromMatrix (const MatrixType &matrix)
 Returns a matrix with the scaling factors removed.
 
template<Matrix33Or44Concept MatrixType>
void vcl::removeScalingFromMatrixInPlace (MatrixType &matrix)
 Removes the scaling factors from the matrix in place.
 
template<MatrixConcept MatrixType, Point3Concept PointType, typename ScalarType >
MatrixType vcl::rotationMatrix (const PointType &axis, const ScalarType &angleRad)
 Given an 3D axis and an angle expressed in radiants, returns a transform matrix that represents the rotation matrix of the given axis/angle.
 
template<MatrixConcept MatrixType, Point3Concept PointType>
MatrixType vcl::rotationMatrix (const PointType &fromVector, const PointType &toVector)
 Given two 3D vectors, returns a transform matrix that represents the rotation matrix from the first vector to the second vector.
 
template<MatrixConcept MatrixType, Point3Concept PointType, typename ScalarType >
MatrixType vcl::rotationMatrixDeg (const PointType &axis, const ScalarType &angleDeg)
 Given an 3D axis and an angle expressed in degrees, fills the given matrix with a transform matrix that represents the rotation matrix of the given axis/angle.
 
template<MatrixConcept MatrixType, Point3Concept PointType>
void vcl::setTransformMatrixRotation (MatrixType &matrix, const PointType &fromVector, const PointType &toVector)
 Given two 3D vectors, fills the given matrix with a transform matrix that represents the rotation matrix from the first vector to the second vector.
 
template<MatrixConcept MatrixType, Point3Concept PointType, typename ScalarType >
void vcl::setTransformMatrixRotation (MatrixType &matrix, PointType axis, const ScalarType &angleRad)
 Given an 3D axis and an angle expressed in radiants, fills the given matrix with a transform matrix that represents the rotation matrix of the given axis/angle.
 
template<MatrixConcept MatrixType, Point3Concept PointType, typename ScalarType >
void vcl::setTransformMatrixRotationDeg (MatrixType &matrix, PointType axis, const ScalarType &angleDeg)
 Given an 3D axis and an angle expressed in degrees, fills the given matrix with a transform matrix that represents the rotation matrix of the given axis/angle.
 
template<Point3Concept PointType>
std::vector< PointType > vcl::sphericalFibonacciPointSet (uint n)
 Returns a vector of n points distributed in a unit sphere.
 
template<Point3Concept PointType>
auto vcl::trianglePointVisibility (const PointType &p0, const PointType &p1, const PointType &p2, const PointType &p)
 Checks if a point is visible from a triangle, i.e., if the point is in the half-space defined by the triangle.
 
template<Triangle3Concept TriangleType, Point3Concept PointType>
bool vcl::trianglePointVisibility (const TriangleType &triangle, const PointType &point)
 Checks if a point is visible from a triangle, i.e., if the point is in the half-space defined by the triangle.
 

Detailed Description

List of Core algorithms.

In this module, you can find the core algorithms of VCLib, that generally involve simple geometric primitives, like points, vectors, and matrices.

You can access these algorithms by including #include <vclib/algorithms/core.h>

Function Documentation

◆ arePointsCoplanar()

template<Point3Concept PointType>
bool vcl::arePointsCoplanar ( const PointType &  p0,
const PointType &  p1,
const PointType &  p2,
const PointType &  p3 
)

Checks if 4 points are coplanar.

Template Parameters
PointTypeThe type of the points.
Parameters
[in]p0First point to test.
[in]p1Second point to test.
[in]p2Third point to test.
[in]p3Fourth point to test.
Returns
True if the points are coplanar, false otherwise.

◆ facePointVisibility()

template<FaceConcept FaceType, Point3Concept PointType>
bool vcl::facePointVisibility ( const FaceType &  face,
const PointType &  point 
)

Checks if a point is visible from a face, i.e., if the point is in the half-space defined by the face.

Template Parameters
FaceTypeThe type of the face.
PointTypeThe type of the point.
Parameters
[in]faceThe input face.
[in]pointThe point to test.
Returns
true if the point is visible from the face, false otherwise.

◆ halfSpaceDeterminant() [1/3]

template<FaceConcept FaceType, Point3Concept PointType>
auto vcl::halfSpaceDeterminant ( const FaceType &  face,
const PointType &  point 
)

Compute the determinant of the half-space defined by the triangle and the point.

Template Parameters
FaceTypeThe type of the face that defines the half-space.
PointTypeThe type of the point to test.
Parameters
[in]faceThe face that defines the half-space.
[in]pointThe point to test.
Returns
The determinant of the half-space.

◆ halfSpaceDeterminant() [2/3]

template<Point3Concept PointType>
auto vcl::halfSpaceDeterminant ( const PointType &  p0,
const PointType &  p1,
const PointType &  p2,
const PointType &  p 
)

Compute the determinant of the half-space defined by the triangle (p1, p2, p3) and the point p.

The triangle is defined by the points p1, p2, and p3, ordered in a counter-clockwise manner.

Template Parameters
PointTypeThe type of the points.
Parameters
[in]p0The first point of the triangle.
[in]p1The second point of the triangle.
[in]p2The third point of the triangle.
[in]pThe point to test.
Returns
The determinant of the half-space.

◆ halfSpaceDeterminant() [3/3]

template<Triangle3Concept TriangleType, Point3Concept PointType>
auto vcl::halfSpaceDeterminant ( const TriangleType triangle,
const PointType &  point 
)

Compute the determinant of the half-space defined by the triangle and the point.

Template Parameters
TriangleTypeThe type of the triangle that defines the half-space.
PointTypeThe type of the point to test.
Parameters
[in]triangleThe triangle that defines the half-space.
[in]pThe point to test.
Returns
The determinant of the half-space.

◆ poissonRandomNumber()

int vcl::poissonRandomNumber ( double  lambda,
std::mt19937 &  gen 
)
inline

algorithm poisson random number (Knuth): init: Let L ← e^−λ, k ← 0 and p ← 1. do: k ← k + 1. Generate uniform random number u in [0,1] and let p ← p × u. while p > L. return k − 1.

Parameters
lambda
gen
Returns

◆ randomTriangleBarycentricCoordinate()

template<Point3Concept PointType>
PointType vcl::randomTriangleBarycentricCoordinate ( std::mt19937 &  gen)

Generate the barycentric coords of a random point over a triangle, with a uniform distribution over the triangle. It uses the parallelogram folding trick.

Parameters
gen
Returns

◆ removeScalingFromMatrix()

template<Matrix33Or44Concept MatrixType>
MatrixType vcl::removeScalingFromMatrix ( const MatrixType &  matrix)

Returns a matrix with the scaling factors removed.

The input matrix is expected to be a 3x3 or 4x4 matrix, and the function removes the scaling factors from the first three rows (or columns) of the matrix. The scaling factors are computed as the Euclidean norm of the first three rows of the matrix. The resulting matrix will have the same orientation as the input matrix, but without scaling.

Parameters
[in]matrixThe input matrix from which the scaling factors will be removed.
Returns
A matrix of the same type as the input matrix, but with the scaling factors removed.

◆ removeScalingFromMatrixInPlace()

template<Matrix33Or44Concept MatrixType>
void vcl::removeScalingFromMatrixInPlace ( MatrixType &  matrix)

Removes the scaling factors from the matrix in place.

The input matrix is expected to be a 3x3 or 4x4 matrix, and the function removes the scaling factors from the first three rows (or columns) of the matrix. The scaling factors are computed as the Euclidean norm of the first three rows of the matrix. The resulting matrix will have the same orientation as the input matrix, but without scaling.

Parameters
[in/out]matrix: The input matrix from which the scaling factors will be removed.

◆ rotationMatrix() [1/2]

template<MatrixConcept MatrixType, Point3Concept PointType, typename ScalarType >
MatrixType vcl::rotationMatrix ( const PointType &  axis,
const ScalarType &  angleRad 
)

Given an 3D axis and an angle expressed in radiants, returns a transform matrix that represents the rotation matrix of the given axis/angle.

The MatrixType must be at least a 3x3 matrix having the setIdentity() member function. If the matrix is a higher than 3x3 (e.g. 4x4), only the 3x3 submatrix will be set, leaving the identity values in the other cells of the matrix.

Parameters
axis
angleRad
Returns

◆ rotationMatrix() [2/2]

template<MatrixConcept MatrixType, Point3Concept PointType>
MatrixType vcl::rotationMatrix ( const PointType &  fromVector,
const PointType &  toVector 
)

Given two 3D vectors, returns a transform matrix that represents the rotation matrix from the first vector to the second vector.

The MatrixType must be at least a 3x3 matrix having the setIdentity() member function. If the matrix is a higher than 3x3 (e.g. 4x4), only the 3x3 submatrix will be set, leaving the identity values in the other cells of the matrix.

Parameters
fromVector
toVector
Returns

◆ rotationMatrixDeg()

template<MatrixConcept MatrixType, Point3Concept PointType, typename ScalarType >
MatrixType vcl::rotationMatrixDeg ( const PointType &  axis,
const ScalarType &  angleDeg 
)

Given an 3D axis and an angle expressed in degrees, fills the given matrix with a transform matrix that represents the rotation matrix of the given axis/angle.

The MatrixType must be at least a 3x3 matrix having the setIdentity() member function. If the matrix is a higher than 3x3 (e.g. 4x4), only the 3x3 submatrix will be set, leaving the identity values in the other cells of the matrix.

Parameters
axis
angleDeg
Returns

◆ setTransformMatrixRotation() [1/2]

template<MatrixConcept MatrixType, Point3Concept PointType>
void vcl::setTransformMatrixRotation ( MatrixType &  matrix,
const PointType &  fromVector,
const PointType &  toVector 
)

Given two 3D vectors, fills the given matrix with a transform matrix that represents the rotation matrix from the first vector to the second vector.

The given matrix must be at least a 3x3 matrix. If the matrix is a higher than 3x3 (e.g. 4x4), only the 3x3 submatrix will be set, leaving unchanged the other values.

Parameters
matrix
fromVector
toVector

◆ setTransformMatrixRotation() [2/2]

template<MatrixConcept MatrixType, Point3Concept PointType, typename ScalarType >
void vcl::setTransformMatrixRotation ( MatrixType &  matrix,
PointType  axis,
const ScalarType &  angleRad 
)

Given an 3D axis and an angle expressed in radiants, fills the given matrix with a transform matrix that represents the rotation matrix of the given axis/angle.

The given matrix must be at least a 3x3 matrix. If the matrix is a higher than 3x3 (e.g. 4x4), only the 3x3 submatrix will be set, leaving unchanged the other values.

Parameters
matrix
axis
angleRad

◆ setTransformMatrixRotationDeg()

template<MatrixConcept MatrixType, Point3Concept PointType, typename ScalarType >
void vcl::setTransformMatrixRotationDeg ( MatrixType &  matrix,
PointType  axis,
const ScalarType &  angleDeg 
)

Given an 3D axis and an angle expressed in degrees, fills the given matrix with a transform matrix that represents the rotation matrix of the given axis/angle.

The given matrix must be at least a 3x3 matrix. If the matrix is a higher than 3x3 (e.g. 4x4), only the 3x3 submatrix will be set, leaving unchanged the other values.

Parameters
matrix
axis
angleDeg

◆ sphericalFibonacciPointSet()

template<Point3Concept PointType>
std::vector< PointType > vcl::sphericalFibonacciPointSet ( uint  n)

Returns a vector of n points distributed in a unit sphere.

This function returns a vector of n points that are uniformly distributed on a unit sphere, using the Spherical Fibonacci Point Sets algorithm described in the paper "Spherical Fibonacci Mapping" by Benjamin Keinert, Matthias Innmann, Michael Sanger, and Marc Stamminger (TOG 2015).

Template Parameters
PointTypeThe type of the point to generate. This type must satisfy the Point3Concept concept.
Parameters
[in]nThe number of points to generate.
Returns
A vector of n points distributed in a unit sphere.

◆ trianglePointVisibility() [1/2]

template<Point3Concept PointType>
auto vcl::trianglePointVisibility ( const PointType &  p0,
const PointType &  p1,
const PointType &  p2,
const PointType &  p 
)

Checks if a point is visible from a triangle, i.e., if the point is in the half-space defined by the triangle.

Template Parameters
PointTypeThe type of the points.
Parameters
[in]p0The first point of the triangle.
[in]p1The second point of the triangle.
[in]p2The third point of the triangle.
[in]pThe point to test.
Returns
true if the point is visible from the triangle, false otherwise.

◆ trianglePointVisibility() [2/2]

template<Triangle3Concept TriangleType, Point3Concept PointType>
bool vcl::trianglePointVisibility ( const TriangleType triangle,
const PointType &  point 
)

Checks if a point is visible from a triangle, i.e., if the point is in the half-space defined by the triangle.

Template Parameters
TriangleTypeThe type of the triangle.
PointTypeThe type of the point.
Parameters
[in]triangleThe input triangle.
[in]pointThe point to test.
Returns
true if the point is visible from the triangle, false otherwise.