VTK  9.3.1
vtkMath.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2011 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
33 #ifndef vtkMath_h
34 #define vtkMath_h
35 
36 #include "vtkCommonCoreModule.h" // For export macro
37 #include "vtkMathPrivate.hxx" // For Matrix meta-class helpers
38 #include "vtkMatrixUtilities.h" // For Matrix wrapping / mapping
39 #include "vtkObject.h"
40 #include "vtkSmartPointer.h" // For vtkSmartPointer.
41 #include "vtkTypeTraits.h" // For type traits
42 
43 #include "vtkMathConfigure.h" // For <cmath> and VTK_HAS_ISNAN etc.
44 
45 #include <algorithm> // for std::clamp
46 #include <cassert> // assert() in inline implementations.
47 #include <type_traits> // for type_traits
48 
49 #ifndef DBL_MIN
50 #define VTK_DBL_MIN 2.2250738585072014e-308
51 #else // DBL_MIN
52 #define VTK_DBL_MIN DBL_MIN
53 #endif // DBL_MIN
54 
55 #ifndef DBL_EPSILON
56 #define VTK_DBL_EPSILON 2.2204460492503131e-16
57 #else // DBL_EPSILON
58 #define VTK_DBL_EPSILON DBL_EPSILON
59 #endif // DBL_EPSILON
60 
61 #ifndef VTK_DBL_EPSILON
62 #ifndef DBL_EPSILON
63 #define VTK_DBL_EPSILON 2.2204460492503131e-16
64 #else // DBL_EPSILON
65 #define VTK_DBL_EPSILON DBL_EPSILON
66 #endif // DBL_EPSILON
67 #endif // VTK_DBL_EPSILON
68 
69 VTK_ABI_NAMESPACE_BEGIN
70 class vtkDataArray;
71 class vtkPoints;
72 class vtkMathInternal;
75 VTK_ABI_NAMESPACE_END
76 
77 namespace vtk_detail
78 {
79 VTK_ABI_NAMESPACE_BEGIN
80 // forward declaration
81 template <typename OutT>
82 void RoundDoubleToIntegralIfNecessary(double val, OutT* ret);
83 VTK_ABI_NAMESPACE_END
84 } // end namespace vtk_detail
85 
86 VTK_ABI_NAMESPACE_BEGIN
87 class VTKCOMMONCORE_EXPORT vtkMath : public vtkObject
88 {
89 public:
90  static vtkMath* New();
91  vtkTypeMacro(vtkMath, vtkObject);
92  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
97  static constexpr double Pi() { return 3.141592653589793; }
98 
100 
103  static float RadiansFromDegrees(float degrees);
104  static double RadiansFromDegrees(double degrees);
106 
108 
111  static float DegreesFromRadians(float radians);
112  static double DegreesFromRadians(double radians);
114 
118 #if 1
119  static int Round(float f) { return static_cast<int>(f + (f >= 0.0 ? 0.5 : -0.5)); }
120  static int Round(double f) { return static_cast<int>(f + (f >= 0.0 ? 0.5 : -0.5)); }
121 #endif
122 
127  template <typename OutT>
128  static void RoundDoubleToIntegralIfNecessary(double val, OutT* ret)
129  {
130  // Can't specialize template methods in a template class, so we move the
131  // implementations to a external namespace.
133  }
134 
140  static int Floor(double x);
141 
147  static int Ceil(double x);
148 
154  static int CeilLog2(vtkTypeUInt64 x);
155 
160  template <class T>
161  static T Min(const T& a, const T& b);
162 
167  template <class T>
168  static T Max(const T& a, const T& b);
169 
173  static bool IsPowerOfTwo(vtkTypeUInt64 x);
174 
180  static int NearestPowerOfTwo(int x);
181 
186  static vtkTypeInt64 Factorial(int N);
187 
193  static vtkTypeInt64 Binomial(int m, int n);
194 
206  static int* BeginCombination(int m, int n);
207 
218  static int NextCombination(int m, int n, int* combination);
219 
223  static void FreeCombination(int* combination);
224 
240  static void RandomSeed(int s);
241 
253  static int GetSeed();
254 
268  static double Random();
269 
282  static double Random(double min, double max);
283 
296  static double Gaussian();
297 
310  static double Gaussian(double mean, double std);
311 
316  template <class VectorT1, class VectorT2>
317  static void Assign(const VectorT1& a, VectorT2&& b)
318  {
319  b[0] = a[0];
320  b[1] = a[1];
321  b[2] = a[2];
322  }
323 
327  static void Assign(const double a[3], double b[3]) { vtkMath::Assign<>(a, b); }
328 
332  static void Add(const float a[3], const float b[3], float c[3])
333  {
334  for (int i = 0; i < 3; ++i)
335  {
336  c[i] = a[i] + b[i];
337  }
338  }
339 
343  static void Add(const double a[3], const double b[3], double c[3])
344  {
345  for (int i = 0; i < 3; ++i)
346  {
347  c[i] = a[i] + b[i];
348  }
349  }
350 
356  template <class VectorT1, class VectorT2, class VectorT3>
357  static void Add(VectorT1&& a, VectorT2&& b, VectorT3& c)
358  {
359  for (int i = 0; i < 3; ++i)
360  {
361  c[i] = a[i] + b[i];
362  }
363  }
364 
368  static void Subtract(const float a[3], const float b[3], float c[3])
369  {
370  for (int i = 0; i < 3; ++i)
371  {
372  c[i] = a[i] - b[i];
373  }
374  }
375 
379  static void Subtract(const double a[3], const double b[3], double c[3])
380  {
381  for (int i = 0; i < 3; ++i)
382  {
383  c[i] = a[i] - b[i];
384  }
385  }
386 
392  template <class VectorT1, class VectorT2, class VectorT3>
393  static void Subtract(const VectorT1& a, const VectorT2& b, VectorT3&& c)
394  {
395  c[0] = a[0] - b[0];
396  c[1] = a[1] - b[1];
397  c[2] = a[2] - b[2];
398  }
399 
404  static void MultiplyScalar(float a[3], float s)
405  {
406  for (int i = 0; i < 3; ++i)
407  {
408  a[i] *= s;
409  }
410  }
411 
416  static void MultiplyScalar2D(float a[2], float s)
417  {
418  for (int i = 0; i < 2; ++i)
419  {
420  a[i] *= s;
421  }
422  }
423 
428  static void MultiplyScalar(double a[3], double s)
429  {
430  for (int i = 0; i < 3; ++i)
431  {
432  a[i] *= s;
433  }
434  }
435 
440  static void MultiplyScalar2D(double a[2], double s)
441  {
442  for (int i = 0; i < 2; ++i)
443  {
444  a[i] *= s;
445  }
446  }
447 
451  static float Dot(const float a[3], const float b[3])
452  {
453  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
454  }
455 
459  static double Dot(const double a[3], const double b[3])
460  {
461  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
462  }
463 
479  template <typename ReturnTypeT = double, typename TupleRangeT1, typename TupleRangeT2,
480  typename EnableT = typename std::conditional<!std::is_pointer<TupleRangeT1>::value &&
482  TupleRangeT1, TupleRangeT2>::type::value_type>
483  static ReturnTypeT Dot(const TupleRangeT1& a, const TupleRangeT2& b)
484  {
485  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
486  }
487 
491  static void Outer(const float a[3], const float b[3], float c[3][3])
492  {
493  for (int i = 0; i < 3; ++i)
494  {
495  for (int j = 0; j < 3; ++j)
496  {
497  c[i][j] = a[i] * b[j];
498  }
499  }
500  }
501 
505  static void Outer(const double a[3], const double b[3], double c[3][3])
506  {
507  for (int i = 0; i < 3; ++i)
508  {
509  for (int j = 0; j < 3; ++j)
510  {
511  c[i][j] = a[i] * b[j];
512  }
513  }
514  }
515 
521  template <class VectorT1, class VectorT2, class VectorT3>
522  static void Cross(VectorT1&& a, VectorT2&& b, VectorT3& c);
523 
528  static void Cross(const float a[3], const float b[3], float c[3]);
529 
534  static void Cross(const double a[3], const double b[3], double c[3]);
535 
537 
540  static float Norm(const float* x, int n);
541  static double Norm(const double* x, int n);
543 
547  static float Norm(const float v[3]) { return std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); }
548 
552  static double Norm(const double v[3])
553  {
554  return std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
555  }
556 
566  template <typename ReturnTypeT = double, typename TupleRangeT>
567  static ReturnTypeT SquaredNorm(const TupleRangeT& v)
568  {
569  return v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
570  }
571 
576  static float Normalize(float v[3]);
577 
582  static double Normalize(double v[3]);
583 
585 
592  static void Perpendiculars(const double v1[3], double v2[3], double v3[3], double theta);
593  static void Perpendiculars(const float v1[3], float v2[3], float v3[3], double theta);
595 
597 
602  static bool ProjectVector(const float a[3], const float b[3], float projection[3]);
603  static bool ProjectVector(const double a[3], const double b[3], double projection[3]);
605 
607 
613  static bool ProjectVector2D(const float a[2], const float b[2], float projection[2]);
614  static bool ProjectVector2D(const double a[2], const double b[2], double projection[2]);
616 
632  template <typename ReturnTypeT = double, typename TupleRangeT1, typename TupleRangeT2,
633  typename EnableT = typename std::conditional<!std::is_pointer<TupleRangeT1>::value &&
635  TupleRangeT1, TupleRangeT2>::type::value_type>
636  static ReturnTypeT Distance2BetweenPoints(const TupleRangeT1& p1, const TupleRangeT2& p2);
637 
642  static float Distance2BetweenPoints(const float p1[3], const float p2[3]);
643 
648  static double Distance2BetweenPoints(const double p1[3], const double p2[3]);
649 
653  static double AngleBetweenVectors(const double v1[3], const double v2[3]);
654 
659  const double v1[3], const double v2[3], const double vn[3]);
660 
665  static double GaussianAmplitude(double variance, double distanceFromMean);
666 
671  static double GaussianAmplitude(double mean, double variance, double position);
672 
678  static double GaussianWeight(double variance, double distanceFromMean);
679 
685  static double GaussianWeight(double mean, double variance, double position);
686 
690  static float Dot2D(const float x[2], const float y[2]) { return x[0] * y[0] + x[1] * y[1]; }
691 
695  static double Dot2D(const double x[2], const double y[2]) { return x[0] * y[0] + x[1] * y[1]; }
696 
700  static void Outer2D(const float x[2], const float y[2], float A[2][2])
701  {
702  for (int i = 0; i < 2; ++i)
703  {
704  for (int j = 0; j < 2; ++j)
705  {
706  A[i][j] = x[i] * y[j];
707  }
708  }
709  }
710 
714  static void Outer2D(const double x[2], const double y[2], double A[2][2])
715  {
716  for (int i = 0; i < 2; ++i)
717  {
718  for (int j = 0; j < 2; ++j)
719  {
720  A[i][j] = x[i] * y[j];
721  }
722  }
723  }
724 
729  static float Norm2D(const float x[2]) { return std::sqrt(x[0] * x[0] + x[1] * x[1]); }
730 
735  static double Norm2D(const double x[2]) { return std::sqrt(x[0] * x[0] + x[1] * x[1]); }
736 
741  static float Normalize2D(float v[2]);
742 
747  static double Normalize2D(double v[2]);
748 
752  static float Determinant2x2(const float c1[2], const float c2[2])
753  {
754  return c1[0] * c2[1] - c2[0] * c1[1];
755  }
756 
758 
761  static double Determinant2x2(double a, double b, double c, double d) { return a * d - b * c; }
762  static double Determinant2x2(const double c1[2], const double c2[2])
763  {
764  return c1[0] * c2[1] - c2[0] * c1[1];
765  }
767 
769 
772  static void LUFactor3x3(float A[3][3], int index[3]);
773  static void LUFactor3x3(double A[3][3], int index[3]);
775 
777 
780  static void LUSolve3x3(const float A[3][3], const int index[3], float x[3]);
781  static void LUSolve3x3(const double A[3][3], const int index[3], double x[3]);
783 
785 
789  static void LinearSolve3x3(const float A[3][3], const float x[3], float y[3]);
790  static void LinearSolve3x3(const double A[3][3], const double x[3], double y[3]);
792 
794 
797  static void Multiply3x3(const float A[3][3], const float v[3], float u[3]);
798  static void Multiply3x3(const double A[3][3], const double v[3], double u[3]);
800 
802 
805  static void Multiply3x3(const float A[3][3], const float B[3][3], float C[3][3]);
806  static void Multiply3x3(const double A[3][3], const double B[3][3], double C[3][3]);
808 
832  template <int RowsT, int MidDimT, int ColsT,
833  class LayoutT1 = vtkMatrixUtilities::Layout::Identity,
834  class LayoutT2 = vtkMatrixUtilities::Layout::Identity, class MatrixT1, class MatrixT2,
835  class MatrixT3>
836  static void MultiplyMatrix(const MatrixT1& M1, const MatrixT2& M2, MatrixT3&& M3)
837  {
838  vtkMathPrivate::MultiplyMatrix<RowsT, MidDimT, ColsT, LayoutT1, LayoutT2>::Compute(M1, M2, M3);
839  }
840 
861  template <int RowsT, int ColsT, class LayoutT = vtkMatrixUtilities::Layout::Identity,
862  class MatrixT, class VectorT1, class VectorT2>
863  static void MultiplyMatrixWithVector(const MatrixT& M, const VectorT1& X, VectorT2&& Y)
864  {
865  vtkMathPrivate::MultiplyMatrix<RowsT, ColsT, 1, LayoutT>::Compute(M, X, Y);
866  }
867 
873  template <class ScalarT, int SizeT, class VectorT1, class VectorT2>
874  static ScalarT Dot(const VectorT1& x, const VectorT2& y)
875  {
876  return vtkMathPrivate::ContractRowWithCol<ScalarT, 1, SizeT, 1, 0, 0,
877  vtkMatrixUtilities::Layout::Identity, vtkMatrixUtilities::Layout::Transpose>::Compute(x, y);
878  }
879 
896  template <int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT>
898  const MatrixT& M)
899  {
900  return vtkMathPrivate::Determinant<SizeT, LayoutT>::Compute(M);
901  }
902 
918  template <int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT1,
919  class MatrixT2>
920  static void InvertMatrix(const MatrixT1& M1, MatrixT2&& M2)
921  {
922  vtkMathPrivate::InvertMatrix<SizeT, LayoutT>::Compute(M1, M2);
923  }
924 
938  template <int RowsT, int ColsT, class LayoutT = vtkMatrixUtilities::Layout::Identity,
939  class MatrixT, class VectorT1, class VectorT2>
940  static void LinearSolve(const MatrixT& M, const VectorT1& x, VectorT2& y)
941  {
942  vtkMathPrivate::LinearSolve<RowsT, ColsT, LayoutT>::Compute(M, x, y);
943  }
944 
959  template <class ScalarT, int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity,
960  class VectorT1, class MatrixT, class VectorT2>
961  static ScalarT Dot(const VectorT1& x, const MatrixT& M, const VectorT2& y)
962  {
963  ScalarT tmp[SizeT];
964  vtkMathPrivate::MultiplyMatrix<SizeT, SizeT, 1, LayoutT>::Compute(M, y, tmp);
965  return vtkMathPrivate::ContractRowWithCol<ScalarT, 1, SizeT, 1, 0, 0,
966  vtkMatrixUtilities::Layout::Identity, vtkMatrixUtilities::Layout::Transpose>::Compute(x, tmp);
967  }
968 
974  static void MultiplyMatrix(const double* const* A, const double* const* B, unsigned int rowA,
975  unsigned int colA, unsigned int rowB, unsigned int colB, double** C);
976 
978 
982  static void Transpose3x3(const float A[3][3], float AT[3][3]);
983  static void Transpose3x3(const double A[3][3], double AT[3][3]);
985 
987 
991  static void Invert3x3(const float A[3][3], float AI[3][3]);
992  static void Invert3x3(const double A[3][3], double AI[3][3]);
994 
996 
999  static void Identity3x3(float A[3][3]);
1000  static void Identity3x3(double A[3][3]);
1002 
1004 
1007  static double Determinant3x3(const float A[3][3]);
1008  static double Determinant3x3(const double A[3][3]);
1010 
1014  static float Determinant3x3(const float c1[3], const float c2[3], const float c3[3]);
1015 
1019  static double Determinant3x3(const double c1[3], const double c2[3], const double c3[3]);
1020 
1027  static double Determinant3x3(double a1, double a2, double a3, double b1, double b2, double b3,
1028  double c1, double c2, double c3);
1029 
1031 
1038  static void QuaternionToMatrix3x3(const float quat[4], float A[3][3]);
1039  static void QuaternionToMatrix3x3(const double quat[4], double A[3][3]);
1040  template <class QuaternionT, class MatrixT,
1041  class EnableT = typename std::enable_if<!vtkMatrixUtilities::MatrixIs2DArray<MatrixT>()>::type>
1042  static void QuaternionToMatrix3x3(const QuaternionT& q, MatrixT&& A);
1044 
1046 
1055  static void Matrix3x3ToQuaternion(const float A[3][3], float quat[4]);
1056  static void Matrix3x3ToQuaternion(const double A[3][3], double quat[4]);
1057  template <class MatrixT, class QuaternionT,
1058  class EnableT = typename std::enable_if<!vtkMatrixUtilities::MatrixIs2DArray<MatrixT>()>::type>
1059  static void Matrix3x3ToQuaternion(const MatrixT& A, QuaternionT&& q);
1061 
1063 
1069  static void MultiplyQuaternion(const float q1[4], const float q2[4], float q[4]);
1070  static void MultiplyQuaternion(const double q1[4], const double q2[4], double q[4]);
1072 
1074 
1078  static void RotateVectorByNormalizedQuaternion(const float v[3], const float q[4], float r[3]);
1079  static void RotateVectorByNormalizedQuaternion(const double v[3], const double q[4], double r[3]);
1081 
1083 
1087  static void RotateVectorByWXYZ(const float v[3], const float q[4], float r[3]);
1088  static void RotateVectorByWXYZ(const double v[3], const double q[4], double r[3]);
1090 
1092 
1097  static void Orthogonalize3x3(const float A[3][3], float B[3][3]);
1098  static void Orthogonalize3x3(const double A[3][3], double B[3][3]);
1100 
1102 
1108  static void Diagonalize3x3(const float A[3][3], float w[3], float V[3][3]);
1109  static void Diagonalize3x3(const double A[3][3], double w[3], double V[3][3]);
1111 
1113 
1123  const float A[3][3], float U[3][3], float w[3], float VT[3][3]);
1125  const double A[3][3], double U[3][3], double w[3], double VT[3][3]);
1127 
1136  double a00, double a01, double a10, double a11, double b0, double b1, double& x0, double& x1);
1137 
1146  static vtkTypeBool SolveLinearSystem(double** A, double* x, int size);
1147 
1154  static vtkTypeBool InvertMatrix(double** A, double** AI, int size);
1155 
1162  double** A, double** AI, int size, int* tmp1Size, double* tmp2Size);
1163 
1186  static vtkTypeBool LUFactorLinearSystem(double** A, int* index, int size);
1187 
1193  static vtkTypeBool LUFactorLinearSystem(double** A, int* index, int size, double* tmpSize);
1194 
1203  static void LUSolveLinearSystem(double** A, int* index, double* x, int size);
1204 
1213  static double EstimateMatrixCondition(const double* const* A, int size);
1214 
1216 
1224  static vtkTypeBool Jacobi(float** a, float* w, float** v);
1225  static vtkTypeBool Jacobi(double** a, double* w, double** v);
1227 
1229 
1238  static vtkTypeBool JacobiN(float** a, int n, float* w, float** v);
1239  static vtkTypeBool JacobiN(double** a, int n, double* w, double** v);
1241 
1256  int numberOfSamples, double** xt, int xOrder, double** mt);
1257 
1272  static vtkTypeBool SolveLeastSquares(int numberOfSamples, double** xt, int xOrder, double** yt,
1273  int yOrder, double** mt, int checkHomogeneous = 1);
1274 
1276 
1283  static void RGBToHSV(const float rgb[3], float hsv[3])
1284  {
1285  RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
1286  }
1287  static void RGBToHSV(float r, float g, float b, float* h, float* s, float* v);
1288  static void RGBToHSV(const double rgb[3], double hsv[3])
1289  {
1290  RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
1291  }
1292  static void RGBToHSV(double r, double g, double b, double* h, double* s, double* v);
1294 
1296 
1303  static void HSVToRGB(const float hsv[3], float rgb[3])
1304  {
1305  HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
1306  }
1307  static void HSVToRGB(float h, float s, float v, float* r, float* g, float* b);
1308  static void HSVToRGB(const double hsv[3], double rgb[3])
1309  {
1310  HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
1311  }
1312  static void HSVToRGB(double h, double s, double v, double* r, double* g, double* b);
1314 
1316 
1319  static void LabToXYZ(const double lab[3], double xyz[3])
1320  {
1321  LabToXYZ(lab[0], lab[1], lab[2], xyz + 0, xyz + 1, xyz + 2);
1322  }
1323  static void LabToXYZ(double L, double a, double b, double* x, double* y, double* z);
1325 
1327 
1330  static void XYZToLab(const double xyz[3], double lab[3])
1331  {
1332  XYZToLab(xyz[0], xyz[1], xyz[2], lab + 0, lab + 1, lab + 2);
1333  }
1334  static void XYZToLab(double x, double y, double z, double* L, double* a, double* b);
1336 
1338 
1341  static void XYZToRGB(const double xyz[3], double rgb[3])
1342  {
1343  XYZToRGB(xyz[0], xyz[1], xyz[2], rgb + 0, rgb + 1, rgb + 2);
1344  }
1345  static void XYZToRGB(double x, double y, double z, double* r, double* g, double* b);
1347 
1349 
1352  static void RGBToXYZ(const double rgb[3], double xyz[3])
1353  {
1354  RGBToXYZ(rgb[0], rgb[1], rgb[2], xyz + 0, xyz + 1, xyz + 2);
1355  }
1356  static void RGBToXYZ(double r, double g, double b, double* x, double* y, double* z);
1358 
1360 
1366  static void RGBToLab(const double rgb[3], double lab[3])
1367  {
1368  RGBToLab(rgb[0], rgb[1], rgb[2], lab + 0, lab + 1, lab + 2);
1369  }
1370  static void RGBToLab(double red, double green, double blue, double* L, double* a, double* b);
1372 
1374 
1377  static void LabToRGB(const double lab[3], double rgb[3])
1378  {
1379  LabToRGB(lab[0], lab[1], lab[2], rgb + 0, rgb + 1, rgb + 2);
1380  }
1381  static void LabToRGB(double L, double a, double b, double* red, double* green, double* blue);
1383 
1385 
1388  static void UninitializeBounds(double bounds[6])
1389  {
1390  bounds[0] = 1.0;
1391  bounds[1] = -1.0;
1392  bounds[2] = 1.0;
1393  bounds[3] = -1.0;
1394  bounds[4] = 1.0;
1395  bounds[5] = -1.0;
1396  }
1398 
1400 
1403  static vtkTypeBool AreBoundsInitialized(const double bounds[6])
1404  {
1405  if (bounds[1] - bounds[0] < 0.0)
1406  {
1407  return 0;
1408  }
1409  return 1;
1410  }
1412 
1417  template <class T>
1418  static T ClampValue(const T& value, const T& min, const T& max);
1419 
1421 
1425  static void ClampValue(double* value, const double range[2]);
1426  static void ClampValue(double value, const double range[2], double* clamped_value);
1427  static void ClampValues(double* values, int nb_values, const double range[2]);
1428  static void ClampValues(
1429  const double* values, int nb_values, const double range[2], double* clamped_values);
1431 
1438  static double ClampAndNormalizeValue(double value, const double range[2]);
1439 
1444  template <class T1, class T2>
1445  static void TensorFromSymmetricTensor(const T1 symmTensor[6], T2 tensor[9]);
1446 
1452  template <class T>
1453  static void TensorFromSymmetricTensor(T tensor[9]);
1454 
1464  double range_min, double range_max, double scale = 1.0, double shift = 0.0);
1465 
1474  static vtkTypeBool GetAdjustedScalarRange(vtkDataArray* array, int comp, double range[2]);
1475 
1480  static vtkTypeBool ExtentIsWithinOtherExtent(const int extent1[6], const int extent2[6]);
1481 
1488  const double bounds1[6], const double bounds2[6], const double delta[3]);
1489 
1496  const double point[3], const double bounds[6], const double delta[3]);
1497 
1508  const double bounds[6], const double normal[3], const double point[3]);
1509 
1519  static double Solve3PointCircle(
1520  const double p1[3], const double p2[3], const double p3[3], double center[3]);
1521 
1525  static double Inf();
1526 
1530  static double NegInf();
1531 
1535  static double Nan();
1536 
1540  static vtkTypeBool IsInf(double x);
1541 
1545  static vtkTypeBool IsNan(double x);
1546 
1551  static bool IsFinite(double x);
1552 
1557  static int QuadraticRoot(double a, double b, double c, double min, double max, double* u);
1558 
1564  static vtkIdType ComputeGCD(vtkIdType m, vtkIdType n) { return (n ? ComputeGCD(n, m % n) : m); }
1565 
1569  enum class ConvolutionMode
1570  {
1571  FULL,
1572  SAME,
1573  VALID
1574  };
1575 
1598  template <class Iter1, class Iter2, class Iter3>
1599  static void Convolve1D(Iter1 beginSample, Iter1 endSample, Iter2 beginKernel, Iter2 endKernel,
1600  Iter3 beginOut, Iter3 endOut, ConvolutionMode mode = ConvolutionMode::FULL)
1601  {
1602  int sampleSize = std::distance(beginSample, endSample);
1603  int kernelSize = std::distance(beginKernel, endKernel);
1604  int outSize = std::distance(beginOut, endOut);
1605 
1606  if (sampleSize <= 0 || kernelSize <= 0 || outSize <= 0)
1607  {
1608  return;
1609  }
1610 
1611  int begin = 0;
1612  int end = outSize;
1613 
1614  switch (mode)
1615  {
1616  case ConvolutionMode::SAME:
1617  begin = static_cast<int>(std::ceil((std::min)(sampleSize, kernelSize) / 2.0)) - 1;
1618  end = begin + (std::max)(sampleSize, kernelSize);
1619  break;
1620  case ConvolutionMode::VALID:
1621  begin = (std::min)(sampleSize, kernelSize) - 1;
1622  end = begin + std::abs(sampleSize - kernelSize) + 1;
1623  break;
1624  case ConvolutionMode::FULL:
1625  default:
1626  break;
1627  }
1628 
1629  for (int i = begin; i < end; i++)
1630  {
1631  Iter3 out = beginOut + i - begin;
1632  *out = 0;
1633  for (int j = (std::max)(i - sampleSize + 1, 0); j <= (std::min)(i, kernelSize - 1); j++)
1634  {
1635  *out += *(beginSample + (i - j)) * *(beginKernel + j);
1636  }
1637  }
1638  }
1639 
1644  static void GetPointAlongLine(double result[3], double p1[3], double p2[3], const double offset)
1645  {
1646  double directionVector[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
1647  vtkMath::Normalize(directionVector);
1648  result[0] = p2[0] + (offset * directionVector[0]);
1649  result[1] = p2[1] + (offset * directionVector[1]);
1650  result[2] = p2[2] + (offset * directionVector[2]);
1651  }
1652 
1653 protected:
1654  vtkMath() = default;
1655  ~vtkMath() override = default;
1656 
1658 
1659 private:
1660  vtkMath(const vtkMath&) = delete;
1661  void operator=(const vtkMath&) = delete;
1662 };
1663 
1664 //----------------------------------------------------------------------------
1665 inline float vtkMath::RadiansFromDegrees(float x)
1666 {
1667  return x * 0.017453292f;
1668 }
1669 
1670 //----------------------------------------------------------------------------
1671 inline double vtkMath::RadiansFromDegrees(double x)
1672 {
1673  return x * 0.017453292519943295;
1674 }
1675 
1676 //----------------------------------------------------------------------------
1677 inline float vtkMath::DegreesFromRadians(float x)
1678 {
1679  return x * 57.2957795131f;
1680 }
1681 
1682 //----------------------------------------------------------------------------
1683 inline double vtkMath::DegreesFromRadians(double x)
1684 {
1685  return x * 57.29577951308232;
1686 }
1687 
1688 //----------------------------------------------------------------------------
1689 inline bool vtkMath::IsPowerOfTwo(vtkTypeUInt64 x)
1690 {
1691  return ((x != 0) & ((x & (x - 1)) == 0));
1692 }
1693 
1694 //----------------------------------------------------------------------------
1695 // Credit goes to Peter Hart and William Lewis on comp.lang.python 1997
1697 {
1698  unsigned int z = static_cast<unsigned int>(((x > 0) ? x - 1 : 0));
1699  z |= z >> 1;
1700  z |= z >> 2;
1701  z |= z >> 4;
1702  z |= z >> 8;
1703  z |= z >> 16;
1704  return static_cast<int>(z + 1);
1705 }
1706 
1707 //----------------------------------------------------------------------------
1708 // Modify the trunc() operation provided by static_cast<int>() to get floor(),
1709 // Note that in C++ conditions evaluate to values of 1 or 0 (true or false).
1710 inline int vtkMath::Floor(double x)
1711 {
1712  int i = static_cast<int>(x);
1713  return i - (i > x);
1714 }
1715 
1716 //----------------------------------------------------------------------------
1717 // Modify the trunc() operation provided by static_cast<int>() to get ceil(),
1718 // Note that in C++ conditions evaluate to values of 1 or 0 (true or false).
1719 inline int vtkMath::Ceil(double x)
1720 {
1721  int i = static_cast<int>(x);
1722  return i + (i < x);
1723 }
1724 
1725 //----------------------------------------------------------------------------
1726 template <class T>
1727 inline T vtkMath::Min(const T& a, const T& b)
1728 {
1729  return (b <= a ? b : a);
1730 }
1731 
1732 //----------------------------------------------------------------------------
1733 template <class T>
1734 inline T vtkMath::Max(const T& a, const T& b)
1735 {
1736  return (b > a ? b : a);
1737 }
1738 
1739 //----------------------------------------------------------------------------
1740 inline float vtkMath::Normalize(float v[3])
1741 {
1742  float den = vtkMath::Norm(v);
1743  if (den != 0.0)
1744  {
1745  for (int i = 0; i < 3; ++i)
1746  {
1747  v[i] /= den;
1748  }
1749  }
1750  return den;
1751 }
1752 
1753 //----------------------------------------------------------------------------
1754 inline double vtkMath::Normalize(double v[3])
1755 {
1756  double den = vtkMath::Norm(v);
1757  if (den != 0.0)
1758  {
1759  for (int i = 0; i < 3; ++i)
1760  {
1761  v[i] /= den;
1762  }
1763  }
1764  return den;
1765 }
1766 
1767 //----------------------------------------------------------------------------
1768 inline float vtkMath::Normalize2D(float v[2])
1769 {
1770  float den = vtkMath::Norm2D(v);
1771  if (den != 0.0)
1772  {
1773  for (int i = 0; i < 2; ++i)
1774  {
1775  v[i] /= den;
1776  }
1777  }
1778  return den;
1779 }
1780 
1781 //----------------------------------------------------------------------------
1782 inline double vtkMath::Normalize2D(double v[2])
1783 {
1784  double den = vtkMath::Norm2D(v);
1785  if (den != 0.0)
1786  {
1787  for (int i = 0; i < 2; ++i)
1788  {
1789  v[i] /= den;
1790  }
1791  }
1792  return den;
1793 }
1794 
1795 //----------------------------------------------------------------------------
1796 inline float vtkMath::Determinant3x3(const float c1[3], const float c2[3], const float c3[3])
1797 {
1798  return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1799  c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1800 }
1801 
1802 //----------------------------------------------------------------------------
1803 inline double vtkMath::Determinant3x3(const double c1[3], const double c2[3], const double c3[3])
1804 {
1805  return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1806  c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1807 }
1808 
1809 //----------------------------------------------------------------------------
1811  double a1, double a2, double a3, double b1, double b2, double b3, double c1, double c2, double c3)
1812 {
1813  return (a1 * vtkMath::Determinant2x2(b2, b3, c2, c3) -
1814  b1 * vtkMath::Determinant2x2(a2, a3, c2, c3) + c1 * vtkMath::Determinant2x2(a2, a3, b2, b3));
1815 }
1816 
1817 //----------------------------------------------------------------------------
1818 inline float vtkMath::Distance2BetweenPoints(const float p1[3], const float p2[3])
1819 {
1820  return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
1821  (p1[2] - p2[2]) * (p1[2] - p2[2]));
1822 }
1823 
1824 //----------------------------------------------------------------------------
1825 inline double vtkMath::Distance2BetweenPoints(const double p1[3], const double p2[3])
1826 {
1827  return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
1828  (p1[2] - p2[2]) * (p1[2] - p2[2]));
1829 }
1830 
1831 //----------------------------------------------------------------------------
1832 template <typename ReturnTypeT, typename TupleRangeT1, typename TupleRangeT2, typename EnableT>
1833 inline ReturnTypeT vtkMath::Distance2BetweenPoints(const TupleRangeT1& p1, const TupleRangeT2& p2)
1834 {
1835  return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
1836  (p1[2] - p2[2]) * (p1[2] - p2[2]));
1837 }
1838 
1839 //----------------------------------------------------------------------------
1840 template <class VectorT1, class VectorT2, class VectorT3>
1841 void vtkMath::Cross(VectorT1&& a, VectorT2&& b, VectorT3& c)
1842 {
1844  ValueType Cx = a[1] * b[2] - a[2] * b[1];
1845  ValueType Cy = a[2] * b[0] - a[0] * b[2];
1846  ValueType Cz = a[0] * b[1] - a[1] * b[0];
1847  c[0] = Cx;
1848  c[1] = Cy;
1849  c[2] = Cz;
1850 }
1851 
1852 //----------------------------------------------------------------------------
1853 // Cross product of two 3-vectors. Result (a x b) is stored in c[3].
1854 inline void vtkMath::Cross(const float a[3], const float b[3], float c[3])
1855 {
1856  float Cx = a[1] * b[2] - a[2] * b[1];
1857  float Cy = a[2] * b[0] - a[0] * b[2];
1858  float Cz = a[0] * b[1] - a[1] * b[0];
1859  c[0] = Cx;
1860  c[1] = Cy;
1861  c[2] = Cz;
1862 }
1863 
1864 //----------------------------------------------------------------------------
1865 // Cross product of two 3-vectors. Result (a x b) is stored in c[3].
1866 inline void vtkMath::Cross(const double a[3], const double b[3], double c[3])
1867 {
1868  double Cx = a[1] * b[2] - a[2] * b[1];
1869  double Cy = a[2] * b[0] - a[0] * b[2];
1870  double Cz = a[0] * b[1] - a[1] * b[0];
1871  c[0] = Cx;
1872  c[1] = Cy;
1873  c[2] = Cz;
1874 }
1875 
1876 //----------------------------------------------------------------------------
1877 template <class T>
1878 inline double vtkDeterminant3x3(const T A[3][3])
1879 {
1880  return A[0][0] * A[1][1] * A[2][2] + A[1][0] * A[2][1] * A[0][2] + A[2][0] * A[0][1] * A[1][2] -
1881  A[0][0] * A[2][1] * A[1][2] - A[1][0] * A[0][1] * A[2][2] - A[2][0] * A[1][1] * A[0][2];
1882 }
1883 
1884 //----------------------------------------------------------------------------
1885 inline double vtkMath::Determinant3x3(const float A[3][3])
1886 {
1887  return vtkDeterminant3x3(A);
1888 }
1889 
1890 //----------------------------------------------------------------------------
1891 inline double vtkMath::Determinant3x3(const double A[3][3])
1892 {
1893  return vtkDeterminant3x3(A);
1894 }
1895 
1896 //----------------------------------------------------------------------------
1897 template <class T>
1898 inline T vtkMath::ClampValue(const T& value, const T& min, const T& max)
1899 {
1900  assert("pre: valid_range" && min <= max);
1901 
1902 #if __cplusplus >= 201703L
1903  return std::clamp(value, min, max);
1904 #else
1905  // compilers are good at optimizing the ternary operator,
1906  // use '<' since it is preferred by STL for custom types
1907  T v = (min < value ? value : min);
1908  return (v < max ? v : max);
1909 #endif
1910 }
1911 
1912 //----------------------------------------------------------------------------
1913 inline void vtkMath::ClampValue(double* value, const double range[2])
1914 {
1915  if (value && range)
1916  {
1917  assert("pre: valid_range" && range[0] <= range[1]);
1918 
1919  *value = vtkMath::ClampValue(*value, range[0], range[1]);
1920  }
1921 }
1922 
1923 //----------------------------------------------------------------------------
1924 inline void vtkMath::ClampValue(double value, const double range[2], double* clamped_value)
1925 {
1926  if (range && clamped_value)
1927  {
1928  assert("pre: valid_range" && range[0] <= range[1]);
1929 
1930  *clamped_value = vtkMath::ClampValue(value, range[0], range[1]);
1931  }
1932 }
1933 
1934 // ---------------------------------------------------------------------------
1935 inline double vtkMath::ClampAndNormalizeValue(double value, const double range[2])
1936 {
1937  assert("pre: valid_range" && range[0] <= range[1]);
1938 
1939  double result;
1940  if (range[0] == range[1])
1941  {
1942  result = 0.0;
1943  }
1944  else
1945  {
1946  // clamp
1947  result = vtkMath::ClampValue(value, range[0], range[1]);
1948 
1949  // normalize
1950  result = (result - range[0]) / (range[1] - range[0]);
1951  }
1952 
1953  assert("post: valid_result" && result >= 0.0 && result <= 1.0);
1954 
1955  return result;
1956 }
1957 
1958 //-----------------------------------------------------------------------------
1959 template <class T1, class T2>
1960 inline void vtkMath::TensorFromSymmetricTensor(const T1 symmTensor[9], T2 tensor[9])
1961 {
1962  for (int i = 0; i < 3; ++i)
1963  {
1964  tensor[4 * i] = symmTensor[i];
1965  }
1966  tensor[1] = tensor[3] = symmTensor[3];
1967  tensor[2] = tensor[6] = symmTensor[5];
1968  tensor[5] = tensor[7] = symmTensor[4];
1969 }
1970 
1971 //-----------------------------------------------------------------------------
1972 template <class T>
1973 inline void vtkMath::TensorFromSymmetricTensor(T tensor[9])
1974 {
1975  tensor[6] = tensor[5]; // XZ
1976  tensor[7] = tensor[4]; // YZ
1977  tensor[8] = tensor[2]; // ZZ
1978  tensor[4] = tensor[1]; // YY
1979  tensor[5] = tensor[7]; // YZ
1980  tensor[2] = tensor[6]; // XZ
1981  tensor[1] = tensor[3]; // XY
1982 }
1983 VTK_ABI_NAMESPACE_END
1984 
1985 namespace
1986 {
1987 template <class QuaternionT, class MatrixT>
1988 inline void vtkQuaternionToMatrix3x3(const QuaternionT& quat, MatrixT& A)
1989 {
1991 
1992  Scalar ww = quat[0] * quat[0];
1993  Scalar wx = quat[0] * quat[1];
1994  Scalar wy = quat[0] * quat[2];
1995  Scalar wz = quat[0] * quat[3];
1996 
1997  Scalar xx = quat[1] * quat[1];
1998  Scalar yy = quat[2] * quat[2];
1999  Scalar zz = quat[3] * quat[3];
2000 
2001  Scalar xy = quat[1] * quat[2];
2002  Scalar xz = quat[1] * quat[3];
2003  Scalar yz = quat[2] * quat[3];
2004 
2005  Scalar rr = xx + yy + zz;
2006  // normalization factor, just in case quaternion was not normalized
2007  Scalar f = 1 / (ww + rr);
2008  Scalar s = (ww - rr) * f;
2009  f *= 2;
2010 
2012 
2013  Wrapper::template Get<0, 0>(A) = xx * f + s;
2014  Wrapper::template Get<1, 0>(A) = (xy + wz) * f;
2015  Wrapper::template Get<2, 0>(A) = (xz - wy) * f;
2016 
2017  Wrapper::template Get<0, 1>(A) = (xy - wz) * f;
2018  Wrapper::template Get<1, 1>(A) = yy * f + s;
2019  Wrapper::template Get<2, 1>(A) = (yz + wx) * f;
2020 
2021  Wrapper::template Get<0, 2>(A) = (xz + wy) * f;
2022  Wrapper::template Get<1, 2>(A) = (yz - wx) * f;
2023  Wrapper::template Get<2, 2>(A) = zz * f + s;
2024 }
2025 } // anonymous namespace
2026 
2027 VTK_ABI_NAMESPACE_BEGIN
2028 //------------------------------------------------------------------------------
2029 inline void vtkMath::QuaternionToMatrix3x3(const float quat[4], float A[3][3])
2030 {
2031  vtkQuaternionToMatrix3x3(quat, A);
2032 }
2033 
2034 //------------------------------------------------------------------------------
2035 inline void vtkMath::QuaternionToMatrix3x3(const double quat[4], double A[3][3])
2036 {
2037  vtkQuaternionToMatrix3x3(quat, A);
2038 }
2039 
2040 //-----------------------------------------------------------------------------
2041 template <class QuaternionT, class MatrixT, class EnableT>
2042 inline void vtkMath::QuaternionToMatrix3x3(const QuaternionT& q, MatrixT&& A)
2043 {
2044  vtkQuaternionToMatrix3x3(q, A);
2045 }
2046 VTK_ABI_NAMESPACE_END
2047 
2048 namespace
2049 {
2050 //------------------------------------------------------------------------------
2051 // The solution is based on
2052 // Berthold K. P. Horn (1987),
2053 // "Closed-form solution of absolute orientation using unit quaternions,"
2054 // Journal of the Optical Society of America A, 4:629-642
2055 template <class MatrixT, class QuaternionT>
2056 inline void vtkMatrix3x3ToQuaternion(const MatrixT& A, QuaternionT& quat)
2057 {
2059 
2060  Scalar N[4][4];
2061 
2063 
2064  // on-diagonal elements
2065  N[0][0] = Wrapper::template Get<0, 0>(A) + Wrapper::template Get<1, 1>(A) +
2066  Wrapper::template Get<2, 2>(A);
2067  N[1][1] = Wrapper::template Get<0, 0>(A) - Wrapper::template Get<1, 1>(A) -
2068  Wrapper::template Get<2, 2>(A);
2069  N[2][2] = -Wrapper::template Get<0, 0>(A) + Wrapper::template Get<1, 1>(A) -
2070  Wrapper::template Get<2, 2>(A);
2071  N[3][3] = -Wrapper::template Get<0, 0>(A) - Wrapper::template Get<1, 1>(A) +
2072  Wrapper::template Get<2, 2>(A);
2073 
2074  // off-diagonal elements
2075  N[0][1] = N[1][0] = Wrapper::template Get<2, 1>(A) - Wrapper::template Get<1, 2>(A);
2076  N[0][2] = N[2][0] = Wrapper::template Get<0, 2>(A) - Wrapper::template Get<2, 0>(A);
2077  N[0][3] = N[3][0] = Wrapper::template Get<1, 0>(A) - Wrapper::template Get<0, 1>(A);
2078 
2079  N[1][2] = N[2][1] = Wrapper::template Get<1, 0>(A) + Wrapper::template Get<0, 1>(A);
2080  N[1][3] = N[3][1] = Wrapper::template Get<0, 2>(A) + Wrapper::template Get<2, 0>(A);
2081  N[2][3] = N[3][2] = Wrapper::template Get<2, 1>(A) + Wrapper::template Get<1, 2>(A);
2082 
2083  Scalar eigenvectors[4][4], eigenvalues[4];
2084 
2085  // convert into format that JacobiN can use,
2086  // then use Jacobi to find eigenvalues and eigenvectors
2087  Scalar *NTemp[4], *eigenvectorsTemp[4];
2088  for (int i = 0; i < 4; ++i)
2089  {
2090  NTemp[i] = N[i];
2091  eigenvectorsTemp[i] = eigenvectors[i];
2092  }
2093  vtkMath::JacobiN(NTemp, 4, eigenvalues, eigenvectorsTemp);
2094 
2095  // the first eigenvector is the one we want
2096  quat[0] = eigenvectors[0][0];
2097  quat[1] = eigenvectors[1][0];
2098  quat[2] = eigenvectors[2][0];
2099  quat[3] = eigenvectors[3][0];
2100 }
2101 } // anonymous namespace
2102 
2103 VTK_ABI_NAMESPACE_BEGIN
2104 //------------------------------------------------------------------------------
2105 inline void vtkMath::Matrix3x3ToQuaternion(const float A[3][3], float quat[4])
2106 {
2107  vtkMatrix3x3ToQuaternion(A, quat);
2108 }
2109 
2110 //------------------------------------------------------------------------------
2111 inline void vtkMath::Matrix3x3ToQuaternion(const double A[3][3], double quat[4])
2112 {
2113  vtkMatrix3x3ToQuaternion(A, quat);
2114 }
2115 
2116 //-----------------------------------------------------------------------------
2117 template <class MatrixT, class QuaternionT, class EnableT>
2118 inline void vtkMath::Matrix3x3ToQuaternion(const MatrixT& A, QuaternionT&& q)
2119 {
2120  vtkMatrix3x3ToQuaternion(A, q);
2121 }
2122 VTK_ABI_NAMESPACE_END
2123 
2124 namespace vtk_detail
2125 {
2126 VTK_ABI_NAMESPACE_BEGIN
2127 // Can't specialize templates inside a template class, so we move the impl here.
2128 template <typename OutT>
2129 void RoundDoubleToIntegralIfNecessary(double val, OutT* ret)
2130 { // OutT is integral -- clamp and round
2131  if (!vtkMath::IsNan(val))
2132  {
2133  double min = static_cast<double>(vtkTypeTraits<OutT>::Min());
2134  double max = static_cast<double>(vtkTypeTraits<OutT>::Max());
2135  val = vtkMath::ClampValue(val, min, max);
2136  *ret = static_cast<OutT>((val >= 0.0) ? (val + 0.5) : (val - 0.5));
2137  }
2138  else
2139  *ret = 0;
2140 }
2141 template <>
2142 inline void RoundDoubleToIntegralIfNecessary(double val, double* retVal)
2143 { // OutT is double: passthrough
2144  *retVal = val;
2145 }
2146 template <>
2147 inline void RoundDoubleToIntegralIfNecessary(double val, float* retVal)
2148 { // OutT is float -- just clamp (as doubles, then the cast to float is well-defined.)
2149  if (!vtkMath::IsNan(val))
2150  {
2151  double min = static_cast<double>(vtkTypeTraits<float>::Min());
2152  double max = static_cast<double>(vtkTypeTraits<float>::Max());
2153  val = vtkMath::ClampValue(val, min, max);
2154  }
2155 
2156  *retVal = static_cast<float>(val);
2157 }
2158 VTK_ABI_NAMESPACE_END
2159 } // end namespace vtk_detail
2160 
2161 VTK_ABI_NAMESPACE_BEGIN
2162 //-----------------------------------------------------------------------------
2163 #if defined(VTK_HAS_ISINF) || defined(VTK_HAS_STD_ISINF)
2164 #define VTK_MATH_ISINF_IS_INLINE
2165 inline vtkTypeBool vtkMath::IsInf(double x)
2166 {
2167 #if defined(VTK_HAS_STD_ISINF)
2168  return std::isinf(x);
2169 #else
2170  return (isinf(x) != 0); // Force conversion to bool
2171 #endif
2172 }
2173 #endif
2174 
2175 //-----------------------------------------------------------------------------
2176 #if defined(VTK_HAS_ISNAN) || defined(VTK_HAS_STD_ISNAN)
2177 #define VTK_MATH_ISNAN_IS_INLINE
2178 inline vtkTypeBool vtkMath::IsNan(double x)
2179 {
2180 #if defined(VTK_HAS_STD_ISNAN)
2181  return std::isnan(x);
2182 #else
2183  return (isnan(x) != 0); // Force conversion to bool
2184 #endif
2185 }
2186 #endif
2187 
2188 //-----------------------------------------------------------------------------
2189 #if defined(VTK_HAS_ISFINITE) || defined(VTK_HAS_STD_ISFINITE) || defined(VTK_HAS_FINITE)
2190 #define VTK_MATH_ISFINITE_IS_INLINE
2191 inline bool vtkMath::IsFinite(double x)
2192 {
2193 #if defined(VTK_HAS_STD_ISFINITE)
2194  return std::isfinite(x);
2195 #elif defined(VTK_HAS_ISFINITE)
2196  return (isfinite(x) != 0); // Force conversion to bool
2197 #else
2198  return (finite(x) != 0); // Force conversion to bool
2199 #endif
2200 }
2201 #endif
2202 
2203 VTK_ABI_NAMESPACE_END
2204 #endif
Gaussian sequence of pseudo random numbers implemented with the Box-Mueller transform.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
a simple class to control print indentation
Definition: vtkIndent.h:38
performs common math operations
Definition: vtkMath.h:88
static ReturnTypeT Distance2BetweenPoints(const TupleRangeT1 &p1, const TupleRangeT2 &p2)
Compute distance squared between two points p1 and p2.
Definition: vtkMath.h:1833
static void Multiply3x3(const float A[3][3], const float B[3][3], float C[3][3])
Multiply one 3x3 matrix by another according to C = AB.
static double Dot(const double a[3], const double b[3])
Dot product of two 3-vectors (double version).
Definition: vtkMath.h:459
static int GetScalarTypeFittingRange(double range_min, double range_max, double scale=1.0, double shift=0.0)
Return the scalar type that is most likely to have enough precision to store a given range of data on...
static void RGBToXYZ(double r, double g, double b, double *x, double *y, double *z)
Convert color from the RGB system to CIE XYZ.
static void Multiply3x3(const double A[3][3], const double B[3][3], double C[3][3])
Multiply one 3x3 matrix by another according to C = AB.
static double Norm(const double *x, int n)
Compute the norm of n-vector.
static int Round(float f)
Rounds a float to the nearest integer.
Definition: vtkMath.h:119
static int * BeginCombination(int m, int n)
Start iterating over "m choose n" objects.
static vtkIdType ComputeGCD(vtkIdType m, vtkIdType n)
Compute the greatest common divisor (GCD) of two positive integers m and n.
Definition: vtkMath.h:1564
static void MultiplyMatrixWithVector(const MatrixT &M, const VectorT1 &X, VectorT2 &&Y)
Multiply matrix M with vector Y such that Y = M x X.
Definition: vtkMath.h:863
static double Norm2D(const double x[2])
Compute the norm of a 2-vector.
Definition: vtkMath.h:735
static double GaussianAmplitude(double variance, double distanceFromMean)
Compute the amplitude of a Gaussian function with mean=0 and specified variance.
static void XYZToRGB(double x, double y, double z, double *r, double *g, double *b)
Convert color from the CIE XYZ system to RGB.
static void GetPointAlongLine(double result[3], double p1[3], double p2[3], const double offset)
Get the coordinates of a point along a line defined by p1 and p2, at a specified offset relative to p...
Definition: vtkMath.h:1644
static void Subtract(const float a[3], const float b[3], float c[3])
Subtraction of two 3-vectors (float version).
Definition: vtkMath.h:368
static void LUSolve3x3(const double A[3][3], const int index[3], double x[3])
LU back substitution for a 3x3 matrix.
static vtkTypeBool SolveHomogeneousLeastSquares(int numberOfSamples, double **xt, int xOrder, double **mt)
Solves for the least squares best fit matrix for the homogeneous equation X'M' = 0'.
static void Outer2D(const float x[2], const float y[2], float A[2][2])
Outer product of two 2-vectors (float version).
Definition: vtkMath.h:700
static bool ProjectVector(const double a[3], const double b[3], double projection[3])
Compute the projection of vector a on vector b and return it in projection[3].
static vtkSmartPointer< vtkMathInternal > Internal
Definition: vtkMath.h:1657
static float Norm(const float *x, int n)
Compute the norm of n-vector.
static vtkTypeBool ExtentIsWithinOtherExtent(const int extent1[6], const int extent2[6])
Return true if first 3D extent is within second 3D extent Extent is x-min, x-max, y-min,...
static double GaussianAmplitude(double mean, double variance, double position)
Compute the amplitude of a Gaussian function with specified mean and variance.
static void Add(const double a[3], const double b[3], double c[3])
Addition of two 3-vectors (double version).
Definition: vtkMath.h:343
static void RGBToHSV(float r, float g, float b, float *h, float *s, float *v)
Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).
static float Norm(const float v[3])
Compute the norm of 3-vector (float version).
Definition: vtkMath.h:547
static ReturnTypeT Dot(const TupleRangeT1 &a, const TupleRangeT2 &b)
Compute dot product between two points p1 and p2.
Definition: vtkMath.h:483
static vtkTypeBool Jacobi(double **a, double *w, double **v)
Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix.
static void XYZToLab(const double xyz[3], double lab[3])
Convert Color from the CIE XYZ system to CIE-L*ab.
Definition: vtkMath.h:1330
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkTypeInt64 Factorial(int N)
Compute N factorial, N! = N*(N-1) * (N-2)...*3*2*1.
static vtkTypeInt64 Binomial(int m, int n)
The number of combinations of n objects from a pool of m objects (m>n).
static double Random()
Generate pseudo-random numbers distributed according to the uniform distribution between 0....
static void LinearSolve(const MatrixT &M, const VectorT1 &x, VectorT2 &y)
This method solves linear systems M * x = y.
Definition: vtkMath.h:940
static void Identity3x3(float A[3][3])
Set A to the identity matrix.
static void SingularValueDecomposition3x3(const float A[3][3], float U[3][3], float w[3], float VT[3][3])
Perform singular value decomposition on a 3x3 matrix.
static double Nan()
Special IEEE-754 number used to represent Not-A-Number (Nan).
static void Perpendiculars(const float v1[3], float v2[3], float v3[3], double theta)
Given a unit vector v1, find two unit vectors v2 and v3 such that v1 cross v2 = v3 (i....
static double Gaussian(double mean, double std)
Generate pseudo-random numbers distributed according to the Gaussian distribution with mean mean and ...
static bool IsFinite(double x)
Test if a number has finite value i.e.
static void LUSolveLinearSystem(double **A, int *index, double *x, int size)
Solve linear equations Ax = b using LU decomposition A = LU where L is lower triangular matrix and U ...
static double EstimateMatrixCondition(const double *const *A, int size)
Estimate the condition number of a LU factored matrix.
static void LUFactor3x3(float A[3][3], int index[3])
LU Factorization of a 3x3 matrix.
static void FreeCombination(int *combination)
Free the "iterator" array created by vtkMath::BeginCombination.
static double Random(double min, double max)
Generate pseudo-random numbers distributed according to the uniform distribution between min and max.
static void TensorFromSymmetricTensor(const T1 symmTensor[6], T2 tensor[9])
Convert a 6-Component symmetric tensor into a 9-Component tensor, no allocation performed.
static void LabToXYZ(const double lab[3], double xyz[3])
Convert color from the CIE-L*ab system to CIE XYZ.
Definition: vtkMath.h:1319
static double Solve3PointCircle(const double p1[3], const double p2[3], const double p3[3], double center[3])
In Euclidean space, there is a unique circle passing through any given three non-collinear points P1,...
static vtkTypeBool PointIsWithinBounds(const double point[3], const double bounds[6], const double delta[3])
Return true if point is within the given 3D bounds Bounds is x-min, x-max, y-min, y-max,...
static float Dot(const float a[3], const float b[3])
Dot product of two 3-vectors (float version).
Definition: vtkMath.h:451
static void Diagonalize3x3(const float A[3][3], float w[3], float V[3][3])
Diagonalize a symmetric 3x3 matrix and return the eigenvalues in w and the eigenvectors in the column...
static void LabToXYZ(double L, double a, double b, double *x, double *y, double *z)
Convert color from the CIE-L*ab system to CIE XYZ.
static vtkMatrixUtilities::ScalarTypeExtractor< MatrixT >::value_type Determinant(const MatrixT &M)
Computes the determinant of input square SizeT x SizeT matrix M.
Definition: vtkMath.h:897
static vtkTypeBool GetAdjustedScalarRange(vtkDataArray *array, int comp, double range[2])
Get a vtkDataArray's scalar range for a given component.
static bool ProjectVector(const float a[3], const float b[3], float projection[3])
Compute the projection of vector a on vector b and return it in projection[3].
static void MultiplyScalar2D(float a[2], float s)
Multiplies a 2-vector by a scalar (float version).
Definition: vtkMath.h:416
static void HSVToRGB(const float hsv[3], float rgb[3])
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
Definition: vtkMath.h:1303
static void Assign(const double a[3], double b[3])
Assign values to a 3-vector (double version).
Definition: vtkMath.h:327
static double Determinant2x2(const double c1[2], const double c2[2])
Calculate the determinant of a 2x2 matrix: | a b | | c d |.
Definition: vtkMath.h:762
static T Max(const T &a, const T &b)
Returns the maximum of the two arguments provided.
Definition: vtkMath.h:1734
static void Outer2D(const double x[2], const double y[2], double A[2][2])
Outer product of two 2-vectors (double version).
Definition: vtkMath.h:714
static void RandomSeed(int s)
Initialize seed value.
static double NegInf()
Special IEEE-754 number used to represent negative infinity.
static void MultiplyScalar2D(double a[2], double s)
Multiplies a 2-vector by a scalar (double version).
Definition: vtkMath.h:440
static void LabToRGB(double L, double a, double b, double *red, double *green, double *blue)
Convert color from the CIE-L*ab system to RGB.
static double Gaussian()
Generate pseudo-random numbers distributed according to the standard normal distribution.
static int Ceil(double x)
Rounds a double to the nearest integer not less than itself.
Definition: vtkMath.h:1719
static void HSVToRGB(const double hsv[3], double rgb[3])
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
Definition: vtkMath.h:1308
~vtkMath() override=default
static ScalarT Dot(const VectorT1 &x, const VectorT2 &y)
Computes the dot product between 2 vectors x and y.
Definition: vtkMath.h:874
static double Inf()
Special IEEE-754 number used to represent positive infinity.
static vtkMath * New()
static vtkTypeBool Jacobi(float **a, float *w, float **v)
Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix.
static int PlaneIntersectsAABB(const double bounds[6], const double normal[3], const double point[3])
Implements Plane / Axis-Aligned Bounding-Box intersection as described in Graphics Gems IV,...
static void RGBToXYZ(const double rgb[3], double xyz[3])
Convert color from the RGB system to CIE XYZ.
Definition: vtkMath.h:1352
static void QuaternionToMatrix3x3(const float quat[4], float A[3][3])
Convert a quaternion to a 3x3 rotation matrix.
Definition: vtkMath.h:2029
static int NearestPowerOfTwo(int x)
Compute the nearest power of two that is not less than x.
Definition: vtkMath.h:1696
static void HSVToRGB(double h, double s, double v, double *r, double *g, double *b)
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
static void SingularValueDecomposition3x3(const double A[3][3], double U[3][3], double w[3], double VT[3][3])
Perform singular value decomposition on a 3x3 matrix.
static double SignedAngleBetweenVectors(const double v1[3], const double v2[3], const double vn[3])
Compute signed angle in radians between two vectors with regard to a third orthogonal vector.
static float Normalize2D(float v[2])
Normalize (in place) a 2-vector.
Definition: vtkMath.h:1768
static void Invert3x3(const double A[3][3], double AI[3][3])
Invert a 3x3 matrix.
static void HSVToRGB(float h, float s, float v, float *r, float *g, float *b)
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
static void MultiplyQuaternion(const double q1[4], const double q2[4], double q[4])
Multiply two quaternions.
static void Multiply3x3(const double A[3][3], const double v[3], double u[3])
Multiply a vector by a 3x3 matrix.
static void Outer(const double a[3], const double b[3], double c[3][3])
Outer product of two 3-vectors (double version).
Definition: vtkMath.h:505
static vtkTypeBool InvertMatrix(double **A, double **AI, int size, int *tmp1Size, double *tmp2Size)
Thread safe version of InvertMatrix method.
static vtkTypeBool InvertMatrix(double **A, double **AI, int size)
Invert input square matrix A into matrix AI.
static void LUSolve3x3(const float A[3][3], const int index[3], float x[3])
LU back substitution for a 3x3 matrix.
static int GetSeed()
Return the current seed used by the random number generator.
static void Assign(const VectorT1 &a, VectorT2 &&b)
Assign values to a 3-vector (templated version).
Definition: vtkMath.h:317
static float RadiansFromDegrees(float degrees)
Convert degrees into radians.
Definition: vtkMath.h:1665
static void Convolve1D(Iter1 beginSample, Iter1 endSample, Iter2 beginKernel, Iter2 endKernel, Iter3 beginOut, Iter3 endOut, ConvolutionMode mode=ConvolutionMode::FULL)
Compute the convolution of a sampled 1D signal by a given kernel.
Definition: vtkMath.h:1599
static void RotateVectorByWXYZ(const double v[3], const double q[4], double r[3])
rotate a vector by WXYZ using // https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula
static void Add(const float a[3], const float b[3], float c[3])
Addition of two 3-vectors (float version).
Definition: vtkMath.h:332
static int CeilLog2(vtkTypeUInt64 x)
Gives the exponent of the lowest power of two not less than x.
static vtkTypeBool AreBoundsInitialized(const double bounds[6])
Are the bounds initialized?
Definition: vtkMath.h:1403
static bool ProjectVector2D(const double a[2], const double b[2], double projection[2])
Compute the projection of 2D vector a on 2D vector b and returns the result in projection[2].
static vtkTypeBool JacobiN(float **a, int n, float *w, float **v)
JacobiN iteration for the solution of eigenvectors/eigenvalues of a nxn real symmetric matrix.
static int NextCombination(int m, int n, int *combination)
Given m, n, and a valid combination of n integers in the range [0,m[, this function alters the intege...
static constexpr double Pi()
A mathematical constant.
Definition: vtkMath.h:97
static void Multiply3x3(const float A[3][3], const float v[3], float u[3])
Multiply a vector by a 3x3 matrix.
static void Subtract(const double a[3], const double b[3], double c[3])
Subtraction of two 3-vectors (double version).
Definition: vtkMath.h:379
static void Matrix3x3ToQuaternion(const float A[3][3], float quat[4])
Convert a 3x3 matrix into a quaternion.
Definition: vtkMath.h:2105
static void Orthogonalize3x3(const double A[3][3], double B[3][3])
Orthogonalize a 3x3 matrix and put the result in B.
static void XYZToRGB(const double xyz[3], double rgb[3])
Convert color from the CIE XYZ system to RGB.
Definition: vtkMath.h:1341
static double ClampAndNormalizeValue(double value, const double range[2])
Clamp a value against a range and then normalize it between 0 and 1.
Definition: vtkMath.h:1935
static void MultiplyScalar(double a[3], double s)
Multiplies a 3-vector by a scalar (double version).
Definition: vtkMath.h:428
static double Dot2D(const double x[2], const double y[2])
Dot product of two 2-vectors.
Definition: vtkMath.h:695
static void LinearSolve3x3(const float A[3][3], const float x[3], float y[3])
Solve Ay = x for y and place the result in y.
static void MultiplyMatrix(const MatrixT1 &M1, const MatrixT2 &M2, MatrixT3 &&M3)
Multiply matrices such that M3 = M1 x M2.
Definition: vtkMath.h:836
static vtkTypeBool IsNan(double x)
Test if a number is equal to the special floating point value Not-A-Number (Nan).
static void Diagonalize3x3(const double A[3][3], double w[3], double V[3][3])
Diagonalize a symmetric 3x3 matrix and return the eigenvalues in w and the eigenvectors in the column...
static void RGBToLab(const double rgb[3], double lab[3])
Convert color from the RGB system to CIE-L*ab.
Definition: vtkMath.h:1366
static int Floor(double x)
Rounds a double to the nearest integer not greater than itself.
Definition: vtkMath.h:1710
static void RotateVectorByNormalizedQuaternion(const double v[3], const double q[4], double r[3])
rotate a vector by a normalized quaternion using // https://en.wikipedia.org/wiki/Rodrigues%27_rotati...
static void Subtract(const VectorT1 &a, const VectorT2 &b, VectorT3 &&c)
Subtraction of two 3-vectors (templated version).
Definition: vtkMath.h:393
static vtkTypeBool BoundsIsWithinOtherBounds(const double bounds1[6], const double bounds2[6], const double delta[3])
Return true if first 3D bounds is within the second 3D bounds Bounds is x-min, x-max,...
static double Determinant2x2(double a, double b, double c, double d)
Calculate the determinant of a 2x2 matrix: | a b | | c d |.
Definition: vtkMath.h:761
static void RGBToHSV(const double rgb[3], double hsv[3])
Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).
Definition: vtkMath.h:1288
static vtkTypeBool JacobiN(double **a, int n, double *w, double **v)
JacobiN iteration for the solution of eigenvectors/eigenvalues of a nxn real symmetric matrix.
static double AngleBetweenVectors(const double v1[3], const double v2[3])
Compute angle in radians between two vectors.
static void MultiplyMatrix(const double *const *A, const double *const *B, unsigned int rowA, unsigned int colA, unsigned int rowB, unsigned int colB, double **C)
General matrix multiplication.
static float DegreesFromRadians(float radians)
Convert radians into degrees.
Definition: vtkMath.h:1677
static float Determinant2x2(const float c1[2], const float c2[2])
Compute determinant of 2x2 matrix.
Definition: vtkMath.h:752
static int Round(double f)
Definition: vtkMath.h:120
static vtkTypeBool IsInf(double x)
Test if a number is equal to the special floating point value infinity.
static double GaussianWeight(double mean, double variance, double position)
Compute the amplitude of an unnormalized Gaussian function with specified mean and variance.
static void UninitializeBounds(double bounds[6])
Set the bounds to an uninitialized state.
Definition: vtkMath.h:1388
vtkMath()=default
static void RGBToHSV(double r, double g, double b, double *h, double *s, double *v)
Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).
static void Outer(const float a[3], const float b[3], float c[3][3])
Outer product of two 3-vectors (float version).
Definition: vtkMath.h:491
static double Norm(const double v[3])
Compute the norm of 3-vector (double version).
Definition: vtkMath.h:552
static void RoundDoubleToIntegralIfNecessary(double val, OutT *ret)
Round a double to type OutT if OutT is integral, otherwise simply clamp the value to the output range...
Definition: vtkMath.h:128
static void RotateVectorByWXYZ(const float v[3], const float q[4], float r[3])
rotate a vector by WXYZ using // https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula
static bool IsPowerOfTwo(vtkTypeUInt64 x)
Returns true if integer is a power of two.
Definition: vtkMath.h:1689
static void Invert3x3(const float A[3][3], float AI[3][3])
Invert a 3x3 matrix.
static float Normalize(float v[3])
Normalize (in place) a 3-vector.
Definition: vtkMath.h:1740
static void Transpose3x3(const double A[3][3], double AT[3][3])
Transpose a 3x3 matrix.
static ReturnTypeT SquaredNorm(const TupleRangeT &v)
Compute the squared norm of a 3-vector.
Definition: vtkMath.h:567
static double Determinant3x3(const float A[3][3])
Return the determinant of a 3x3 matrix.
Definition: vtkMath.h:1885
static float Dot2D(const float x[2], const float y[2])
Dot product of two 2-vectors.
Definition: vtkMath.h:690
ConvolutionMode
Support the convolution operations.
Definition: vtkMath.h:1570
static void RotateVectorByNormalizedQuaternion(const float v[3], const float q[4], float r[3])
rotate a vector by a normalized quaternion using // https://en.wikipedia.org/wiki/Rodrigues%27_rotati...
static ScalarT Dot(const VectorT1 &x, const MatrixT &M, const VectorT2 &y)
Computes the dot product x^T M y, where x and y are vectors and M is a metric matrix.
Definition: vtkMath.h:961
static void RGBToHSV(const float rgb[3], float hsv[3])
Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).
Definition: vtkMath.h:1283
static void Add(VectorT1 &&a, VectorT2 &&b, VectorT3 &c)
Addition of two 3-vectors (double version).
Definition: vtkMath.h:357
static void Orthogonalize3x3(const float A[3][3], float B[3][3])
Orthogonalize a 3x3 matrix and put the result in B.
static bool ProjectVector2D(const float a[2], const float b[2], float projection[2])
Compute the projection of 2D vector a on 2D vector b and returns the result in projection[2].
static vtkTypeBool SolveLinearSystemGEPP2x2(double a00, double a01, double a10, double a11, double b0, double b1, double &x0, double &x1)
Solve linear equation Ax = b using Gaussian Elimination with Partial Pivoting for a 2x2 system.
static vtkTypeBool SolveLinearSystem(double **A, double *x, int size)
Solve linear equations Ax = b using Crout's method.
static void LabToRGB(const double lab[3], double rgb[3])
Convert color from the CIE-L*ab system to RGB.
Definition: vtkMath.h:1377
static float Norm2D(const float x[2])
Compute the norm of a 2-vector.
Definition: vtkMath.h:729
static vtkTypeBool LUFactorLinearSystem(double **A, int *index, int size, double *tmpSize)
Thread safe version of LUFactorLinearSystem method.
static void LinearSolve3x3(const double A[3][3], const double x[3], double y[3])
Solve Ay = x for y and place the result in y.
static void XYZToLab(double x, double y, double z, double *L, double *a, double *b)
Convert Color from the CIE XYZ system to CIE-L*ab.
static void InvertMatrix(const MatrixT1 &M1, MatrixT2 &&M2)
Computes the inverse of input matrix M1 into M2.
Definition: vtkMath.h:920
static void MultiplyScalar(float a[3], float s)
Multiplies a 3-vector by a scalar (float version).
Definition: vtkMath.h:404
static T Min(const T &a, const T &b)
Returns the minimum of the two arguments provided.
Definition: vtkMath.h:1727
static void Cross(VectorT1 &&a, VectorT2 &&b, VectorT3 &c)
Cross product of two 3-vectors.
Definition: vtkMath.h:1841
static void Perpendiculars(const double v1[3], double v2[3], double v3[3], double theta)
Given a unit vector v1, find two unit vectors v2 and v3 such that v1 cross v2 = v3 (i....
static T ClampValue(const T &value, const T &min, const T &max)
Clamp some value against a range, return the result.
Definition: vtkMath.h:1898
static vtkTypeBool SolveLeastSquares(int numberOfSamples, double **xt, int xOrder, double **yt, int yOrder, double **mt, int checkHomogeneous=1)
Solves for the least squares best fit matrix for the equation X'M' = Y'.
static void Identity3x3(double A[3][3])
Set A to the identity matrix.
static void LUFactor3x3(double A[3][3], int index[3])
LU Factorization of a 3x3 matrix.
static vtkTypeBool LUFactorLinearSystem(double **A, int *index, int size)
Factor linear equations Ax = b using LU decomposition into the form A = LU where L is a unit lower tr...
static void RGBToLab(double red, double green, double blue, double *L, double *a, double *b)
Convert color from the RGB system to CIE-L*ab.
static void MultiplyQuaternion(const float q1[4], const float q2[4], float q[4])
Multiply two quaternions.
static double GaussianWeight(double variance, double distanceFromMean)
Compute the amplitude of an unnormalized Gaussian function with mean=0 and specified variance.
static void ClampValues(const double *values, int nb_values, const double range[2], double *clamped_values)
Clamp some values against a range The method without 'clamped_values' will perform in-place clamping.
static void Transpose3x3(const float A[3][3], float AT[3][3])
Transpose a 3x3 matrix.
static void ClampValues(double *values, int nb_values, const double range[2])
Clamp some values against a range The method without 'clamped_values' will perform in-place clamping.
static int QuadraticRoot(double a, double b, double c, double min, double max, double *u)
find roots of ax^2+bx+c=0 in the interval min,max.
Matrix wrapping class.
Park and Miller Sequence of pseudo random numbers.
abstract base class for most VTK objects
Definition: vtkObject.h:61
represent and manipulate 3D points
Definition: vtkPoints.h:38
Computes the portion of a dataset which is inside a selection.
@ point
Definition: vtkX3D.h:236
@ mode
Definition: vtkX3D.h:247
@ value
Definition: vtkX3D.h:220
@ scale
Definition: vtkX3D.h:229
@ range
Definition: vtkX3D.h:238
@ center
Definition: vtkX3D.h:230
@ type
Definition: vtkX3D.h:516
@ position
Definition: vtkX3D.h:261
@ size
Definition: vtkX3D.h:253
@ index
Definition: vtkX3D.h:246
@ offset
Definition: vtkX3D.h:438
void RoundDoubleToIntegralIfNecessary(double val, OutT *ret)
Definition: vtkMath.h:2129
detail::ScalarTypeExtractor< std::is_array< DerefContainer >::value||std::is_pointer< DerefContainer >::value, ContainerT >::value_type value_type
Template defining traits of native types used by VTK.
Definition: vtkTypeTraits.h:23
int vtkTypeBool
Definition: vtkABI.h:64
double vtkDeterminant3x3(const T A[3][3])
Definition: vtkMath.h:1878
int vtkIdType
Definition: vtkType.h:315
#define max(a, b)