VTK  9.0.20201030
vtkMath.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMath.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================
15  Copyright 2011 Sandia Corporation.
16  Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
17  license for use of this work by or on behalf of the
18  U.S. Government. Redistribution and use in source and binary forms, with
19  or without modification, are permitted provided that this Notice and any
20  statement of authorship are reproduced on all copies.
21 
22  Contact: pppebay@sandia.gov,dcthomp@sandia.gov
23 
24 =========================================================================*/
39 #ifndef vtkMath_h
40 #define vtkMath_h
41 
42 #include "vtkCommonCoreModule.h" // For export macro
43 #include "vtkMathPrivate.hxx" // For Matrix meta-class helpers
44 #include "vtkMatrixUtilities.h" // For Matrix wrapping / mapping
45 #include "vtkObject.h"
46 #include "vtkSmartPointer.h" // For vtkSmartPointer.
47 #include "vtkTypeTraits.h" // For type traits
48 
49 #include "vtkMathConfigure.h" // For <cmath> and VTK_HAS_ISNAN etc.
50 
51 #include <algorithm> // for std::clamp
52 #include <cassert> // assert() in inline implementations.
53 
54 #ifndef DBL_MIN
55 #define VTK_DBL_MIN 2.2250738585072014e-308
56 #else // DBL_MIN
57 #define VTK_DBL_MIN DBL_MIN
58 #endif // DBL_MIN
59 
60 #ifndef DBL_EPSILON
61 #define VTK_DBL_EPSILON 2.2204460492503131e-16
62 #else // DBL_EPSILON
63 #define VTK_DBL_EPSILON DBL_EPSILON
64 #endif // DBL_EPSILON
65 
66 #ifndef VTK_DBL_EPSILON
67 #ifndef DBL_EPSILON
68 #define VTK_DBL_EPSILON 2.2204460492503131e-16
69 #else // DBL_EPSILON
70 #define VTK_DBL_EPSILON DBL_EPSILON
71 #endif // DBL_EPSILON
72 #endif // VTK_DBL_EPSILON
73 
74 class vtkDataArray;
75 class vtkPoints;
76 class vtkMathInternal;
79 
80 namespace vtk_detail
81 {
82 // forward declaration
83 template <typename OutT>
84 void RoundDoubleToIntegralIfNecessary(double val, OutT* ret);
85 } // end namespace vtk_detail
86 
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 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 
315  static void Assign(const double a[3], double b[3])
316  {
317  b[0] = a[0];
318  b[1] = a[1];
319  b[2] = a[2];
320  }
321 
325  static void Add(const float a[3], const float b[3], float c[3])
326  {
327  for (int i = 0; i < 3; ++i)
328  {
329  c[i] = a[i] + b[i];
330  }
331  }
332 
336  static void Add(const double a[3], const double b[3], double c[3])
337  {
338  for (int i = 0; i < 3; ++i)
339  {
340  c[i] = a[i] + b[i];
341  }
342  }
343 
347  static void Subtract(const float a[3], const float b[3], float c[3])
348  {
349  for (int i = 0; i < 3; ++i)
350  {
351  c[i] = a[i] - b[i];
352  }
353  }
354 
358  static void Subtract(const double a[3], const double b[3], double c[3])
359  {
360  for (int i = 0; i < 3; ++i)
361  {
362  c[i] = a[i] - b[i];
363  }
364  }
365 
370  static void MultiplyScalar(float a[3], float s)
371  {
372  for (int i = 0; i < 3; ++i)
373  {
374  a[i] *= s;
375  }
376  }
377 
382  static void MultiplyScalar2D(float a[2], float s)
383  {
384  for (int i = 0; i < 2; ++i)
385  {
386  a[i] *= s;
387  }
388  }
389 
394  static void MultiplyScalar(double a[3], double s)
395  {
396  for (int i = 0; i < 3; ++i)
397  {
398  a[i] *= s;
399  }
400  }
401 
406  static void MultiplyScalar2D(double a[2], double s)
407  {
408  for (int i = 0; i < 2; ++i)
409  {
410  a[i] *= s;
411  }
412  }
413 
417  static float Dot(const float a[3], const float b[3])
418  {
419  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
420  }
421 
425  static double Dot(const double a[3], const double b[3])
426  {
427  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
428  }
429 
445  template <typename ReturnTypeT = double, typename TupleRangeT1, typename TupleRangeT2,
446  typename EnableT = typename std::conditional<!std::is_pointer<TupleRangeT1>::value &&
448  TupleRangeT1, TupleRangeT2>::type::value_type>
449  static ReturnTypeT Dot(const TupleRangeT1& a, const TupleRangeT2& b)
450  {
451  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
452  }
453 
457  static void Outer(const float a[3], const float b[3], float c[3][3])
458  {
459  for (int i = 0; i < 3; ++i)
460  {
461  for (int j = 0; j < 3; ++j)
462  {
463  c[i][j] = a[i] * b[j];
464  }
465  }
466  }
467 
471  static void Outer(const double a[3], const double b[3], double c[3][3])
472  {
473  for (int i = 0; i < 3; ++i)
474  {
475  for (int j = 0; j < 3; ++j)
476  {
477  c[i][j] = a[i] * b[j];
478  }
479  }
480  }
481 
486  static void Cross(const float a[3], const float b[3], float c[3]);
487 
492  static void Cross(const double a[3], const double b[3], double c[3]);
493 
495 
498  static float Norm(const float* x, int n);
499  static double Norm(const double* x, int n);
501 
505  static float Norm(const float v[3]) { return std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); }
506 
510  static double Norm(const double v[3])
511  {
512  return std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
513  }
514 
524  template <typename ReturnTypeT = double, typename TupleRangeT>
525  static ReturnTypeT SquaredNorm(const TupleRangeT& v)
526  {
527  return v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
528  }
529 
534  static float Normalize(float v[3]);
535 
540  static double Normalize(double v[3]);
541 
543 
550  static void Perpendiculars(const double v1[3], double v2[3], double v3[3], double theta);
551  static void Perpendiculars(const float v1[3], float v2[3], float v3[3], double theta);
553 
555 
560  static bool ProjectVector(const float a[3], const float b[3], float projection[3]);
561  static bool ProjectVector(const double a[3], const double b[3], double projection[3]);
563 
565 
571  static bool ProjectVector2D(const float a[2], const float b[2], float projection[2]);
572  static bool ProjectVector2D(const double a[2], const double b[2], double projection[2]);
574 
590  template <typename ReturnTypeT = double, typename TupleRangeT1, typename TupleRangeT2,
591  typename EnableT = typename std::conditional<!std::is_pointer<TupleRangeT1>::value &&
593  TupleRangeT1, TupleRangeT2>::type::value_type>
594  static ReturnTypeT Distance2BetweenPoints(const TupleRangeT1& p1, const TupleRangeT2& p2);
595 
600  static float Distance2BetweenPoints(const float p1[3], const float p2[3]);
601 
606  static double Distance2BetweenPoints(const double p1[3], const double p2[3]);
607 
611  static double AngleBetweenVectors(const double v1[3], const double v2[3]);
612 
617  static double GaussianAmplitude(const double variance, const double distanceFromMean);
618 
623  static double GaussianAmplitude(const double mean, const double variance, const double position);
624 
630  static double GaussianWeight(const double variance, const double distanceFromMean);
631 
637  static double GaussianWeight(const double mean, const double variance, const double position);
638 
642  static float Dot2D(const float x[2], const float y[2]) { return x[0] * y[0] + x[1] * y[1]; }
643 
647  static double Dot2D(const double x[2], const double y[2]) { return x[0] * y[0] + x[1] * y[1]; }
648 
652  static void Outer2D(const float x[2], const float y[2], float A[2][2])
653  {
654  for (int i = 0; i < 2; ++i)
655  {
656  for (int j = 0; j < 2; ++j)
657  {
658  A[i][j] = x[i] * y[j];
659  }
660  }
661  }
662 
666  static void Outer2D(const double x[2], const double y[2], double A[2][2])
667  {
668  for (int i = 0; i < 2; ++i)
669  {
670  for (int j = 0; j < 2; ++j)
671  {
672  A[i][j] = x[i] * y[j];
673  }
674  }
675  }
676 
681  static float Norm2D(const float x[2]) { return std::sqrt(x[0] * x[0] + x[1] * x[1]); }
682 
687  static double Norm2D(const double x[2]) { return std::sqrt(x[0] * x[0] + x[1] * x[1]); }
688 
693  static float Normalize2D(float v[2]);
694 
699  static double Normalize2D(double v[2]);
700 
704  static float Determinant2x2(const float c1[2], const float c2[2])
705  {
706  return c1[0] * c2[1] - c2[0] * c1[1];
707  }
708 
710 
713  static double Determinant2x2(double a, double b, double c, double d) { return a * d - b * c; }
714  static double Determinant2x2(const double c1[2], const double c2[2])
715  {
716  return c1[0] * c2[1] - c2[0] * c1[1];
717  }
719 
721 
724  static void LUFactor3x3(float A[3][3], int index[3]);
725  static void LUFactor3x3(double A[3][3], int index[3]);
727 
729 
732  static void LUSolve3x3(const float A[3][3], const int index[3], float x[3]);
733  static void LUSolve3x3(const double A[3][3], const int index[3], double x[3]);
735 
737 
741  static void LinearSolve3x3(const float A[3][3], const float x[3], float y[3]);
742  static void LinearSolve3x3(const double A[3][3], const double x[3], double y[3]);
744 
746 
749  static void Multiply3x3(const float A[3][3], const float v[3], float u[3]);
750  static void Multiply3x3(const double A[3][3], const double v[3], double u[3]);
752 
754 
757  static void Multiply3x3(const float A[3][3], const float B[3][3], float C[3][3]);
758  static void Multiply3x3(const double A[3][3], const double B[3][3], double C[3][3]);
760 
784  template <int RowsT, int MidDimT, int ColsT,
785  class LayoutT1 = vtkMatrixUtilities::Layout::Identity,
786  class LayoutT2 = vtkMatrixUtilities::Layout::Identity, class MatrixT1, class MatrixT2,
787  class MatrixT3>
788  static void MultiplyMatrix(const MatrixT1& M1, const MatrixT2& M2, MatrixT3&& M3)
789  {
790  vtkMathPrivate::MultiplyMatrix<RowsT, MidDimT, ColsT, LayoutT1, LayoutT2>::Compute(M1, M2, M3);
791  }
792 
813  template <int RowsT, int ColsT, class LayoutT = vtkMatrixUtilities::Layout::Identity,
814  class MatrixT, class VectorT1, class VectorT2>
815  static void MultiplyMatrixWithVector(const MatrixT& M, const VectorT1& X, VectorT2&& Y)
816  {
817  vtkMathPrivate::MultiplyMatrix<RowsT, ColsT, 1, LayoutT>::Compute(M, X, Y);
818  }
819 
825  template <class ScalarT, int SizeT, class VectorT1, class VectorT2>
826  static ScalarT Dot(const VectorT1& x, const VectorT2& y)
827  {
828  return vtkMathPrivate::ContractRowWithCol<ScalarT, 1, SizeT, 1, 0, 0,
829  vtkMatrixUtilities::Layout::Identity, vtkMatrixUtilities::Layout::Transpose>::Compute(x, y);
830  }
831 
848  template <int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT>
850  const MatrixT& M)
851  {
852  return vtkMathPrivate::Determinant<SizeT, LayoutT>::Compute(M);
853  }
854 
870  template <int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT1,
871  class MatrixT2>
872  static void InvertMatrix(const MatrixT1& M1, MatrixT2&& M2)
873  {
874  vtkMathPrivate::InvertMatrix<SizeT, LayoutT>::Compute(M1, M2);
875  }
876 
890  template <int RowsT, int ColsT, class LayoutT = vtkMatrixUtilities::Layout::Identity,
891  class MatrixT, class VectorT1, class VectorT2>
892  static void LinearSolve(const MatrixT& M, const VectorT1& x, VectorT2& y)
893  {
894  vtkMathPrivate::LinearSolve<RowsT, ColsT, LayoutT>::Compute(M, x, y);
895  }
896 
911  template <class ScalarT, int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity,
912  class VectorT1, class MatrixT, class VectorT2>
913  static ScalarT Dot(const VectorT1& x, const MatrixT& M, const VectorT2& y)
914  {
915  ScalarT tmp[SizeT];
916  vtkMathPrivate::MultiplyMatrix<SizeT, SizeT, 1, LayoutT>::Compute(M, y, tmp);
917  return vtkMathPrivate::ContractRowWithCol<ScalarT, 1, SizeT, 1, 0, 0,
918  vtkMatrixUtilities::Layout::Identity, vtkMatrixUtilities::Layout::Transpose>::Compute(x, tmp);
919  }
920 
926  static void MultiplyMatrix(const double* const* A, const double* const* B, unsigned int rowA,
927  unsigned int colA, unsigned int rowB, unsigned int colB, double** C);
928 
930 
934  static void Transpose3x3(const float A[3][3], float AT[3][3]);
935  static void Transpose3x3(const double A[3][3], double AT[3][3]);
937 
939 
943  static void Invert3x3(const float A[3][3], float AI[3][3]);
944  static void Invert3x3(const double A[3][3], double AI[3][3]);
946 
948 
951  static void Identity3x3(float A[3][3]);
952  static void Identity3x3(double A[3][3]);
954 
956 
959  static double Determinant3x3(const float A[3][3]);
960  static double Determinant3x3(const double A[3][3]);
962 
966  static float Determinant3x3(const float c1[3], const float c2[3], const float c3[3]);
967 
971  static double Determinant3x3(const double c1[3], const double c2[3], const double c3[3]);
972 
979  static double Determinant3x3(double a1, double a2, double a3, double b1, double b2, double b3,
980  double c1, double c2, double c3);
981 
983 
990  static void QuaternionToMatrix3x3(const float quat[4], float A[3][3]);
991  static void QuaternionToMatrix3x3(const double quat[4], double A[3][3]);
993 
995 
1004  static void Matrix3x3ToQuaternion(const float A[3][3], float quat[4]);
1005  static void Matrix3x3ToQuaternion(const double A[3][3], double quat[4]);
1007 
1009 
1015  static void MultiplyQuaternion(const float q1[4], const float q2[4], float q[4]);
1016  static void MultiplyQuaternion(const double q1[4], const double q2[4], double q[4]);
1018 
1020 
1024  static void RotateVectorByNormalizedQuaternion(const float v[3], const float q[4], float r[3]);
1025  static void RotateVectorByNormalizedQuaternion(const double v[3], const double q[4], double r[3]);
1027 
1029 
1033  static void RotateVectorByWXYZ(const float v[3], const float q[4], float r[3]);
1034  static void RotateVectorByWXYZ(const double v[3], const double q[4], double r[3]);
1036 
1038 
1043  static void Orthogonalize3x3(const float A[3][3], float B[3][3]);
1044  static void Orthogonalize3x3(const double A[3][3], double B[3][3]);
1046 
1048 
1054  static void Diagonalize3x3(const float A[3][3], float w[3], float V[3][3]);
1055  static void Diagonalize3x3(const double A[3][3], double w[3], double V[3][3]);
1057 
1059 
1068  static void SingularValueDecomposition3x3(
1069  const float A[3][3], float U[3][3], float w[3], float VT[3][3]);
1070  static void SingularValueDecomposition3x3(
1071  const double A[3][3], double U[3][3], double w[3], double VT[3][3]);
1073 
1080  static vtkTypeBool SolveLinearSystem(double** A, double* x, int size);
1081 
1088  static vtkTypeBool InvertMatrix(double** A, double** AI, int size);
1089 
1095  static vtkTypeBool InvertMatrix(
1096  double** A, double** AI, int size, int* tmp1Size, double* tmp2Size);
1097 
1120  static vtkTypeBool LUFactorLinearSystem(double** A, int* index, int size);
1121 
1127  static vtkTypeBool LUFactorLinearSystem(double** A, int* index, int size, double* tmpSize);
1128 
1137  static void LUSolveLinearSystem(double** A, int* index, double* x, int size);
1138 
1147  static double EstimateMatrixCondition(const double* const* A, int size);
1148 
1150 
1158  static vtkTypeBool Jacobi(float** a, float* w, float** v);
1159  static vtkTypeBool Jacobi(double** a, double* w, double** v);
1161 
1163 
1172  static vtkTypeBool JacobiN(float** a, int n, float* w, float** v);
1173  static vtkTypeBool JacobiN(double** a, int n, double* w, double** v);
1175 
1189  static vtkTypeBool SolveHomogeneousLeastSquares(
1190  int numberOfSamples, double** xt, int xOrder, double** mt);
1191 
1206  static vtkTypeBool SolveLeastSquares(int numberOfSamples, double** xt, int xOrder, double** yt,
1207  int yOrder, double** mt, int checkHomogeneous = 1);
1208 
1210 
1217  static void RGBToHSV(const float rgb[3], float hsv[3])
1218  {
1219  RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
1220  }
1221  static void RGBToHSV(float r, float g, float b, float* h, float* s, float* v);
1222  static void RGBToHSV(const double rgb[3], double hsv[3])
1223  {
1224  RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
1225  }
1226  static void RGBToHSV(double r, double g, double b, double* h, double* s, double* v);
1228 
1230 
1237  static void HSVToRGB(const float hsv[3], float rgb[3])
1238  {
1239  HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
1240  }
1241  static void HSVToRGB(float h, float s, float v, float* r, float* g, float* b);
1242  static void HSVToRGB(const double hsv[3], double rgb[3])
1243  {
1244  HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
1245  }
1246  static void HSVToRGB(double h, double s, double v, double* r, double* g, double* b);
1248 
1250 
1253  static void LabToXYZ(const double lab[3], double xyz[3])
1254  {
1255  LabToXYZ(lab[0], lab[1], lab[2], xyz + 0, xyz + 1, xyz + 2);
1256  }
1257  static void LabToXYZ(double L, double a, double b, double* x, double* y, double* z);
1259 
1261 
1264  static void XYZToLab(const double xyz[3], double lab[3])
1265  {
1266  XYZToLab(xyz[0], xyz[1], xyz[2], lab + 0, lab + 1, lab + 2);
1267  }
1268  static void XYZToLab(double x, double y, double z, double* L, double* a, double* b);
1270 
1272 
1275  static void XYZToRGB(const double xyz[3], double rgb[3])
1276  {
1277  XYZToRGB(xyz[0], xyz[1], xyz[2], rgb + 0, rgb + 1, rgb + 2);
1278  }
1279  static void XYZToRGB(double x, double y, double z, double* r, double* g, double* b);
1281 
1283 
1286  static void RGBToXYZ(const double rgb[3], double xyz[3])
1287  {
1288  RGBToXYZ(rgb[0], rgb[1], rgb[2], xyz + 0, xyz + 1, xyz + 2);
1289  }
1290  static void RGBToXYZ(double r, double g, double b, double* x, double* y, double* z);
1292 
1294 
1300  static void RGBToLab(const double rgb[3], double lab[3])
1301  {
1302  RGBToLab(rgb[0], rgb[1], rgb[2], lab + 0, lab + 1, lab + 2);
1303  }
1304  static void RGBToLab(double red, double green, double blue, double* L, double* a, double* b);
1306 
1308 
1311  static void LabToRGB(const double lab[3], double rgb[3])
1312  {
1313  LabToRGB(lab[0], lab[1], lab[2], rgb + 0, rgb + 1, rgb + 2);
1314  }
1315  static void LabToRGB(double L, double a, double b, double* red, double* green, double* blue);
1317 
1319 
1322  static void UninitializeBounds(double bounds[6])
1323  {
1324  bounds[0] = 1.0;
1325  bounds[1] = -1.0;
1326  bounds[2] = 1.0;
1327  bounds[3] = -1.0;
1328  bounds[4] = 1.0;
1329  bounds[5] = -1.0;
1330  }
1332 
1334 
1337  static vtkTypeBool AreBoundsInitialized(const double bounds[6])
1338  {
1339  if (bounds[1] - bounds[0] < 0.0)
1340  {
1341  return 0;
1342  }
1343  return 1;
1344  }
1346 
1351  template <class T>
1352  static T ClampValue(const T& value, const T& min, const T& max);
1353 
1355 
1359  static void ClampValue(double* value, const double range[2]);
1360  static void ClampValue(double value, const double range[2], double* clamped_value);
1361  static void ClampValues(double* values, int nb_values, const double range[2]);
1362  static void ClampValues(
1363  const double* values, int nb_values, const double range[2], double* clamped_values);
1365 
1372  static double ClampAndNormalizeValue(double value, const double range[2]);
1373 
1378  template <class T1, class T2>
1379  static void TensorFromSymmetricTensor(const T1 symmTensor[6], T2 tensor[9]);
1380 
1386  template <class T>
1387  static void TensorFromSymmetricTensor(T tensor[9]);
1388 
1397  static int GetScalarTypeFittingRange(
1398  double range_min, double range_max, double scale = 1.0, double shift = 0.0);
1399 
1408  static vtkTypeBool GetAdjustedScalarRange(vtkDataArray* array, int comp, double range[2]);
1409 
1414  static vtkTypeBool ExtentIsWithinOtherExtent(const int extent1[6], const int extent2[6]);
1415 
1421  static vtkTypeBool BoundsIsWithinOtherBounds(
1422  const double bounds1[6], const double bounds2[6], const double delta[3]);
1423 
1429  static vtkTypeBool PointIsWithinBounds(
1430  const double point[3], const double bounds[6], const double delta[3]);
1431 
1441  static int PlaneIntersectsAABB(
1442  const double bounds[6], const double normal[3], const double point[3]);
1443 
1453  static double Solve3PointCircle(
1454  const double p1[3], const double p2[3], const double p3[3], double center[3]);
1455 
1459  static double Inf();
1460 
1464  static double NegInf();
1465 
1469  static double Nan();
1470 
1474  static vtkTypeBool IsInf(double x);
1475 
1479  static vtkTypeBool IsNan(double x);
1480 
1485  static bool IsFinite(double x);
1486 
1491  static int QuadraticRoot(double a, double b, double c, double min, double max, double* u);
1492 
1493 protected:
1494  vtkMath() = default;
1495  ~vtkMath() override = default;
1496 
1498 
1499 private:
1500  vtkMath(const vtkMath&) = delete;
1501  void operator=(const vtkMath&) = delete;
1502 };
1503 
1504 //----------------------------------------------------------------------------
1505 inline float vtkMath::RadiansFromDegrees(float x)
1506 {
1507  return x * 0.017453292f;
1508 }
1509 
1510 //----------------------------------------------------------------------------
1511 inline double vtkMath::RadiansFromDegrees(double x)
1512 {
1513  return x * 0.017453292519943295;
1514 }
1515 
1516 //----------------------------------------------------------------------------
1517 inline float vtkMath::DegreesFromRadians(float x)
1518 {
1519  return x * 57.2957795131f;
1520 }
1521 
1522 //----------------------------------------------------------------------------
1523 inline double vtkMath::DegreesFromRadians(double x)
1524 {
1525  return x * 57.29577951308232;
1526 }
1527 
1528 //----------------------------------------------------------------------------
1529 inline bool vtkMath::IsPowerOfTwo(vtkTypeUInt64 x)
1530 {
1531  return ((x != 0) & ((x & (x - 1)) == 0));
1532 }
1533 
1534 //----------------------------------------------------------------------------
1535 // Credit goes to Peter Hart and William Lewis on comp.lang.python 1997
1537 {
1538  unsigned int z = static_cast<unsigned int>(((x > 0) ? x - 1 : 0));
1539  z |= z >> 1;
1540  z |= z >> 2;
1541  z |= z >> 4;
1542  z |= z >> 8;
1543  z |= z >> 16;
1544  return static_cast<int>(z + 1);
1545 }
1546 
1547 //----------------------------------------------------------------------------
1548 // Modify the trunc() operation provided by static_cast<int>() to get floor(),
1549 // Note that in C++ conditions evaluate to values of 1 or 0 (true or false).
1550 inline int vtkMath::Floor(double x)
1551 {
1552  int i = static_cast<int>(x);
1553  return i - (i > x);
1554 }
1555 
1556 //----------------------------------------------------------------------------
1557 // Modify the trunc() operation provided by static_cast<int>() to get ceil(),
1558 // Note that in C++ conditions evaluate to values of 1 or 0 (true or false).
1559 inline int vtkMath::Ceil(double x)
1560 {
1561  int i = static_cast<int>(x);
1562  return i + (i < x);
1563 }
1564 
1565 //----------------------------------------------------------------------------
1566 template <class T>
1567 inline T vtkMath::Min(const T& a, const T& b)
1568 {
1569  return (b <= a ? b : a);
1570 }
1571 
1572 //----------------------------------------------------------------------------
1573 template <class T>
1574 inline T vtkMath::Max(const T& a, const T& b)
1575 {
1576  return (b > a ? b : a);
1577 }
1578 
1579 //----------------------------------------------------------------------------
1580 inline float vtkMath::Normalize(float v[3])
1581 {
1582  float den = vtkMath::Norm(v);
1583  if (den != 0.0)
1584  {
1585  for (int i = 0; i < 3; ++i)
1586  {
1587  v[i] /= den;
1588  }
1589  }
1590  return den;
1591 }
1592 
1593 //----------------------------------------------------------------------------
1594 inline double vtkMath::Normalize(double v[3])
1595 {
1596  double den = vtkMath::Norm(v);
1597  if (den != 0.0)
1598  {
1599  for (int i = 0; i < 3; ++i)
1600  {
1601  v[i] /= den;
1602  }
1603  }
1604  return den;
1605 }
1606 
1607 //----------------------------------------------------------------------------
1608 inline float vtkMath::Normalize2D(float v[3])
1609 {
1610  float den = vtkMath::Norm2D(v);
1611  if (den != 0.0)
1612  {
1613  for (int i = 0; i < 2; ++i)
1614  {
1615  v[i] /= den;
1616  }
1617  }
1618  return den;
1619 }
1620 
1621 //----------------------------------------------------------------------------
1622 inline double vtkMath::Normalize2D(double v[3])
1623 {
1624  double den = vtkMath::Norm2D(v);
1625  if (den != 0.0)
1626  {
1627  for (int i = 0; i < 2; ++i)
1628  {
1629  v[i] /= den;
1630  }
1631  }
1632  return den;
1633 }
1634 
1635 //----------------------------------------------------------------------------
1636 inline float vtkMath::Determinant3x3(const float c1[3], const float c2[3], const float c3[3])
1637 {
1638  return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1639  c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1640 }
1641 
1642 //----------------------------------------------------------------------------
1643 inline double vtkMath::Determinant3x3(const double c1[3], const double c2[3], const double c3[3])
1644 {
1645  return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1646  c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1647 }
1648 
1649 //----------------------------------------------------------------------------
1651  double a1, double a2, double a3, double b1, double b2, double b3, double c1, double c2, double c3)
1652 {
1653  return (a1 * vtkMath::Determinant2x2(b2, b3, c2, c3) -
1654  b1 * vtkMath::Determinant2x2(a2, a3, c2, c3) + c1 * vtkMath::Determinant2x2(a2, a3, b2, b3));
1655 }
1656 
1657 //----------------------------------------------------------------------------
1658 inline float vtkMath::Distance2BetweenPoints(const float p1[3], const float p2[3])
1659 {
1660  return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
1661  (p1[2] - p2[2]) * (p1[2] - p2[2]));
1662 }
1663 
1664 //----------------------------------------------------------------------------
1665 inline double vtkMath::Distance2BetweenPoints(const double p1[3], const double p2[3])
1666 {
1667  return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
1668  (p1[2] - p2[2]) * (p1[2] - p2[2]));
1669 }
1670 
1671 //----------------------------------------------------------------------------
1672 template <typename ReturnTypeT, typename TupleRangeT1, typename TupleRangeT2, typename EnableT>
1673 inline ReturnTypeT vtkMath::Distance2BetweenPoints(const TupleRangeT1& p1, const TupleRangeT2& p2)
1674 {
1675  return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
1676  (p1[2] - p2[2]) * (p1[2] - p2[2]));
1677 }
1678 
1679 //----------------------------------------------------------------------------
1680 // Cross product of two 3-vectors. Result (a x b) is stored in c[3].
1681 inline void vtkMath::Cross(const float a[3], const float b[3], float c[3])
1682 {
1683  float Cx = a[1] * b[2] - a[2] * b[1];
1684  float Cy = a[2] * b[0] - a[0] * b[2];
1685  float Cz = a[0] * b[1] - a[1] * b[0];
1686  c[0] = Cx;
1687  c[1] = Cy;
1688  c[2] = Cz;
1689 }
1690 
1691 //----------------------------------------------------------------------------
1692 // Cross product of two 3-vectors. Result (a x b) is stored in c[3].
1693 inline void vtkMath::Cross(const double a[3], const double b[3], double c[3])
1694 {
1695  double Cx = a[1] * b[2] - a[2] * b[1];
1696  double Cy = a[2] * b[0] - a[0] * b[2];
1697  double Cz = a[0] * b[1] - a[1] * b[0];
1698  c[0] = Cx;
1699  c[1] = Cy;
1700  c[2] = Cz;
1701 }
1702 
1703 //----------------------------------------------------------------------------
1704 template <class T>
1705 inline double vtkDeterminant3x3(const T A[3][3])
1706 {
1707  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] -
1708  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];
1709 }
1710 
1711 //----------------------------------------------------------------------------
1712 inline double vtkMath::Determinant3x3(const float A[3][3])
1713 {
1714  return vtkDeterminant3x3(A);
1715 }
1716 
1717 //----------------------------------------------------------------------------
1718 inline double vtkMath::Determinant3x3(const double A[3][3])
1719 {
1720  return vtkDeterminant3x3(A);
1721 }
1722 
1723 //----------------------------------------------------------------------------
1724 template <class T>
1725 inline T vtkMath::ClampValue(const T& value, const T& min, const T& max)
1726 {
1727  assert("pre: valid_range" && min <= max);
1728 
1729 #if __cplusplus >= 201703L
1730  return std::clamp(value, min, max);
1731 #else
1732  // compilers are good at optimizing the ternary operator,
1733  // use '<' since it is preferred by STL for custom types
1734  T v = (min < value ? value : min);
1735  return (v < max ? v : max);
1736 #endif
1737 }
1738 
1739 //----------------------------------------------------------------------------
1740 inline void vtkMath::ClampValue(double* value, const double range[2])
1741 {
1742  if (value && range)
1743  {
1744  assert("pre: valid_range" && range[0] <= range[1]);
1745 
1746  *value = vtkMath::ClampValue(*value, range[0], range[1]);
1747  }
1748 }
1749 
1750 //----------------------------------------------------------------------------
1751 inline void vtkMath::ClampValue(double value, const double range[2], double* clamped_value)
1752 {
1753  if (range && clamped_value)
1754  {
1755  assert("pre: valid_range" && range[0] <= range[1]);
1756 
1757  *clamped_value = vtkMath::ClampValue(value, range[0], range[1]);
1758  }
1759 }
1760 
1761 // ---------------------------------------------------------------------------
1762 inline double vtkMath::ClampAndNormalizeValue(double value, const double range[2])
1763 {
1764  assert("pre: valid_range" && range[0] <= range[1]);
1765 
1766  double result;
1767  if (range[0] == range[1])
1768  {
1769  result = 0.0;
1770  }
1771  else
1772  {
1773  // clamp
1774  result = vtkMath::ClampValue(value, range[0], range[1]);
1775 
1776  // normalize
1777  result = (result - range[0]) / (range[1] - range[0]);
1778  }
1779 
1780  assert("post: valid_result" && result >= 0.0 && result <= 1.0);
1781 
1782  return result;
1783 }
1784 
1785 //-----------------------------------------------------------------------------
1786 template <class T1, class T2>
1787 inline void vtkMath::TensorFromSymmetricTensor(const T1 symmTensor[9], T2 tensor[9])
1788 {
1789  for (int i = 0; i < 3; ++i)
1790  {
1791  tensor[4 * i] = symmTensor[i];
1792  }
1793  tensor[1] = tensor[3] = symmTensor[3];
1794  tensor[2] = tensor[6] = symmTensor[5];
1795  tensor[5] = tensor[7] = symmTensor[4];
1796 }
1797 
1798 //-----------------------------------------------------------------------------
1799 template <class T>
1800 inline void vtkMath::TensorFromSymmetricTensor(T tensor[9])
1801 {
1802  tensor[6] = tensor[5]; // XZ
1803  tensor[7] = tensor[4]; // YZ
1804  tensor[8] = tensor[2]; // ZZ
1805  tensor[4] = tensor[1]; // YY
1806  tensor[5] = tensor[7]; // YZ
1807  tensor[2] = tensor[6]; // XZ
1808  tensor[1] = tensor[3]; // XY
1809 }
1810 
1811 namespace vtk_detail
1812 {
1813 // Can't specialize templates inside a template class, so we move the impl here.
1814 template <typename OutT>
1815 void RoundDoubleToIntegralIfNecessary(double val, OutT* ret)
1816 { // OutT is integral -- clamp and round
1817  if (!vtkMath::IsNan(val))
1818  {
1819  double min = static_cast<double>(vtkTypeTraits<OutT>::Min());
1820  double max = static_cast<double>(vtkTypeTraits<OutT>::Max());
1821  val = vtkMath::ClampValue(val, min, max);
1822  *ret = static_cast<OutT>((val >= 0.0) ? (val + 0.5) : (val - 0.5));
1823  }
1824  else
1825  *ret = 0;
1826 }
1827 template <>
1828 inline void RoundDoubleToIntegralIfNecessary(double val, double* retVal)
1829 { // OutT is double: passthrough
1830  *retVal = val;
1831 }
1832 template <>
1833 inline void RoundDoubleToIntegralIfNecessary(double val, float* retVal)
1834 { // OutT is float -- just clamp (as doubles, then the cast to float is well-defined.)
1835  if (!vtkMath::IsNan(val))
1836  {
1837  double min = static_cast<double>(vtkTypeTraits<float>::Min());
1838  double max = static_cast<double>(vtkTypeTraits<float>::Max());
1839  val = vtkMath::ClampValue(val, min, max);
1840  *retVal = static_cast<float>(val);
1841  }
1842  else
1843  *retVal = val;
1844 }
1845 } // end namespace vtk_detail
1846 
1847 //-----------------------------------------------------------------------------
1848 #if defined(VTK_HAS_ISINF) || defined(VTK_HAS_STD_ISINF)
1849 #define VTK_MATH_ISINF_IS_INLINE
1850 inline vtkTypeBool vtkMath::IsInf(double x)
1851 {
1852 #if defined(VTK_HAS_STD_ISINF)
1853  return std::isinf(x);
1854 #else
1855  return (isinf(x) != 0); // Force conversion to bool
1856 #endif
1857 }
1858 #endif
1859 
1860 //-----------------------------------------------------------------------------
1861 #if defined(VTK_HAS_ISNAN) || defined(VTK_HAS_STD_ISNAN)
1862 #define VTK_MATH_ISNAN_IS_INLINE
1863 inline vtkTypeBool vtkMath::IsNan(double x)
1864 {
1865 #if defined(VTK_HAS_STD_ISNAN)
1866  return std::isnan(x);
1867 #else
1868  return (isnan(x) != 0); // Force conversion to bool
1869 #endif
1870 }
1871 #endif
1872 
1873 //-----------------------------------------------------------------------------
1874 #if defined(VTK_HAS_ISFINITE) || defined(VTK_HAS_STD_ISFINITE) || defined(VTK_HAS_FINITE)
1875 #define VTK_MATH_ISFINITE_IS_INLINE
1876 inline bool vtkMath::IsFinite(double x)
1877 {
1878 #if defined(VTK_HAS_STD_ISFINITE)
1879  return std::isfinite(x);
1880 #elif defined(VTK_HAS_ISFINITE)
1881  return (isfinite(x) != 0); // Force conversion to bool
1882 #else
1883  return (finite(x) != 0); // Force conversion to bool
1884 #endif
1885 }
1886 #endif
1887 
1888 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkMath::Ceil
static int Ceil(double x)
Rounds a double to the nearest integer not less than itself.
Definition: vtkMath.h:1559
vtkMath::RGBToLab
static void RGBToLab(const double rgb[3], double lab[3])
Convert color from the RGB system to CIE-L*ab.
Definition: vtkMath.h:1300
vtkMath::MultiplyScalar
static void MultiplyScalar(double a[3], double s)
Multiplies a 3-vector by a scalar (double version).
Definition: vtkMath.h:394
vtkMath::Norm
static float Norm(const float *x, int n)
Compute the norm of n-vector.
vtkMath::RGBToHSV
static void RGBToHSV(const double rgb[3], double hsv[3])
Definition: vtkMath.h:1222
vtkMath::Floor
static int Floor(double x)
Rounds a double to the nearest integer not greater than itself.
Definition: vtkMath.h:1550
vtkMath::Dot
static double Dot(const double a[3], const double b[3])
Dot product of two 3-vectors (double version).
Definition: vtkMath.h:425
vtkMinimalStandardRandomSequence
Park and Miller Sequence of pseudo random numbers.
Definition: vtkMinimalStandardRandomSequence.h:41
vtkMath::IsNan
static vtkTypeBool IsNan(double x)
Test if a number is equal to the special floating point value Not-A-Number (Nan).
vtkTypeTraits
Template defining traits of native types used by VTK.
Definition: vtkTypeTraits.h:30
vtkMath::NearestPowerOfTwo
static int NearestPowerOfTwo(int x)
Compute the nearest power of two that is not less than x.
Definition: vtkMath.h:1536
vtkMath::Normalize
static float Normalize(float v[3])
Normalize (in place) a 3-vector.
Definition: vtkMath.h:1580
vtkMath::Determinant2x2
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:713
vtkX3D::scale
Definition: vtkX3D.h:235
vtkMath::RGBToHSV
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:1217
vtkMath::IsInf
static vtkTypeBool IsInf(double x)
Test if a number is equal to the special floating point value infinity.
vtkMath::Dot
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:913
vtkX3D::value
Definition: vtkX3D.h:226
vtkMath::LinearSolve
static void LinearSolve(const MatrixT &M, const VectorT1 &x, VectorT2 &y)
This method solves linear systems M * x = y.
Definition: vtkMath.h:892
vtkMath::UninitializeBounds
static void UninitializeBounds(double bounds[6])
Set the bounds to an uninitialized state.
Definition: vtkMath.h:1322
vtk_detail
Definition: vtkMath.h:80
vtkMath::Dot2D
static float Dot2D(const float x[2], const float y[2])
Dot product of two 2-vectors.
Definition: vtkMath.h:642
vtkMath::DegreesFromRadians
static float DegreesFromRadians(float radians)
Convert radians into degrees.
Definition: vtkMath.h:1517
vtkMath::Max
static T Max(const T &a, const T &b)
Returns the maximum of the two arguments provided.
Definition: vtkMath.h:1574
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkMath::Norm2D
static double Norm2D(const double x[2])
Compute the norm of a 2-vector.
Definition: vtkMath.h:687
vtkMath::InvertMatrix
static void InvertMatrix(const MatrixT1 &M1, MatrixT2 &&M2)
Computes the inverse of input matrix M1 into M2.
Definition: vtkMath.h:872
vtkMath::HSVToRGB
static void HSVToRGB(const double hsv[3], double rgb[3])
Definition: vtkMath.h:1242
vtkMath::RadiansFromDegrees
static float RadiansFromDegrees(float degrees)
Convert degrees into radians.
Definition: vtkMath.h:1505
vtkX3D::range
Definition: vtkX3D.h:244
vtkMath::XYZToRGB
static void XYZToRGB(const double xyz[3], double rgb[3])
Convert color from the CIE XYZ system to RGB.
Definition: vtkMath.h:1275
vtkSmartPointer< vtkMathInternal >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkMath::Determinant3x3
static double Determinant3x3(const float A[3][3])
Return the determinant of a 3x3 matrix.
Definition: vtkMath.h:1712
vtkMath::MultiplyScalar
static void MultiplyScalar(float a[3], float s)
Multiplies a 3-vector by a scalar (float version).
Definition: vtkMath.h:370
vtkX3D::center
Definition: vtkX3D.h:236
vtkMath::Subtract
static void Subtract(const float a[3], const float b[3], float c[3])
Subtraction of two 3-vectors (float version).
Definition: vtkMath.h:347
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkMath::SquaredNorm
static ReturnTypeT SquaredNorm(const TupleRangeT &v)
Compute the squared norm of a 3-vector.
Definition: vtkMath.h:525
vtkMath::LabToRGB
static void LabToRGB(const double lab[3], double rgb[3])
Convert color from the CIE-L*ab system to RGB.
Definition: vtkMath.h:1311
vtkMath::Norm
static float Norm(const float v[3])
Compute the norm of 3-vector (float version).
Definition: vtkMath.h:505
vtk_detail::RoundDoubleToIntegralIfNecessary
void RoundDoubleToIntegralIfNecessary(double val, OutT *ret)
Definition: vtkMath.h:1815
vtkMath::Dot
static ReturnTypeT Dot(const TupleRangeT1 &a, const TupleRangeT2 &b)
Compute dot product between two points p1 and p2.
Definition: vtkMath.h:449
vtkMath::ClampAndNormalizeValue
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:1762
vtkMatrixUtilities.h
vtkMath::HSVToRGB
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:1237
vtkMath::Dot
static ScalarT Dot(const VectorT1 &x, const VectorT2 &y)
Computes the dot product between 2 vectors x and y.
Definition: vtkMath.h:826
vtkMath::Subtract
static void Subtract(const double a[3], const double b[3], double c[3])
Subtraction of two 3-vectors (double version).
Definition: vtkMath.h:358
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkMath::LabToXYZ
static void LabToXYZ(const double lab[3], double xyz[3])
Convert color from the CIE-L*ab system to CIE XYZ.
Definition: vtkMath.h:1253
vtkMath::MultiplyScalar2D
static void MultiplyScalar2D(float a[2], float s)
Multiplies a 2-vector by a scalar (float version).
Definition: vtkMath.h:382
vtkMath::Add
static void Add(const double a[3], const double b[3], double c[3])
Addition of two 3-vectors (double version).
Definition: vtkMath.h:336
vtkMath::Outer
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:471
detail::isnan
bool isnan(T x)
Definition: vtkGenericDataArrayLookupHelper.h:49
vtkX3D::position
Definition: vtkX3D.h:267
vtkMath::Determinant
static vtkMatrixUtilities::ScalarTypeExtractor< MatrixT >::value_type Determinant(const MatrixT &M)
Computes the determinant of input square SizeT x SizeT matrix M.
Definition: vtkMath.h:849
vtkX3D::point
Definition: vtkX3D.h:242
vtkMath::ClampValue
static T ClampValue(const T &value, const T &min, const T &max)
Clamp some value against a range, return the result.
Definition: vtkMath.h:1725
vtkMath::Distance2BetweenPoints
static ReturnTypeT Distance2BetweenPoints(const TupleRangeT1 &p1, const TupleRangeT2 &p2)
Compute distance squared between two points p1 and p2.
Definition: vtkMath.h:1673
vtkTypeTraits.h
vtkMath::RoundDoubleToIntegralIfNecessary
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
vtkMath::Normalize2D
static float Normalize2D(float v[2])
Normalize (in place) a 2-vector.
vtkMath::Norm2D
static float Norm2D(const float x[2])
Compute the norm of a 2-vector.
Definition: vtkMath.h:681
vtkMath::Pi
static double Pi()
A mathematical constant.
Definition: vtkMath.h:97
vtkMath::MultiplyScalar2D
static void MultiplyScalar2D(double a[2], double s)
Multiplies a 2-vector by a scalar (double version).
Definition: vtkMath.h:406
vtkMath::TensorFromSymmetricTensor
static void TensorFromSymmetricTensor(const T1 symmTensor[6], T2 tensor[9])
Convert a 6-Component symmetric tensor into a 9-Component tensor, no allocation performed.
vtkMath::Min
static T Min(const T &a, const T &b)
Returns the minimum of the two arguments provided.
Definition: vtkMath.h:1567
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSmartPointer.h
vtkDeterminant3x3
double vtkDeterminant3x3(const T A[3][3])
Definition: vtkMath.h:1705
vtkX3D::size
Definition: vtkX3D.h:259
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMath::Outer2D
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:666
vtkMath::Determinant2x2
static float Determinant2x2(const float c1[2], const float c2[2])
Compute determinant of 2x2 matrix.
Definition: vtkMath.h:704
vtkObject.h
vtkMath::Outer
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:457
vtkMath::MultiplyMatrixWithVector
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:815
vtkMath::MultiplyMatrix
static void MultiplyMatrix(const MatrixT1 &M1, const MatrixT2 &M2, MatrixT3 &&M3)
Multiply matrices such that M3 = M1 x M2.
Definition: vtkMath.h:788
vtkBoxMuellerRandomSequence
Gaussian sequence of pseudo random numbers implemented with the Box-Mueller transform.
Definition: vtkBoxMuellerRandomSequence.h:32
vtkMath::Determinant2x2
static double Determinant2x2(const double c1[2], const double c2[2])
Definition: vtkMath.h:714
vtkMath
performs common math operations
Definition: vtkMath.h:87
vtkMath::IsPowerOfTwo
static bool IsPowerOfTwo(vtkTypeUInt64 x)
Returns true if integer is a power of two.
Definition: vtkMath.h:1529
vtkMath::Cross
static void Cross(const float a[3], const float b[3], float c[3])
Cross product of two 3-vectors.
Definition: vtkMath.h:1681
vtkMath::Round
static int Round(double f)
Definition: vtkMath.h:120
vtkMath::XYZToLab
static void XYZToLab(const double xyz[3], double lab[3])
Convert Color from the CIE XYZ system to CIE-L*ab.
Definition: vtkMath.h:1264
vtkMath::RGBToXYZ
static void RGBToXYZ(const double rgb[3], double xyz[3])
Convert color from the RGB system to CIE XYZ.
Definition: vtkMath.h:1286
vtkMath::Round
static int Round(float f)
Rounds a float to the nearest integer.
Definition: vtkMath.h:119
vtkMath::Assign
static void Assign(const double a[3], double b[3])
Assign values to a 3-vector (double version).
Definition: vtkMath.h:315
vtkMath::IsFinite
static bool IsFinite(double x)
Test if a number has finite value i.e.
vtkMath::Dot2D
static double Dot2D(const double x[2], const double y[2])
Dot product of two 2-vectors.
Definition: vtkMath.h:647
vtkMath::Outer2D
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:652
vtkMath::Add
static void Add(const float a[3], const float b[3], float c[3])
Addition of two 3-vectors (float version).
Definition: vtkMath.h:325
vtkMath::Norm
static double Norm(const double v[3])
Compute the norm of 3-vector (double version).
Definition: vtkMath.h:510
vtkMath::Dot
static float Dot(const float a[3], const float b[3])
Dot product of two 3-vectors (float version).
Definition: vtkMath.h:417
vtkX3D::index
Definition: vtkX3D.h:252
vtkMath::AreBoundsInitialized
static vtkTypeBool AreBoundsInitialized(const double bounds[6])
Are the bounds initialized?
Definition: vtkMath.h:1337
vtkMath::Internal
static vtkSmartPointer< vtkMathInternal > Internal
Definition: vtkMath.h:1497
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
h
vtkMatrixUtilities::ScalarTypeExtractor::value_type
detail::ScalarTypeExtractor< std::is_array< ContainerT >::value+std::is_pointer< ContainerT >::value *2, ContainerT >::value_type value_type
Definition: vtkMatrixUtilities.h:96