48 #include "vtkCommonCoreModule.h" 53 #include "vtkMathConfigure.h" 59 # define VTK_DBL_MIN 2.2250738585072014e-308 61 # define VTK_DBL_MIN DBL_MIN 65 # define VTK_DBL_EPSILON 2.2204460492503131e-16 67 # define VTK_DBL_EPSILON DBL_EPSILON 70 #ifndef VTK_DBL_EPSILON 72 # define VTK_DBL_EPSILON 2.2204460492503131e-16 74 # define VTK_DBL_EPSILON DBL_EPSILON 75 # endif // DBL_EPSILON 76 #endif // VTK_DBL_EPSILON 80 class vtkMathInternal;
87 template <
typename OutT>
96 void PrintSelf(ostream& os,
vtkIndent indent)
override;
101 static double Pi() {
return 3.141592653589793; }
107 static float RadiansFromDegrees(
float degrees);
108 static double RadiansFromDegrees(
double degrees);
115 static float DegreesFromRadians(
float radians);
116 static double DegreesFromRadians(
double radians);
124 return static_cast<int>( f + ( f >= 0.0 ? 0.5 : -0.5 ) ); }
126 return static_cast<int>( f + ( f >= 0.0 ? 0.5 : -0.5 ) ); }
133 template <
typename OutT>
146 static int Floor(
double x);
153 static int Ceil(
double x);
160 static int CeilLog2(vtkTypeUInt64 x);
167 static T Min(
const T & a,
const T & b);
174 static T Max(
const T & a,
const T & b);
179 static bool IsPowerOfTwo(vtkTypeUInt64 x);
186 static int NearestPowerOfTwo(
int x);
192 static vtkTypeInt64 Factorial(
int N );
199 static vtkTypeInt64 Binomial(
int m,
int n );
211 static int* BeginCombination(
int m,
int n );
223 static int NextCombination(
int m,
int n,
int* combination );
228 static void FreeCombination(
int* combination);
245 static void RandomSeed(
int s);
258 static int GetSeed();
273 static double Random();
287 static double Random(
double min,
double max );
301 static double Gaussian();
315 static double Gaussian(
double mean,
double std );
320 static void Add(
const float a[3],
const float b[3],
float c[3]) {
321 for (
int i = 0; i < 3; ++i)
330 static void Add(
const double a[3],
const double b[3],
double c[3]) {
331 for (
int i = 0; i < 3; ++i)
340 static void Subtract(
const float a[3],
const float b[3],
float c[3]) {
341 for (
int i = 0; i < 3; ++i)
350 static void Subtract(
const double a[3],
const double b[3],
double c[3]) {
351 for (
int i = 0; i < 3; ++i)
362 for (
int i = 0; i < 3; ++i)
373 for (
int i = 0; i < 2; ++i)
384 for (
int i = 0; i < 3; ++i)
395 for (
int i = 0; i < 2; ++i)
404 static float Dot(
const float a[3],
const float b[3]) {
405 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
411 static double Dot(
const double a[3],
const double b[3]) {
412 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
418 static void Outer(
const float a[3],
const float b[3],
float c[3][3]) {
419 for (
int i = 0; i < 3; ++i)
421 for (
int j = 0; j < 3; ++j)
423 c[i][j] = a[i] * b[j];
431 static void Outer(
const double a[3],
const double b[3],
double c[3][3]) {
432 for (
int i = 0; i < 3; ++i)
434 for (
int j = 0; j < 3; ++j)
436 c[i][j] = a[i] * b[j];
445 static void Cross(
const float a[3],
const float b[3],
float c[3]);
451 static void Cross(
const double a[3],
const double b[3],
double c[3]);
457 static float Norm(
const float* x,
int n);
458 static double Norm(
const double* x,
int n);
464 static float Norm(
const float v[3]) {
465 return static_cast<float> (sqrt( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] ) );
471 static double Norm(
const double v[3]) {
472 return sqrt( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] );
479 static float Normalize(
float v[3]);
485 static double Normalize(
double v[3]);
495 static void Perpendiculars(
const double v1[3],
double v2[3],
double v3[3],
497 static void Perpendiculars(
const float v1[3],
float v2[3],
float v3[3],
507 static bool ProjectVector(
const float a[3],
const float b[3],
float projection[3]);
508 static bool ProjectVector(
const double a[3],
const double b[3],
double projection[3]);
518 static bool ProjectVector2D(
const float a[2],
const float b[2],
float projection[2]);
519 static bool ProjectVector2D(
const double a[2],
const double b[2],
double projection[2]);
526 static float Distance2BetweenPoints(
const float p1[3],
const float p2[3]);
532 static double Distance2BetweenPoints(
const double p1[3],
const double p2[3]);
537 static double AngleBetweenVectors(
const double v1[3],
const double v2[3]);
543 static double GaussianAmplitude(
const double variance,
const double distanceFromMean);
549 static double GaussianAmplitude(
const double mean,
const double variance,
const double position);
556 static double GaussianWeight(
const double variance,
const double distanceFromMean);
563 static double GaussianWeight(
const double mean,
const double variance,
const double position);
568 static float Dot2D(
const float x[2],
const float y[2]) {
569 return x[0] * y[0] + x[1] * y[1];
575 static double Dot2D(
const double x[2],
const double y[2]) {
576 return x[0] * y[0] + x[1] * y[1];
582 static void Outer2D(
const float x[2],
const float y[2],
float A[2][2])
584 for (
int i=0; i < 2; ++i)
586 for (
int j=0; j < 2; ++j)
588 A[i][j] = x[i] * y[j];
596 static void Outer2D(
const double x[2],
const double y[2],
double A[2][2])
598 for (
int i=0; i < 2; ++i)
600 for (
int j=0; j < 2; ++j)
602 A[i][j] = x[i] * y[j];
612 return static_cast<float> (sqrt( x[0] * x[0] + x[1] * x[1] ) );
619 static double Norm2D(
const double x[2]) {
620 return sqrt( x[0] * x[0] + x[1] * x[1] );
627 static float Normalize2D(
float v[2]);
633 static double Normalize2D(
double v[2]);
639 return c1[0] * c2[1] - c2[0] * c1[1];
647 return a * d - b * c;
650 return c1[0] * c2[1] - c2[0] * c1[1];
658 static void LUFactor3x3(
float A[3][3],
int index[3]);
659 static void LUFactor3x3(
double A[3][3],
int index[3]);
666 static void LUSolve3x3(
const float A[3][3],
const int index[3],
668 static void LUSolve3x3(
const double A[3][3],
const int index[3],
677 static void LinearSolve3x3(
const float A[3][3],
const float x[3],
679 static void LinearSolve3x3(
const double A[3][3],
const double x[3],
687 static void Multiply3x3(
const float A[3][3],
const float in[3],
689 static void Multiply3x3(
const double A[3][3],
const double in[3],
697 static void Multiply3x3(
const float A[3][3],
const float B[3][3],
699 static void Multiply3x3(
const double A[3][3],
const double B[3][3],
708 static void MultiplyMatrix(
const double *
const *A,
const double *
const *B,
709 unsigned int rowA,
unsigned int colA,
710 unsigned int rowB,
unsigned int colB,
718 static void Transpose3x3(
const float A[3][3],
float AT[3][3]);
719 static void Transpose3x3(
const double A[3][3],
double AT[3][3]);
727 static void Invert3x3(
const float A[3][3],
float AI[3][3]);
728 static void Invert3x3(
const double A[3][3],
double AI[3][3]);
735 static void Identity3x3(
float A[3][3]);
736 static void Identity3x3(
double A[3][3]);
743 static double Determinant3x3(
const float A[3][3]);
744 static double Determinant3x3(
const double A[3][3]);
750 static float Determinant3x3(
const float c1[3],
757 static double Determinant3x3(
const double c1[3],
767 static double Determinant3x3(
double a1,
double a2,
double a3,
768 double b1,
double b2,
double b3,
769 double c1,
double c2,
double c3);
779 static void QuaternionToMatrix3x3(
const float quat[4],
float A[3][3]);
780 static void QuaternionToMatrix3x3(
const double quat[4],
double A[3][3]);
793 static void Matrix3x3ToQuaternion(
const float A[3][3],
float quat[4]);
794 static void Matrix3x3ToQuaternion(
const double A[3][3],
double quat[4]);
804 static void MultiplyQuaternion(
const float q1[4],
const float q2[4],
float q[4] );
805 static void MultiplyQuaternion(
const double q1[4],
const double q2[4],
double q[4] );
813 static void RotateVectorByNormalizedQuaternion(
const float v[3],
const float q[4],
float r[3]);
814 static void RotateVectorByNormalizedQuaternion(
const double v[3],
const double q[4],
double r[3]);
822 static void RotateVectorByWXYZ(
const float v[3],
const float q[4],
float r[3]);
823 static void RotateVectorByWXYZ(
const double v[3],
const double q[4],
double r[3]);
832 static void Orthogonalize3x3(
const float A[3][3],
float B[3][3]);
833 static void Orthogonalize3x3(
const double A[3][3],
double B[3][3]);
843 static void Diagonalize3x3(
const float A[3][3],
float w[3],
float V[3][3]);
844 static void Diagonalize3x3(
const double A[3][3],
double w[3],
double V[3][3]);
857 static void SingularValueDecomposition3x3(
const float A[3][3],
858 float U[3][3],
float w[3],
860 static void SingularValueDecomposition3x3(
const double A[3][3],
861 double U[3][3],
double w[3],
879 static vtkTypeBool InvertMatrix(
double **A,
double **AI,
int size);
886 static vtkTypeBool InvertMatrix(
double **A,
double **AI,
int size,
887 int *tmp1Size,
double *tmp2Size);
911 static vtkTypeBool LUFactorLinearSystem(
double **A,
int *index,
int size);
918 static vtkTypeBool LUFactorLinearSystem(
double **A,
int *index,
int size,
929 static void LUSolveLinearSystem(
double **A,
int *index,
930 double *x,
int size);
940 static double EstimateMatrixCondition(
const double *
const *A,
int size);
951 static vtkTypeBool Jacobi(
float **a,
float *w,
float **v);
952 static vtkTypeBool Jacobi(
double **a,
double *w,
double **v);
965 static vtkTypeBool JacobiN(
float **a,
int n,
float *w,
float **v);
966 static vtkTypeBool JacobiN(
double **a,
int n,
double *w,
double **v);
982 static vtkTypeBool SolveHomogeneousLeastSquares(
int numberOfSamples,
double **xt,
983 int xOrder,
double **mt);
999 static vtkTypeBool SolveLeastSquares(
int numberOfSamples,
double **xt,
int xOrder,
1000 double **yt,
int yOrder,
double **mt,
int checkHomogeneous=1);
1010 static void RGBToHSV(
const float rgb[3],
float hsv[3]) {
1011 RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
1013 static void RGBToHSV(
float r,
float g,
float b,
float *h,
float *s,
float *v);
1014 VTK_LEGACY(
static double* RGBToHSV(
const double rgb[3])
VTK_SIZEHINT(3));
1015 VTK_LEGACY(
static double* RGBToHSV(
double r,
double g,
double b)
VTK_SIZEHINT(3));
1016 static void RGBToHSV(
const double rgb[3],
double hsv[3]) {
1017 RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
1019 static void RGBToHSV(
double r,
double g,
double b,
double *h,
double *s,
double *v);
1030 static void HSVToRGB(
const float hsv[3],
float rgb[3]) {
1031 HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
1033 static void HSVToRGB(
float h,
float s,
float v,
float *r,
float *g,
float *b);
1034 VTK_LEGACY(
static double* HSVToRGB(
const double hsv[3])
VTK_SIZEHINT(3));
1035 VTK_LEGACY(
static double* HSVToRGB(
double h,
double s,
double v)
VTK_SIZEHINT(3));
1036 static void HSVToRGB(
const double hsv[3],
double rgb[3])
1037 { HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); }
1038 static void HSVToRGB(
double h,
double s,
double v,
double *r,
double *g,
double *b);
1045 static void LabToXYZ(
const double lab[3],
double xyz[3]) {
1046 LabToXYZ(lab[0], lab[1], lab[2], xyz+0, xyz+1, xyz+2);
1048 static void LabToXYZ(
double L,
double a,
double b,
1049 double *x,
double *y,
double *z);
1050 VTK_LEGACY(
static double *LabToXYZ(
const double lab[3])
VTK_SIZEHINT(3));
1057 static void XYZToLab(
const double xyz[3],
double lab[3]) {
1058 XYZToLab(xyz[0], xyz[1], xyz[2], lab+0, lab+1, lab+2);
1060 static void XYZToLab(
double x,
double y,
double z,
1061 double *L,
double *a,
double *b);
1062 VTK_LEGACY(
static double *XYZToLab(
const double xyz[3])
VTK_SIZEHINT(3));
1069 static void XYZToRGB(
const double xyz[3],
double rgb[3]) {
1070 XYZToRGB(xyz[0], xyz[1], xyz[2], rgb+0, rgb+1, rgb+2);
1072 static void XYZToRGB(
double x,
double y,
double z,
1073 double *r,
double *g,
double *b);
1074 VTK_LEGACY(
static double *XYZToRGB(
const double xyz[3])
VTK_SIZEHINT(3));
1081 static void RGBToXYZ(
const double rgb[3],
double xyz[3]) {
1082 RGBToXYZ(rgb[0], rgb[1], rgb[2], xyz+0, xyz+1, xyz+2);
1084 static void RGBToXYZ(
double r,
double g,
double b,
1085 double *x,
double *y,
double *z);
1086 VTK_LEGACY(
static double *RGBToXYZ(
const double rgb[3])
VTK_SIZEHINT(3));
1096 static void RGBToLab(
const double rgb[3],
double lab[3]) {
1097 RGBToLab(rgb[0], rgb[1], rgb[2], lab+0, lab+1, lab+2);
1099 static void RGBToLab(
double red,
double green,
double blue,
1100 double *L,
double *a,
double *b);
1101 VTK_LEGACY(
static double *RGBToLab(
const double rgb[3])
VTK_SIZEHINT(3));
1108 static void LabToRGB(
const double lab[3],
double rgb[3]) {
1109 LabToRGB(lab[0], lab[1], lab[2], rgb+0, rgb+1, rgb+2);
1111 static void LabToRGB(
double L,
double a,
double b,
1112 double *red,
double *green,
double *blue);
1113 VTK_LEGACY(
static double *LabToRGB(
const double lab[3])
VTK_SIZEHINT(3));
1135 if ( bounds[1] - bounds[0] < 0.0 )
1148 static T ClampValue(
const T &
value,
const T & min,
const T & max);
1155 static void ClampValue(
double *value,
const double range[2]);
1156 static void ClampValue(
double value,
const double range[2],
double *clamped_value);
1157 static void ClampValues(
1158 double *values,
int nb_values,
const double range[2]);
1159 static void ClampValues(
1160 const double *values,
int nb_values,
const double range[2],
double *clamped_values);
1169 static double ClampAndNormalizeValue(
double value,
1170 const double range[2]);
1176 template<
class T1,
class T2>
1177 static void TensorFromSymmetricTensor(
const T1 symmTensor[6], T2 tensor[9]);
1185 static void TensorFromSymmetricTensor(T tensor[9]);
1195 static int GetScalarTypeFittingRange(
1196 double range_min,
double range_max,
1197 double scale = 1.0,
double shift = 0.0);
1214 static vtkTypeBool ExtentIsWithinOtherExtent(
const int extent1[6],
const int extent2[6]);
1221 static vtkTypeBool BoundsIsWithinOtherBounds(
const double bounds1[6],
const double bounds2[6],
const double delta[3]);
1228 static vtkTypeBool PointIsWithinBounds(
const double point[3],
const double bounds[6],
const double delta[3]);
1239 static int PlaneIntersectsAABB(
1240 const double bounds[6],
1241 const double normal[3],
1242 const double point[3]);
1253 static double Solve3PointCircle(
1262 static double Inf();
1267 static double NegInf();
1272 static double Nan();
1287 static bool IsFinite(
double x);
1295 void operator=(
const vtkMath&) =
delete;
1301 return x * 0.017453292f;
1307 return x * 0.017453292519943295;
1313 return x * 57.2957795131f;
1319 return x * 57.29577951308232;
1325 return ((x != 0) & ((x & (x - 1)) == 0));
1332 unsigned int z = ((x > 0) ? x - 1 : 0);
1338 return static_cast<int>(z + 1);
1346 int i =
static_cast<int>(x);
1347 return i - ( i > x );
1355 int i =
static_cast<int>(x);
1356 return i + ( i < x );
1363 return (b <= a ? b : a);
1370 return (b > a ? b : a);
1379 for (
int i=0; i < 3; ++i)
1393 for (
int i=0; i < 3; ++i)
1407 for (
int i=0; i < 2; ++i)
1421 for (
int i=0; i < 2; ++i)
1434 return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1435 c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1443 return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1444 c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1449 double b1,
double b2,
double b3,
1450 double c1,
double c2,
double c3)
1461 return ( ( p1[0] - p2[0] ) * ( p1[0] - p2[0] )
1462 + ( p1[1] - p2[1] ) * ( p1[1] - p2[1] )
1463 + ( p1[2] - p2[2] ) * ( p1[2] - p2[2] ) );
1470 return ( ( p1[0] - p2[0] ) * ( p1[0] - p2[0] )
1471 + ( p1[1] - p2[1] ) * ( p1[1] - p2[1] )
1472 + ( p1[2] - p2[2] ) * ( p1[2] - p2[2] ) );
1479 float Cx = a[1] * b[2] - a[2] * b[1];
1480 float Cy = a[2] * b[0] - a[0] * b[2];
1481 float Cz = a[0] * b[1] - a[1] * b[0];
1482 c[0] = Cx; c[1] = Cy; c[2] = Cz;
1489 double Cx = a[1] * b[2] - a[2] * b[1];
1490 double Cy = a[2] * b[0] - a[0] * b[2];
1491 double Cz = a[0] * b[1] - a[1] * b[0];
1492 c[0] = Cx; c[1] = Cy; c[2] = Cz;
1499 return A[0][0] * A[1][1] * A[2][2] + A[1][0] * A[2][1] * A[0][2] +
1500 A[2][0] * A[0][1] * A[1][2] - A[0][0] * A[2][1] * A[1][2] -
1501 A[1][0] * A[0][1] * A[2][2] - A[2][0] * A[1][1] * A[0][2];
1520 assert(
"pre: valid_range" && min<=max);
1522 #if __cplusplus >= 201703L 1523 return std::clamp(value, min, max);
1527 T v = (min < value ? value : min);
1528 return (v < max ? v : max);
1537 assert(
"pre: valid_range" && range[0]<=range[1]);
1545 double value,
const double range[2],
double *clamped_value)
1547 if (range && clamped_value)
1549 assert(
"pre: valid_range" && range[0]<=range[1]);
1557 const double range[2])
1559 assert(
"pre: valid_range" && range[0]<=range[1]);
1562 if (range[0] == range[1])
1572 result=( result - range[0] ) / ( range[1] - range[0] );
1575 assert(
"post: valid_result" && result>=0.0 && result<=1.0);
1581 template<
class T1,
class T2>
1584 for (
int i = 0; i < 3; ++i)
1586 tensor[4*i] = symmTensor[i];
1588 tensor[1] = tensor[3] = symmTensor[3];
1589 tensor[2] = tensor[6] = symmTensor[5];
1590 tensor[5] = tensor[7] = symmTensor[4];
1597 tensor[6] = tensor[5];
1598 tensor[7] = tensor[4];
1599 tensor[8] = tensor[2];
1600 tensor[4] = tensor[1];
1601 tensor[5] = tensor[7];
1602 tensor[2] = tensor[6];
1603 tensor[1] = tensor[3];
1609 template <
typename OutT>
1615 *ret =
static_cast<OutT
>((val >= 0.0) ? (val + 0.5) : (val - 0.5));
1628 *retVal =
static_cast<float>(val);
1633 #if defined(VTK_HAS_ISINF) || defined(VTK_HAS_STD_ISINF) 1634 #define VTK_MATH_ISINF_IS_INLINE 1637 #if defined(VTK_HAS_STD_ISINF) 1638 return std::isinf(x);
1640 return (isinf(x) != 0);
1646 #if defined(VTK_HAS_ISNAN) || defined(VTK_HAS_STD_ISNAN) 1647 #define VTK_MATH_ISNAN_IS_INLINE 1650 #if defined(VTK_HAS_STD_ISNAN) 1653 return (
isnan(x) != 0);
1659 #if defined(VTK_HAS_ISFINITE) || defined(VTK_HAS_STD_ISFINITE) || defined(VTK_HAS_FINITE) 1660 #define VTK_MATH_ISFINITE_IS_INLINE 1663 #if defined(VTK_HAS_STD_ISFINITE) 1664 return std::isfinite(x);
1665 #elif defined(VTK_HAS_ISFINITE) 1666 return (isfinite(x) != 0);
1668 return (finite(x) != 0);
static void MultiplyScalar2D(float a[2], float s)
Multiplies a 2-vector by a scalar (float version).
static bool IsFinite(double x)
Test if a number has finite value i.e.
static float Dot2D(const float x[2], const float y[2])
Dot product of two 2-vectors.
static float Dot(const float a[3], const float b[3])
Dot product of two 3-vectors (float version).
static void TensorFromSymmetricTensor(const T1 symmTensor[6], T2 tensor[9])
Convert a 6-Component symmetric tensor into a 9-Component tensor, no allocation performed.
abstract base class for most VTK objects
static void LabToXYZ(const double lab[3], double xyz[3])
Convert color from the CIE-L*ab system to CIE XYZ.
static double Pi()
A mathematical constant.
static bool IsPowerOfTwo(vtkTypeUInt64 x)
Returns true if integer is a power of two.
static void Outer(const double a[3], const double b[3], double c[3][3])
Outer product of two 3-vectors (double version).
void RoundDoubleToIntegralIfNecessary(double val, OutT *ret)
static float Determinant2x2(const float c1[2], const float c2[2])
Compute determinant of 2x2 matrix.
static vtkSmartPointer< vtkMathInternal > Internal
static vtkTypeBool IsInf(double x)
Test if a number is equal to the special floating point value infinity.
static void RGBToHSV(const double rgb[3], double hsv[3])
Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).
static vtkTypeBool IsNan(double x)
Test if a number is equal to the special floating point value Not-A-Number (Nan). ...
static int Round(float f)
Rounds a float to the nearest integer.
static void RGBToHSV(const float rgb[3], float hsv[3])
Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).
static double ClampAndNormalizeValue(double value, const double range[2])
Clamp a value against a range and then normalize it between 0 and 1.
static void Outer(const float a[3], const float b[3], float c[3][3])
Outer product of two 3-vectors (float version).
static float Normalize2D(float v[2])
Normalize (in place) a 2-vector.
static void Add(const double a[3], const double b[3], double c[3])
Addition of two 3-vectors (double version).
static double Dot(const double a[3], const double b[3])
Dot product of two 3-vectors (double version).
static void XYZToRGB(const double xyz[3], double rgb[3])
Convert color from the CIE XYZ system to RGB.
static float Norm2D(const float x[2])
Compute the norm of a 2-vector.
static void UninitializeBounds(double bounds[6])
Set the bounds to an uninitialized state.
double vtkDeterminant3x3(const T A[3][3])
static int NearestPowerOfTwo(int x)
Compute the nearest power of two that is not less than x.
static void RGBToXYZ(const double rgb[3], double xyz[3])
Convert color from the RGB system to CIE XYZ.
static T Min(const T &a, const T &b)
Returns the minimum of the two arguments provided.
a simple class to control print indentation
static void Subtract(const float a[3], const float b[3], float c[3])
Subtraction of two 3-vectors (float version).
static void Subtract(const double a[3], const double b[3], double c[3])
Subtraction of two 3-vectors (double version).
static int Floor(double x)
Rounds a double to the nearest integer not greater than itself.
static double Determinant3x3(const float A[3][3])
Return the determinant of a 3x3 matrix.
abstract superclass for arrays of numeric data
static double Determinant2x2(double a, double b, double c, double d)
Calculate the determinant of a 2x2 matrix: | a b | | c d |.
static float RadiansFromDegrees(float degrees)
Convert degrees into radians.
static void HSVToRGB(const double hsv[3], double rgb[3])
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
Park and Miller Sequence of pseudo random numbers.
static void MultiplyScalar(double a[3], double s)
Multiplies a 3-vector by a scalar (double version).
#define VTK_SIZEHINT(...)
static void RGBToLab(const double rgb[3], double lab[3])
Convert color from the RGB system to CIE-L*ab.
static float DegreesFromRadians(float radians)
Convert radians into degrees.
static float Normalize(float v[3])
Normalize (in place) a 3-vector.
static void Outer2D(const double x[2], const double y[2], double A[2][2])
Outer product of two 2-vectors (double version).
static void Outer2D(const float x[2], const float y[2], float A[2][2])
Outer product of two 2-vectors (float version).
static int Ceil(double x)
Rounds a double to the nearest integer not less than itself.
performs common math operations
static double Dot2D(const double x[2], const double y[2])
Dot product of two 2-vectors.
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...
static float Norm(const float v[3])
Compute the norm of 3-vector (float version).
static void MultiplyScalar(float a[3], float s)
Multiplies a 3-vector by a scalar (float version).
static void HSVToRGB(const float hsv[3], float rgb[3])
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
static T ClampValue(const T &value, const T &min, const T &max)
Clamp some value against a range, return the result.
static double Norm2D(const double x[2])
Compute the norm of a 2-vector.
static int Round(double f)
static double Norm(const double v[3])
Compute the norm of 3-vector (double version).
static void MultiplyScalar2D(double a[2], double s)
Multiplies a 2-vector by a scalar (double version).
static float Distance2BetweenPoints(const float p1[3], const float p2[3])
Compute distance squared between two points p1 and p2.
static void LabToRGB(const double lab[3], double rgb[3])
Convert color from the CIE-L*ab system to RGB.
static float Norm(const float *x, int n)
Compute the norm of n-vector.
static void Cross(const float a[3], const float b[3], float c[3])
Cross product of two 3-vectors.
Gaussian sequence of pseudo random numbers implemented with the Box-Mueller transform.
static double Determinant2x2(const double c1[2], const double c2[2])
Calculate the determinant of a 2x2 matrix: | a b | | c d |.
static void Add(const float a[3], const float b[3], float c[3])
Addition of two 3-vectors (float version).
Template defining traits of native types used by VTK.
static vtkTypeBool AreBoundsInitialized(const double bounds[6])
Are the bounds initialized?
represent and manipulate 3D points
static T Max(const T &a, const T &b)
Returns the maximum of the two arguments provided.
static void XYZToLab(const double xyz[3], double lab[3])
Convert Color from the CIE XYZ system to CIE-L*ab.