24 T
angle(
const T *vA0,
const T *vA1,
const T *vB0,
const T *vB1);
27 T
angle2D(
const T *vA0,
const T *vA1,
const T *vB0,
const T *vB1);
32 double angle = angle2D<T>(vA, vB, vA, vC);
54 std::array<T, 3> *coefficients =
nullptr,
55 const T *tolerance = NULL);
76 std::array<T, 2> &baryCentrics,
77 const int &dimension = 3);
93 std::array<T, 3> &baryCentrics);
107 template <
typename T>
124 template <
typename T>
128 std::array<T, 3> &angles);
136 template <
typename T>
148 template <
typename T>
157 template <
typename T>
168 template <
typename T>
180 template <
typename T>
188 template <
typename T>
189 T
distance(
const T *p0,
const T *p1,
const int &dimension = 3);
194 template <
typename T>
195 T
distance(
const std::vector<T> &p0,
const std::vector<T> &p1);
197 template <
typename T>
200 T di0 = (p0[0] - p1[0]);
201 T di1 = (p0[1] - p1[1]);
202 if(std::is_same<T, float>::value) {
217 template <
typename T>
219 const std::vector<std::vector<T>> &p1);
225 template <
typename T>
227 const std::vector<std::vector<T>> &p1);
235 template <
typename T>
236 T
dotProduct(
const T *vA0,
const T *vA1,
const T *vB0,
const T *vB1);
244 template <
typename T>
245 T
dotProduct(
const T *vA,
const T *vB,
const int &dimension = 3);
251 template <
typename T>
252 T
dotProduct(
const std::vector<T> &vA,
const std::vector<T> &vB);
258 template <
typename T>
260 const std::vector<std::vector<T>> &vB);
270 template <
typename T,
typename Container,
size_t dim>
272 std::array<std::pair<T, T>, dim> &bBox) {
277 for(
size_t i = 0; i < points.size(); i++) {
280 for(
size_t j = 0; j < dim; j++) {
281 bBox[j].first = points[i][j];
282 bBox[j].second = points[i][j];
285 for(
size_t j = 0; j < dim; j++) {
286 if(points[i][j] < bBox[j].first) {
287 bBox[j].first = points[i][j];
289 if(points[i][j] > bBox[j].second) {
290 bBox[j].second = points[i][j];
305 template <
typename T>
317 template <
typename T>
333 template <
typename T>
337 const int &dimension = 3);
345 template <
typename T>
349 const T *tolerance =
nullptr);
356 template <
typename T>
357 T
magnitude(
const T *v,
const int &dimension = 3);
362 template <
typename T>
369 template <
typename T>
375 template <
typename T>
380 template <
typename T>
381 inline T
powInt(
const T val,
const int n) {
383 return 1.0 /
powInt(val, -n);
391 return val * val * val;
394 for(
int i = 0; i < n - 1; ++i) {
402 template <
typename T =
double>
404 return powInt(
static_cast<T
>(10), n);
428#define TTK_POW_LAMBDA(CALLEXPR, TYPE, EXPN, ...) \
430 const auto one = [](const TYPE ttkNotUsed(a)) { return TYPE{1}; }; \
431 const auto id = [](const TYPE a) { return a; }; \
432 const auto square = [](const TYPE a) { return a * a; }; \
433 const auto cube = [](const TYPE a) { return a * a * a; }; \
435 = [EXPN](const TYPE a) { return Geometry::powInt(a, EXPN); }; \
438 CALLEXPR(__VA_ARGS__, one); \
439 } else if(EXPN == 1) { \
440 CALLEXPR(__VA_ARGS__, id); \
441 } else if(EXPN == 2) { \
442 CALLEXPR(__VA_ARGS__, square); \
443 } else if(EXPN == 3) { \
444 CALLEXPR(__VA_ARGS__, cube); \
446 CALLEXPR(__VA_ARGS__, powInt); \
453 template <
typename T1,
typename T2>
454 inline T1
pow(
const T1 val,
const T2 n) {
456 std::is_arithmetic<T1>::value && std::is_arithmetic<T2>::value,
457 "pow can only be applied on arithmetic values");
459 if(std::is_integral<T2>::value) {
461 }
else if(std::is_floating_point<T2>::value) {
462 return std::pow(val, n);
476 template <
typename T>
478 subtractVectors(
const T *a,
const T *b, T *out,
const int &dimension = 3);
485 template <
typename T>
487 const std::vector<T> &b,
488 std::vector<T> &out);
497 template <
typename T>
498 int addVectors(
const T *a,
const T *b, T *out,
const int &dimension = 3);
505 template <
typename T>
507 const std::vector<T> &b,
508 std::vector<T> &out);
514 template <
typename T>
516 const std::vector<std::vector<T>> &b,
517 std::vector<std::vector<T>> &out);
524 template <
typename T>
527 const std::vector<std::vector<std::vector<T>>> &b,
528 std::vector<std::vector<T>> &out);
537 template <
typename T>
539 scaleVector(
const T *a,
const T factor, T *out,
const int &dimension = 3);
546 template <
typename T>
548 scaleVector(
const std::vector<T> &a,
const T factor, std::vector<T> &out);
557 template <
typename T>
561 const int &dimension = 3);
568 template <
typename T>
570 const std::vector<T> &b,
571 std::vector<T> &out);
578 template <
typename T>
580 const std::vector<T> &b,
581 std::vector<T> &a_out,
582 std::vector<T> &b_out);
589 template <
typename T>
590 void gramSchmidt(
const std::vector<std::vector<T>> &a,
591 std::vector<std::vector<T>> &out);
596 template <
typename T>
602 template <
typename T>
609 template <
typename T>
617 template <
typename T>
619 std::vector<T> &out);
625 template <
typename T>
627 const std::vector<std::vector<std::vector<T>>> &a,
628 std::vector<std::vector<T>> &out);
637 template <
typename T>
639 std::vector<std::vector<T>> &out,
640 const int &no_columns = 2);
646 template <
typename T>
648 const std::vector<std::vector<T>> &b,
649 std::vector<std::vector<T>> &out);
656 template <
typename T>
658 const std::vector<std::vector<T>> &b,
659 std::vector<std::vector<T>> &out);
665 template <
typename T>
666 void addMatrices(
const std::vector<std::vector<T>> &a,
667 const std::vector<std::vector<T>> &b,
668 std::vector<std::vector<T>> &out);
674 template <
typename T>
675 void scaleMatrix(
const std::vector<std::vector<T>> &a,
677 std::vector<std::vector<T>> &out);
682 template <
typename T>
684 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)
double angle2DUndirected(const T *vA, const T *vB, const T *vC)
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)
bool isTriangleColinear2D(const T *pptA, const T *pptB, const T *pptC, const T tolerance)
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)
T distance2D(const T *p0, const T *p1)
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 angle2D(const T *vA0, const T *vA1, const T *vB0, const T *vB1)
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)