PointCloud2BIM Library
1.0
Library to facilitate the transpormation of point clouds into digital BIM representation
|
Set of functions supporting mathematic operations. More...
#include <algorithm>
#include <cmath>
#include <iostream>
#include "BoundingBox.h"
Functions | |
double | det2 (double a1, double b1, double c1, double d1) |
Calculates the determinant of the given 2x2 matrix. More... | |
double | det3 (double matrix[3][3]) |
Calculates the determinant of the given 3x3 matrix. More... | |
void | eig3 (double matrix[3][3], double lambda, double(&result)[3]) |
Calculates eigenvector of the given 3x3 matrix for the given eigenvalue. More... | |
void | cubicEq (double au, double bu, double cu, double du, double(&result)[3]) |
Calculates the solution of a cubic equation ( ![]() | |
template<typename T > | |
void | averageD (std::vector< T > &points, double(&v1)[3], double(&averageD)) |
Calculates the average coefficient d for the plane ( ![]() | |
template<typename T > | |
void | planeFromPoints (std::vector< T > &points, std::vector< int > &indexes, double(&v1)[3], double &averageD) |
Interpolates the plane through the given points. More... | |
template<typename T > | |
void | planeFromPoints (std::vector< T > &points, double(&v1)[3], double(&v2)[3], double(&v3)[3], double &averageD) |
Interpolates the plane through the given points. More... | |
double | angleBetweenPlanes (double a1, double b1, double c1, double a2, double b2, double c2) |
Calculates the angle between two planes ( ![]() | |
double | angleBetweenPlanes (double n1[3], double n2[3]) |
Calculates the angle between two planes given by normal vectors. More... | |
double | dot (double ax, double ay, double az, double bx, double by, double bz) |
Calculates the dot product of two vectors. More... | |
void | cross (double(&a)[3], double(&b)[3], double(&result)[3]) |
Calculates the cross product of two vectors. More... | |
void | normalize (double(&vec)[3]) |
Normalizes the given vector. More... | |
template<typename T > | |
void | rotatePointsToLocal (std::vector< T > &points, double(&locx)[3], double(&locy)[3]) |
Rotates points in the local coordinate system (z = 0). More... | |
template<typename T > | |
void | rotatePoint (T &pt, double(&v1)[3], double(&v2)[3], double(&v3)[3]) |
Rotates point in the local coordinate system given by its base vectors. More... | |
template<typename T > | |
void | rotatePoints (std::vector< T > &points, double(&v1)[3], double(&v2)[3], double(&v3)[3]) |
Rotates points in the local coordinate system given by its base vectors. More... | |
template<typename T > | |
void | moveCSorigin (std::vector< T > &points, T O) |
Recalculates the coordinates of the points when the new origin of the coordinate system is set. More... | |
template<typename T > | |
void | moveBackCSorigin (std::vector< T > &points, T O) |
Recalculates the coordinates of the points when the origin of the coordinate system is reset from the given O to (0, 0, 0). More... | |
template<typename T > | |
void | giveLocalCS (std::vector< T > &points, double(&locx)[3], double(&locy)[3], double(&locz)[3]) |
Calculates local coordinate system of the plane defined by the given points. More... | |
void | giveLtoGVectorsFromLocalCS (double(&locx)[3], double(&locy)[3], double(&locz)[3], double(&l2g1)[3], double(&l2g2)[3], double(&l2g3)[3]) |
Calculates the global-to-local (G2L) transformation vectors to local-to-global (L2G) transformation vectors. More... | |
template<typename T > | |
double | giveAverageCoord (std::vector< T > &points, int cIndex) |
Calculates the average coordinate of the given points. More... | |
template<typename T > | |
void | projectPointsToXYPlane (std::vector< T > &points) |
Sets the z-coordinate of the given points to the zero. More... | |
Set of functions supporting mathematic operations.
double angleBetweenPlanes | ( | double | a1, |
double | b1, | ||
double | c1, | ||
double | a2, | ||
double | b2, | ||
double | c2 | ||
) |
Calculates the angle between two planes ( ).
a1 | Coefficient a of the first plane |
b1 | Coefficient b of the first plane |
c1 | Coefficient c of the first plane |
a1 | Coefficient a of the second plane |
b1 | Coefficient b of the second plane |
c1 | Coefficient c of the second plane |
double angleBetweenPlanes | ( | double | n1[3], |
double | n2[3] | ||
) |
Calculates the angle between two planes given by normal vectors.
n1 | Normal vector of the first plane |
n2 | Normal vector of the second plane |
void averageD | ( | std::vector< T > & | points, |
double(&) | v1[3], | ||
double & | averageD | ||
) |
Calculates the average coefficient d for the plane ( ) given by normal vector and interpolated through the given points.
points | Plane points |
v1 | Plane normal vector |
averageD | Return parameter storing the calculated coefficient |
void cross | ( | double(&) | a[3], |
double(&) | b[3], | ||
double(&) | result[3] | ||
) |
Calculates the cross product of two vectors.
a | The first vector |
b | The second vector |
result | Return parameter storing the resulting cross product |
void cubicEq | ( | double | au, |
double | bu, | ||
double | cu, | ||
double | du, | ||
double(&) | result[3] | ||
) |
Calculates the solution of a cubic equation ( ).
au | Coefficient a |
bu | Coefficient b |
cu | Coefficient c |
du | Coefficient d |
result | Return parameter storing the calculated solution |
double det2 | ( | double | a1, |
double | b1, | ||
double | c1, | ||
double | d1 | ||
) |
Calculates the determinant of the given 2x2 matrix.
a1 | Matrix element (1,1) |
b1 | Matrix element (1,2) |
c1 | Matrix element (2,1) |
d1 | Matrix element (2,2) |
double det3 | ( | double | matrix[3][3] | ) |
Calculates the determinant of the given 3x3 matrix.
matrix | 3x3 matrix |
double dot | ( | double | ax, |
double | ay, | ||
double | az, | ||
double | bx, | ||
double | by, | ||
double | bz | ||
) |
Calculates the dot product of two vectors.
ax | X component of the first vector |
ay | Y component of the first vector |
az | Z component of the first vector |
bx | X component of the second vector |
by | Y component of the second vector |
bz | Z component of the second vector |
void eig3 | ( | double | matrix[3][3], |
double | lambda, | ||
double(&) | result[3] | ||
) |
Calculates eigenvector of the given 3x3 matrix for the given eigenvalue.
matrix | 3x3 matrix |
lambda | Eigenvalue |
result | Return parameter storing the calculated eigenvector |
double giveAverageCoord | ( | std::vector< T > & | points, |
int | cIndex | ||
) |
Calculates the average coordinate of the given points.
points | The points for calculation of the average coordinate |
index | Index specifying which coordinate to calculate (0~x, 1~y, 2~z) |
void giveLocalCS | ( | std::vector< T > & | points, |
double(&) | locx[3], | ||
double(&) | locy[3], | ||
double(&) | locz[3] | ||
) |
Calculates local coordinate system of the plane defined by the given points.
points | Points defining the plane for which to calculate the local coordinate system |
locx | Return parameter storing local x-axis (in plane, horizontal) |
locy | Return parameter storing local y-axis (in plane, vertical) |
locz | Return parameter storing local z-axis (normal vector) |
void giveLtoGVectorsFromLocalCS | ( | double(&) | locx[3], |
double(&) | locy[3], | ||
double(&) | locz[3], | ||
double(&) | l2g1[3], | ||
double(&) | l2g2[3], | ||
double(&) | l2g3[3] | ||
) |
Calculates the global-to-local (G2L) transformation vectors to local-to-global (L2G) transformation vectors.
locx | The first G2L transformation vector |
locy | The second G2L transformation vector |
locz | The third G2L transformation vector |
l2g1 | In-out parameter storing the first L2G transformation vector ![]() |
l2g1 | In-out parameter storing the second L2G transformation vector ![]() |
l2g1 | In-out parameter storing the third L2G transformation vector ![]() |
void moveBackCSorigin | ( | std::vector< T > & | points, |
T | O | ||
) |
Recalculates the coordinates of the points when the origin of the coordinate system is reset from the given O to (0, 0, 0).
pt | In-Out parameter storing the points to be transformed |
O | Actual origin coordinates |
void moveCSorigin | ( | std::vector< T > & | points, |
T | O | ||
) |
Recalculates the coordinates of the points when the new origin of the coordinate system is set.
pt | In-Out parameter storing the points to be transformed |
O | New origin coordinates |
void normalize | ( | double(&) | vec[3] | ) |
Normalizes the given vector.
vec | In-Out parameter storing the vector to be normalized |
void planeFromPoints | ( | std::vector< T > & | points, |
std::vector< int > & | indexes, | ||
double(&) | v1[3], | ||
double & | averageD | ||
) |
Interpolates the plane through the given points.
points | Points for the calculation |
indexes | Indexes specifying which points to use for the plane calculation |
v1 | Return parametr storing the normal vector of the plane |
averageD | Coefficient d of the plane equation ( ![]() |
void planeFromPoints | ( | std::vector< T > & | points, |
double(&) | v1[3], | ||
double(&) | v2[3], | ||
double(&) | v3[3], | ||
double & | averageD | ||
) |
Interpolates the plane through the given points.
points | Points through which to interpolate the plane |
v1 | Return parametr storing the normal vector of the plane |
v2 | Return parametr storing the first in-plane vector |
v3 | Return parametr storing the second in-plane vector |
averageD | Coefficient d of the plane equation ( ![]() |
void projectPointsToXYPlane | ( | std::vector< T > & | points | ) |
Sets the z-coordinate of the given points to the zero.
points | In-Out parameter storing the points to be projected |
void rotatePoint | ( | T & | pt, |
double(&) | v1[3], | ||
double(&) | v2[3], | ||
double(&) | v3[3] | ||
) |
Rotates point in the local coordinate system given by its base vectors.
pt | In-Out parameter storing the point to be rotated |
v1 | The first base vector of the local coordinate system |
v2 | The second base vector of the local coordinate system |
v3 | The third base vector of the local coordinate system |
void rotatePoints | ( | std::vector< T > & | points, |
double(&) | v1[3], | ||
double(&) | v2[3], | ||
double(&) | v3[3] | ||
) |
Rotates points in the local coordinate system given by its base vectors.
pt | In-Out parameter storing the points to be rotated |
v1 | The first base vector of the local coordinate system |
v2 | The second base vector of the local coordinate system |
v3 | The third base vector of the local coordinate system |
void rotatePointsToLocal | ( | std::vector< T > & | points, |
double(&) | locx[3], | ||
double(&) | locy[3] | ||
) |
Rotates points in the local coordinate system (z = 0).
points | In-Out parameter storing the points to be rotated |
locx | Local x vector |
locy | Local y vector |