23 T
angle(
const T *vA0,
const T *vA1,
const T *vB0,
const T *vB1);
40 std::array<T, 3> *coefficients =
nullptr,
41 const T *tolerance = NULL);
57 std::array<T, 2> &baryCentrics,
58 const int &dimension = 3);
74 std::array<T, 3> &baryCentrics);
105 template <
typename T>
109 std::array<T, 3> &angles);
117 template <
typename T>
129 template <
typename T>
138 template <
typename T>
149 template <
typename T>
161 template <
typename T>
169 template <
typename T>
170 T
distance(
const T *p0,
const T *p1,
const int &dimension = 3);
175 template <
typename T>
176 T
distance(
const std::vector<T> &p0,
const std::vector<T> &p1);
182 template <
typename T>
184 const std::vector<std::vector<T>> &p1);
192 template <
typename T>
193 T
dotProduct(
const T *vA0,
const T *vA1,
const T *vB0,
const T *vB1);
201 template <
typename T>
202 T
dotProduct(
const T *vA,
const T *vB,
const int &dimension = 3);
208 template <
typename T>
209 T
dotProduct(
const std::vector<T> &vA,
const std::vector<T> &vB);
215 template <
typename T>
217 const std::vector<std::vector<T>> &vB);
227 template <
typename T,
typename Container,
size_t dim>
229 std::array<std::pair<T, T>, dim> &bBox) {
234 for(
size_t i = 0; i < points.size(); i++) {
237 for(
size_t j = 0; j < dim; j++) {
238 bBox[j].first = points[i][j];
239 bBox[j].second = points[i][j];
242 for(
size_t j = 0; j < dim; j++) {
243 if(points[i][j] < bBox[j].first) {
244 bBox[j].first = points[i][j];
246 if(points[i][j] > bBox[j].second) {
247 bBox[j].second = points[i][j];
262 template <
typename T>
274 template <
typename T>
290 template <
typename T>
294 const int &dimension = 3);
302 template <
typename T>
306 const T *tolerance =
nullptr);
313 template <
typename T>
314 T
magnitude(
const T *v,
const int &dimension = 3);
319 template <
typename T>
326 template <
typename T>
332 template <
typename T>
337 template <
typename T>
338 inline T
powInt(
const T val,
const int n) {
340 return 1.0 /
powInt(val, -n);
348 return val * val * val;
351 for(
int i = 0; i < n - 1; ++i) {
359 template <
typename T =
double>
361 return powInt(
static_cast<T
>(10), n);
385#define TTK_POW_LAMBDA(CALLEXPR, TYPE, EXPN, ...) \
387 const auto one = [](const TYPE ttkNotUsed(a)) { return TYPE{1}; }; \
388 const auto id = [](const TYPE a) { return a; }; \
389 const auto square = [](const TYPE a) { return a * a; }; \
390 const auto cube = [](const TYPE a) { return a * a * a; }; \
392 = [EXPN](const TYPE a) { return Geometry::powInt(a, EXPN); }; \
395 CALLEXPR(__VA_ARGS__, one); \
396 } else if(EXPN == 1) { \
397 CALLEXPR(__VA_ARGS__, id); \
398 } else if(EXPN == 2) { \
399 CALLEXPR(__VA_ARGS__, square); \
400 } else if(EXPN == 3) { \
401 CALLEXPR(__VA_ARGS__, cube); \
403 CALLEXPR(__VA_ARGS__, powInt); \
410 template <
typename T1,
typename T2>
411 inline T1
pow(
const T1 val,
const T2 n) {
413 std::is_arithmetic<T1>::value && std::is_arithmetic<T2>::value,
414 "pow can only be applied on arithmetic values");
416 if(std::is_integral<T2>::value) {
418 }
else if(std::is_floating_point<T2>::value) {
419 return std::pow(val, n);
433 template <
typename T>
435 subtractVectors(
const T *a,
const T *b, T *out,
const int &dimension = 3);
442 template <
typename T>
444 const std::vector<T> &b,
445 std::vector<T> &out);
454 template <
typename T>
455 int addVectors(
const T *a,
const T *b, T *out,
const int &dimension = 3);
462 template <
typename T>
464 const std::vector<T> &b,
465 std::vector<T> &out);
471 template <
typename T>
473 const std::vector<std::vector<T>> &b,
474 std::vector<std::vector<T>> &out);
481 template <
typename T>
484 const std::vector<std::vector<std::vector<T>>> &b,
485 std::vector<std::vector<T>> &out);
494 template <
typename T>
496 scaleVector(
const T *a,
const T factor, T *out,
const int &dimension = 3);
503 template <
typename T>
505 scaleVector(
const std::vector<T> &a,
const T factor, std::vector<T> &out);
514 template <
typename T>
518 const int &dimension = 3);
525 template <
typename T>
527 const std::vector<T> &b,
528 std::vector<T> &out);
535 template <
typename T>
537 const std::vector<T> &b,
538 std::vector<T> &a_out,
539 std::vector<T> &b_out);
546 template <
typename T>
547 void gramSchmidt(
const std::vector<std::vector<T>> &a,
548 std::vector<std::vector<T>> &out);
553 template <
typename T>
559 template <
typename T>
566 template <
typename T>
574 template <
typename T>
576 std::vector<T> &out);
582 template <
typename T>
584 const std::vector<std::vector<std::vector<T>>> &a,
585 std::vector<std::vector<T>> &out);
594 template <
typename T>
596 std::vector<std::vector<T>> &out,
597 const int &no_columns = 2);
603 template <
typename T>
605 const std::vector<std::vector<T>> &b,
606 std::vector<std::vector<T>> &out);
613 template <
typename T>
615 const std::vector<std::vector<T>> &b,
616 std::vector<std::vector<T>> &out);
622 template <
typename T>
623 void addMatrices(
const std::vector<std::vector<T>> &a,
624 const std::vector<std::vector<T>> &b,
625 std::vector<std::vector<T>> &out);
631 template <
typename T>
632 void scaleMatrix(
const std::vector<std::vector<T>> &a,
634 std::vector<std::vector<T>> &out);
639 template <
typename T>
641 std::vector<std::vector<T>> &out);
int scaleVector(const T *a, const T factor, T *out, const int &dimension=3)
bool areVectorsColinear(const T *vA0, const T *vA1, const T *vB0, const T *vB1, std::array< T, 3 > *coefficients=nullptr, const T *tolerance=NULL)
int computeTriangleArea(const T *p0, const T *p1, const T *p2, T &area)
int addVectors(const T *a, const T *b, T *out, const int &dimension=3)
T dotProductFlatten(const std::vector< std::vector< T > > &vA, const std::vector< std::vector< T > > &vB)
int multiFlattenMultiDimensionalVector(const std::vector< std::vector< std::vector< T > > > &a, std::vector< std::vector< T > > &out)
void subtractMatrices(const std::vector< std::vector< T > > &a, const std::vector< std::vector< T > > &b, std::vector< std::vector< T > > &out)
T dotProduct(const T *vA0, const T *vA1, const T *vB0, const T *vB1)
void matrixMultiplication(const std::vector< std::vector< T > > &a, const std::vector< std::vector< T > > &b, std::vector< std::vector< T > > &out)
bool isVectorNullFlatten(const std::vector< std::vector< T > > &a)
bool isPointOnSegment(const T &x, const T &y, const T &xA, const T &yA, const T &xB, const T &yB)
bool computeSegmentIntersection(const T &xA, const T &yA, const T &xB, const T &yB, const T &xC, const T &yC, const T &xD, const T &yD, T &x, T &y)
int computeBarycentricCoordinates(const T *p0, const T *p1, const T *p, std::array< T, 2 > &baryCentrics, const int &dimension=3)
void addMatrices(const std::vector< std::vector< T > > &a, const std::vector< std::vector< T > > &b, std::vector< std::vector< T > > &out)
void gramSchmidt(const std::vector< std::vector< T > > &a, std::vector< std::vector< T > > &out)
void scaleMatrix(const std::vector< std::vector< T > > &a, const T factor, std::vector< std::vector< T > > &out)
int multiAddVectors(const std::vector< std::vector< T > > &a, const std::vector< std::vector< T > > &b, std::vector< std::vector< T > > &out)
int flattenMultiDimensionalVector(const std::vector< std::vector< T > > &a, std::vector< T > &out)
bool isVectorUniform(const std::vector< T > &a)
int subtractVectors(const T *a, const T *b, T *out, const int &dimension=3)
int computeTriangleAreaFromSides(const T s0, const T s1, const T s2, T &area)
T magnitudeFlatten(const std::vector< std::vector< T > > &v)
bool isVectorNull(const std::vector< T > &a)
T1 pow(const T1 val, const T2 n)
bool isTriangleColinear(const T *p0, const T *p1, const T *p2, const T *tolerance=nullptr)
int getBoundingBox(const Container &points, std::array< std::pair< T, T >, dim > &bBox)
T angle(const T *vA0, const T *vA1, const T *vB0, const T *vB1)
void addVectorsProjection(const std::vector< T > &a, const std::vector< T > &b, std::vector< T > &a_out, std::vector< T > &b_out)
T powIntTen(const int n)
Compute the nth power of ten.
T powInt(const T val, const int n)
int computeTriangleAngles(const T *p0, const T *p1, const T *p2, std::array< T, 3 > &angles)
int computeTriangleAngleFromSides(const T s0, const T s1, const T s2, T &angle)
int vectorProjection(const T *a, const T *b, T *out, const int &dimension=3)
int crossProduct(const T *vA0, const T *vA1, const T *vB0, const T *vB1, std::array< T, 3 > &crossProduct)
void transposeMatrix(const std::vector< std::vector< T > > &a, std::vector< std::vector< T > > &out)
int unflattenMultiDimensionalVector(const std::vector< T > &a, std::vector< std::vector< T > > &out, const int &no_columns=2)
T magnitude(const T *v, const int &dimension=3)
T distance(const T *p0, const T *p1, const int &dimension=3)
T distanceFlatten(const std::vector< std::vector< T > > &p0, const std::vector< std::vector< T > > &p1)
int multiAddVectorsFlatten(const std::vector< std::vector< std::vector< T > > > &a, const std::vector< std::vector< std::vector< T > > > &b, std::vector< std::vector< T > > &out)
bool isPointInTriangle(const T *p0, const T *p1, const T *p2, const T *p)