42 #include "vtkCommonCoreModule.h" 47 #include "vtkMathConfigure.h" 52 # define VTK_DBL_MIN 2.2250738585072014e-308 54 # define VTK_DBL_MIN DBL_MIN 58 # define VTK_DBL_EPSILON 2.2204460492503131e-16 60 # define VTK_DBL_EPSILON DBL_EPSILON 63 #ifndef VTK_DBL_EPSILON 65 # define VTK_DBL_EPSILON 2.2204460492503131e-16 67 # define VTK_DBL_EPSILON DBL_EPSILON 68 # endif // DBL_EPSILON 69 #endif // VTK_DBL_EPSILON 73 class vtkMathInternal;
80 template <
typename OutT>
94 static double Pi() {
return 3.141592653589793; };
100 static float RadiansFromDegrees(
float degrees);
101 static double RadiansFromDegrees(
double degrees);
108 static float DegreesFromRadians(
float radians);
109 static double DegreesFromRadians(
double radians);
116 return static_cast<int>( f + ( f >= 0.0 ? 0.5 : -0.5 ) ); }
118 return static_cast<int>( f + ( f >= 0.0 ? 0.5 : -0.5 ) ); }
124 template <
typename OutT>
137 static int Floor(
double x);
144 static int Ceil(
double x);
151 static int CeilLog2(vtkTypeUInt64 x);
158 static T Min(
const T & a,
const T & b);
165 static T Max(
const T & a,
const T & b);
170 static bool IsPowerOfTwo(vtkTypeUInt64 x);
177 static int NearestPowerOfTwo(
int x);
183 static vtkTypeInt64 Factorial(
int N );
190 static vtkTypeInt64 Binomial(
int m,
int n );
202 static int* BeginCombination(
int m,
int n );
214 static int NextCombination(
int m,
int n,
int* combination );
219 static void FreeCombination(
int* combination);
236 static void RandomSeed(
int s);
249 static int GetSeed();
264 static double Random();
278 static double Random(
double min,
double max );
292 static double Gaussian();
306 static double Gaussian(
double mean,
double std );
311 static void Add(
const float a[3],
const float b[3],
float c[3]) {
312 for (
int i = 0; i < 3; ++i)
319 static void Add(
const double a[3],
const double b[3],
double c[3]) {
320 for (
int i = 0; i < 3; ++i)
327 static void Subtract(
const float a[3],
const float b[3],
float c[3]) {
328 for (
int i = 0; i < 3; ++i)
335 static void Subtract(
const double a[3],
const double b[3],
double c[3]) {
336 for (
int i = 0; i < 3; ++i)
345 for (
int i = 0; i < 3; ++i)
354 for (
int i = 0; i < 2; ++i)
363 for (
int i = 0; i < 3; ++i)
372 for (
int i = 0; i < 2; ++i)
379 static float Dot(
const float a[3],
const float b[3]) {
380 return ( a[0] * b[0] + a[1] * b[1] + a[2] * b[2] );};
385 static double Dot(
const double a[3],
const double b[3]) {
386 return ( a[0] * b[0] + a[1] * b[1] + a[2] * b[2] );};
391 static void Outer(
const float a[3],
const float b[3],
float C[3][3]) {
392 for (
int i=0; i < 3; i++)
393 for (
int j=0; j < 3; j++)
394 C[i][j] = a[i] * b[j];
399 static void Outer(
const double a[3],
const double b[3],
double C[3][3]) {
400 for (
int i=0; i < 3; i++)
401 for (
int j=0; j < 3; j++)
402 C[i][j] = a[i] * b[j];
408 static void Cross(
const float a[3],
const float b[3],
float c[3]);
414 static void Cross(
const double a[3],
const double b[3],
double c[3]);
420 static float Norm(
const float* x,
int n);
421 static double Norm(
const double* x,
int n);
427 static float Norm(
const float v[3]) {
428 return static_cast<float> (sqrt( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] ) );};
433 static double Norm(
const double v[3]) {
434 return sqrt( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] );};
439 static float Normalize(
float v[3]);
445 static double Normalize(
double v[3]);
455 static void Perpendiculars(
const double v1[3],
double v2[3],
double v3[3],
457 static void Perpendiculars(
const float v1[3],
float v2[3],
float v3[3],
467 static bool ProjectVector(
const float a[3],
const float b[3],
float projection[3]);
468 static bool ProjectVector(
const double a[3],
const double b[3],
double projection[3]);
478 static bool ProjectVector2D(
const float a[2],
const float b[2],
float projection[2]);
479 static bool ProjectVector2D(
const double a[2],
const double b[2],
double projection[2]);
485 static float Distance2BetweenPoints(
const float p1[3],
const float p2[3]);
491 static double Distance2BetweenPoints(
const double p1[3],
const double p2[3]);
496 static double AngleBetweenVectors(
const double v1[3],
const double v2[3]);
502 static double GaussianAmplitude(
const double variance,
const double distanceFromMean);
508 static double GaussianAmplitude(
const double mean,
const double variance,
const double position);
515 static double GaussianWeight(
const double variance,
const double distanceFromMean);
522 static double GaussianWeight(
const double mean,
const double variance,
const double position);
527 static float Dot2D(
const float x[2],
const float y[2]) {
528 return ( x[0] * y[0] + x[1] * y[1] );};
533 static double Dot2D(
const double x[2],
const double y[2]) {
534 return ( x[0] * y[0] + x[1] * y[1] );};
539 static void Outer2D(
const float x[2],
const float y[2],
float A[2][2])
541 for (
int i=0; i < 2; i++)
543 for (
int j=0; j < 2; j++)
545 A[i][j] = x[i] * y[j];
552 static void Outer2D(
const double x[2],
const double y[2],
double A[2][2])
554 for (
int i=0; i < 2; i++)
556 for (
int j=0; j < 2; j++)
558 A[i][j] = x[i] * y[j];
567 return static_cast<float> (sqrt( x[0] * x[0] + x[1] * x[1] ) );};
573 static double Norm2D(
const double x[2]) {
574 return sqrt( x[0] * x[0] + x[1] * x[1] );};
579 static float Normalize2D(
float v[2]);
585 static double Normalize2D(
double v[2]);
591 return (c1[0] * c2[1] - c2[0] * c1[1] );};
598 return (a * d - b * c);};
600 return (c1[0] * c2[1] - c2[0] * c1[1] );};
607 static void LUFactor3x3(
float A[3][3],
int index[3]);
608 static void LUFactor3x3(
double A[3][3],
int index[3]);
615 static void LUSolve3x3(
const float A[3][3],
const int index[3],
617 static void LUSolve3x3(
const double A[3][3],
const int index[3],
626 static void LinearSolve3x3(
const float A[3][3],
const float x[3],
628 static void LinearSolve3x3(
const double A[3][3],
const double x[3],
636 static void Multiply3x3(
const float A[3][3],
const float in[3],
638 static void Multiply3x3(
const double A[3][3],
const double in[3],
646 static void Multiply3x3(
const float A[3][3],
const float B[3][3],
648 static void Multiply3x3(
const double A[3][3],
const double B[3][3],
657 static void MultiplyMatrix(
double **A,
double **B,
658 unsigned int rowA,
unsigned int colA,
659 unsigned int rowB,
unsigned int colB,
667 static void Transpose3x3(
const float A[3][3],
float AT[3][3]);
668 static void Transpose3x3(
const double A[3][3],
double AT[3][3]);
676 static void Invert3x3(
const float A[3][3],
float AI[3][3]);
677 static void Invert3x3(
const double A[3][3],
double AI[3][3]);
684 static void Identity3x3(
float A[3][3]);
685 static void Identity3x3(
double A[3][3]);
692 static double Determinant3x3(
float A[3][3]);
693 static double Determinant3x3(
double A[3][3]);
699 static float Determinant3x3(
const float c1[3],
706 static double Determinant3x3(
const double c1[3],
716 static double Determinant3x3(
double a1,
double a2,
double a3,
717 double b1,
double b2,
double b3,
718 double c1,
double c2,
double c3);
728 static void QuaternionToMatrix3x3(
const float quat[4],
float A[3][3]);
729 static void QuaternionToMatrix3x3(
const double quat[4],
double A[3][3]);
741 static void Matrix3x3ToQuaternion(
const float A[3][3],
float quat[4]);
742 static void Matrix3x3ToQuaternion(
const double A[3][3],
double quat[4]);
752 static void MultiplyQuaternion(
const float q1[4],
const float q2[4],
float q[4] );
753 static void MultiplyQuaternion(
const double q1[4],
const double q2[4],
double q[4] );
761 static void RotateVectorByNormalizedQuaternion(
const float v[3],
const float q[4],
float r[3]);
762 static void RotateVectorByNormalizedQuaternion(
const double v[3],
const double q[4],
double r[3]);
770 static void RotateVectorByWXYZ(
const float v[3],
const float q[4],
float r[3]);
771 static void RotateVectorByWXYZ(
const double v[3],
const double q[4],
double r[3]);
780 static void Orthogonalize3x3(
const float A[3][3],
float B[3][3]);
781 static void Orthogonalize3x3(
const double A[3][3],
double B[3][3]);
791 static void Diagonalize3x3(
const float A[3][3],
float w[3],
float V[3][3]);
792 static void Diagonalize3x3(
const double A[3][3],
double w[3],
double V[3][3]);
805 static void SingularValueDecomposition3x3(
const float A[3][3],
806 float U[3][3],
float w[3],
808 static void SingularValueDecomposition3x3(
const double A[3][3],
809 double U[3][3],
double w[3],
819 static int SolveLinearSystem(
double **A,
double *x,
int size);
827 static int InvertMatrix(
double **A,
double **AI,
int size);
834 static int InvertMatrix(
double **A,
double **AI,
int size,
835 int *tmp1Size,
double *tmp2Size);
859 static int LUFactorLinearSystem(
double **A,
int *
index,
int size);
866 static int LUFactorLinearSystem(
double **A,
int *
index,
int size,
877 static void LUSolveLinearSystem(
double **A,
int *
index,
878 double *x,
int size);
888 static double EstimateMatrixCondition(
double **A,
int size);
899 static int Jacobi(
float **a,
float *w,
float **v);
900 static int Jacobi(
double **a,
double *w,
double **v);
913 static int JacobiN(
float **a,
int n,
float *w,
float **v);
914 static int JacobiN(
double **a,
int n,
double *w,
double **v);
930 static int SolveHomogeneousLeastSquares(
int numberOfSamples,
double **xt,
int xOrder,
947 static int SolveLeastSquares(
int numberOfSamples,
double **xt,
int xOrder,
948 double **yt,
int yOrder,
double **mt,
int checkHomogeneous=1);
958 static void RGBToHSV(
const float rgb[3],
float hsv[3])
959 { RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); }
960 static void RGBToHSV(
float r,
float g,
float b,
float *h,
float *s,
float *v);
961 static double* RGBToHSV(
const double rgb[3])
VTK_SIZEHINT(3);
962 static double* RGBToHSV(
double r,
double g,
double b)
VTK_SIZEHINT(3);
963 static void RGBToHSV(
const double rgb[3],
double hsv[3])
964 { RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); }
965 static void RGBToHSV(
double r,
double g,
double b,
double *h,
double *s,
double *v);
976 static void HSVToRGB(
const float hsv[3],
float rgb[3])
977 { HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); }
978 static void HSVToRGB(
float h,
float s,
float v,
float *r,
float *g,
float *b);
979 static double* HSVToRGB(
const double hsv[3])
VTK_SIZEHINT(3);
980 static double* HSVToRGB(
double h,
double s,
double v)
VTK_SIZEHINT(3);
981 static void HSVToRGB(
const double hsv[3],
double rgb[3])
982 { HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); }
983 static void HSVToRGB(
double h,
double s,
double v,
double *r,
double *g,
double *b);
990 static void LabToXYZ(
const double lab[3],
double xyz[3]) {
991 LabToXYZ(lab[0], lab[1], lab[2], xyz+0, xyz+1, xyz+2);
993 static void LabToXYZ(
double L,
double a,
double b,
994 double *x,
double *y,
double *z);
995 static double *LabToXYZ(
const double lab[3])
VTK_SIZEHINT(3);
1002 static void XYZToLab(
const double xyz[3],
double lab[3]) {
1003 XYZToLab(xyz[0], xyz[1], xyz[2], lab+0, lab+1, lab+2);
1005 static void XYZToLab(
double x,
double y,
double z,
1006 double *L,
double *a,
double *b);
1007 static double *XYZToLab(
const double xyz[3])
VTK_SIZEHINT(3);
1014 static void XYZToRGB(
const double xyz[3],
double rgb[3]) {
1015 XYZToRGB(xyz[0], xyz[1], xyz[2], rgb+0, rgb+1, rgb+2);
1017 static void XYZToRGB(
double x,
double y,
double z,
1018 double *r,
double *g,
double *b);
1019 static double *XYZToRGB(
const double xyz[3])
VTK_SIZEHINT(3);
1026 static void RGBToXYZ(
const double rgb[3],
double xyz[3]) {
1027 RGBToXYZ(rgb[0], rgb[1], rgb[2], xyz+0, xyz+1, xyz+2);
1029 static void RGBToXYZ(
double r,
double g,
double b,
1030 double *x,
double *y,
double *z);
1031 static double *RGBToXYZ(
const double rgb[3])
VTK_SIZEHINT(3);
1041 static void RGBToLab(
const double rgb[3],
double lab[3]) {
1042 RGBToLab(rgb[0], rgb[1], rgb[2], lab+0, lab+1, lab+2);
1044 static void RGBToLab(
double red,
double green,
double blue,
1045 double *L,
double *a,
double *b);
1046 static double *RGBToLab(
const double rgb[3])
VTK_SIZEHINT(3);
1053 static void LabToRGB(
const double lab[3],
double rgb[3]) {
1054 LabToRGB(lab[0], lab[1], lab[2], rgb+0, rgb+1, rgb+2);
1056 static void LabToRGB(
double L,
double a,
double b,
1057 double *red,
double *green,
double *blue);
1058 static double *LabToRGB(
const double lab[3])
VTK_SIZEHINT(3);
1080 if ( bounds[1]-bounds[0]<0.0 )
1093 static T ClampValue(
const T &
value,
const T & min,
const T &
max);
1100 static void ClampValue(
double *
value,
const double range[2]);
1101 static void ClampValue(
double value,
const double range[2],
double *clamped_value);
1102 static void ClampValues(
1103 double *values,
int nb_values,
const double range[2]);
1104 static void ClampValues(
1105 const double *values,
int nb_values,
const double range[2],
double *clamped_values);
1114 static double ClampAndNormalizeValue(
double value,
1115 const double range[2]);
1121 template<
class T1,
class T2>
1122 static void TensorFromSymmetricTensor(T1 symmTensor[6], T2 tensor[9]);
1130 static void TensorFromSymmetricTensor(T tensor[9]);
1140 static int GetScalarTypeFittingRange(
1141 double range_min,
double range_max,
1142 double scale = 1.0,
double shift = 0.0);
1152 static int GetAdjustedScalarRange(
1159 static vtkTypeBool ExtentIsWithinOtherExtent(
int extent1[6],
int extent2[6]);
1166 static vtkTypeBool BoundsIsWithinOtherBounds(
double bounds1[6],
double bounds2[6],
double delta[3]);
1173 static vtkTypeBool PointIsWithinBounds(
double point[3],
double bounds[6],
double delta[3]);
1184 static int PlaneIntersectsAABB(
double const bounds[6],
double const normal[3],
1185 double const point[3]);
1196 static double Solve3PointCircle(
const double p1[3],
const double p2[3],
const double p3[3],
double center[3]);
1201 static double Inf();
1206 static double NegInf();
1211 static double Nan();
1226 static bool IsFinite(
double x);
1234 void operator=(
const vtkMath&) =
delete;
1240 return x * 0.017453292f;
1246 return x * 0.017453292519943295;
1252 return x * 57.2957795131f;
1258 return x * 57.29577951308232;
1264 return ((x != 0) & ((x & (x - 1)) == 0));
1271 unsigned int z = ((x > 0) ? x - 1 : 0);
1277 return static_cast<int>(z + 1);
1285 int i = static_cast<int>(x);
1286 return i - ( i > x );
1294 int i = static_cast<int>(x);
1295 return i + ( i < x );
1302 return (b <= a ? b : a);
1309 return (b > a ? b : a);
1318 for (
int i=0; i < 3; i++)
1332 for (
int i=0; i < 3; i++)
1346 for (
int i=0; i < 2; i++)
1360 for (
int i=0; i < 2; i++)
1373 return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1374 c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1382 return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1383 c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1388 double b1,
double b2,
double b3,
1389 double c1,
double c2,
double c3)
1400 return ( ( p1[0] - p2[0] ) * ( p1[0] - p2[0] )
1401 + ( p1[1] - p2[1] ) * ( p1[1] - p2[1] )
1402 + ( p1[2] - p2[2] ) * ( p1[2] - p2[2] ) );
1409 return ( ( p1[0] - p2[0] ) * ( p1[0] - p2[0] )
1410 + ( p1[1] - p2[1] ) * ( p1[1] - p2[1] )
1411 + ( p1[2] - p2[2] ) * ( p1[2] - p2[2] ) );
1418 float Cx = a[1] * b[2] - a[2] * b[1];
1419 float Cy = a[2] * b[0] - a[0] * b[2];
1420 float Cz = a[0] * b[1] - a[1] * b[0];
1421 c[0] = Cx; c[1] = Cy; c[2] = Cz;
1428 double Cx = a[1] * b[2] - a[2] * b[1];
1429 double Cy = a[2] * b[0] - a[0] * b[2];
1430 double Cz = a[0] * b[1] - a[1] * b[0];
1431 c[0] = Cx; c[1] = Cy; c[2] = Cz;
1438 return A[0][0] * A[1][1] * A[2][2] + A[1][0] * A[2][1] * A[0][2] +
1439 A[2][0] * A[0][1] * A[1][2] - A[0][0] * A[2][1] * A[1][2] -
1440 A[1][0] * A[0][1] * A[2][2] - A[2][0] * A[1][1] * A[0][2];
1459 assert(
"pre: valid_range" && min<=
max);
1479 assert(
"pre: valid_range" &&
range[0]<=
range[1]);
1494 double value,
const double range[2],
double *clamped_value)
1496 if (
range && clamped_value)
1498 assert(
"pre: valid_range" &&
range[0]<=
range[1]);
1502 *clamped_value =
range[0];
1506 *clamped_value =
range[1];
1510 *clamped_value =
value;
1517 const double range[2])
1519 assert(
"pre: valid_range" &&
range[0]<=
range[1]);
1549 assert(
"post: valid_result" && result>=0.0 && result<=1.0);
1555 template<
class T1,
class T2>
1558 for (
int i = 0; i < 3; i++)
1560 tensor[4*i] = symmTensor[i];
1562 tensor[1] = tensor[3] = symmTensor[3];
1563 tensor[2] = tensor[6] = symmTensor[5];
1564 tensor[5] = tensor[7] = symmTensor[4];
1571 tensor[6] = tensor[5];
1572 tensor[7] = tensor[4];
1573 tensor[8] = tensor[2];
1574 tensor[4] = tensor[1];
1575 tensor[5] = tensor[7];
1576 tensor[2] = tensor[6];
1577 tensor[1] = tensor[3];
1583 template <
typename OutT>
1588 *ret = static_cast<OutT>((val >= 0.0) ? (val + 0.5) : (val - 0.5));
1600 *retVal = static_cast<float>(val);
1605 #if defined(VTK_HAS_ISINF) || defined(VTK_HAS_STD_ISINF) 1606 #define VTK_MATH_ISINF_IS_INLINE 1609 #if defined(VTK_HAS_STD_ISINF) 1610 return std::isinf(x);
1612 return (isinf(x) != 0);
1618 #if defined(VTK_HAS_ISNAN) || defined(VTK_HAS_STD_ISNAN) 1619 #define VTK_MATH_ISNAN_IS_INLINE 1622 #if defined(VTK_HAS_STD_ISNAN) 1625 return (
isnan(x) != 0);
1631 #if defined(VTK_HAS_ISFINITE) || defined(VTK_HAS_STD_ISFINITE) || defined(VTK_HAS_FINITE) 1632 #define VTK_MATH_ISFINITE_IS_INLINE 1635 #if defined(VTK_HAS_STD_ISFINITE) 1636 return std::isfinite(x);
1637 #elif defined(VTK_HAS_ISFINITE) 1638 return (isfinite(x) != 0);
1640 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).
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.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static bool IsPowerOfTwo(vtkTypeUInt64 x)
Returns true if integer is a power of two.
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 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-precision 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.
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.
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 double Determinant3x3(float A[3][3])
Return the determinant of a 3x3 matrix.
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 (float 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.
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 void Outer(const double a[3], const double b[3], double C[3][3])
Outer product of two 3-vectors (double-precision version).
static T ClampValue(const T &value, const T &min, const T &max)
Clamp some value against a range, return the result.
static void TensorFromSymmetricTensor(T1 symmTensor[6], T2 tensor[9])
Convert a 6-Component symmetric tensor into a 9-Component tensor, no allocation performed.
static double Norm2D(const double x[2])
Compute the norm of a 2-vector.
static void Outer(const float a[3], const float b[3], float C[3][3])
Outer product of two 3-vectors (float version).
static int Round(double f)
static double Norm(const double v[3])
Compute the norm of 3-vector (double-precision 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 vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
double vtkDeterminant3x3(T A[3][3])
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.