48 #include "vtkCommonCoreModule.h"
53 #include "vtkMathConfigure.h"
58 # define VTK_DBL_MIN 2.2250738585072014e-308
60 # define VTK_DBL_MIN DBL_MIN
64 # define VTK_DBL_EPSILON 2.2204460492503131e-16
66 # define VTK_DBL_EPSILON DBL_EPSILON
69 #ifndef VTK_DBL_EPSILON
71 # define VTK_DBL_EPSILON 2.2204460492503131e-16
73 # define VTK_DBL_EPSILON DBL_EPSILON
79 class vtkMathInternal;
86 template <
typename OutT>
100 static double Pi() {
return 3.141592653589793; };
106 static float RadiansFromDegrees(
float degrees);
107 static double RadiansFromDegrees(
double degrees);
114 static float DegreesFromRadians(
float radians);
115 static double DegreesFromRadians(
double radians);
122 return static_cast<int>( f + ( f >= 0.0 ? 0.5 : -0.5 ) ); }
124 return static_cast<int>( f + ( f >= 0.0 ? 0.5 : -0.5 ) ); }
130 template <
typename OutT>
143 static int Floor(
double x);
150 static int Ceil(
double x);
163 static T Min(
const T & a,
const T & b);
169 static T Max(
const T & a,
const T & b);
174 static bool IsPowerOfTwo(vtkTypeUInt64 x);
181 static int NearestPowerOfTwo(
int x);
315 static void Add(
const float a[3],
const float b[3],
float c[3]) {
316 for (
int i = 0; i < 3; ++i)
323 static void Add(
const double a[3],
const double b[3],
double c[3]) {
324 for (
int i = 0; i < 3; ++i)
331 static void Subtract(
const float a[3],
const float b[3],
float c[3]) {
332 for (
int i = 0; i < 3; ++i)
339 static void Subtract(
const double a[3],
const double b[3],
double c[3]) {
340 for (
int i = 0; i < 3; ++i)
349 for (
int i = 0; i < 3; ++i)
358 for (
int i = 0; i < 2; ++i)
367 for (
int i = 0; i < 3; ++i)
376 for (
int i = 0; i < 2; ++i)
383 static float Dot(
const float a[3],
const float b[3]) {
384 return ( a[0] * b[0] + a[1] * b[1] + a[2] * b[2] );};
389 static double Dot(
const double a[3],
const double b[3]) {
390 return ( a[0] * b[0] + a[1] * b[1] + a[2] * b[2] );};
395 static void Outer(
const float a[3],
const float b[3],
float C[3][3]) {
396 for (
int i=0; i < 3; i++)
397 for (
int j=0; j < 3; j++)
398 C[i][j] = a[i] * b[j];
403 static void Outer(
const double a[3],
const double b[3],
double C[3][3]) {
404 for (
int i=0; i < 3; i++)
405 for (
int j=0; j < 3; j++)
406 C[i][j] = a[i] * b[j];
412 static void Cross(
const float a[3],
const float b[3],
float c[3]);
418 static void Cross(
const double a[3],
const double b[3],
double c[3]);
424 static float Norm(
const float* x,
int n);
425 static double Norm(
const double* x,
int n);
431 static float Norm(
const float v[3]) {
432 return static_cast<float> (sqrt( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] ) );};
437 static double Norm(
const double v[3]) {
438 return sqrt( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] );};
443 static float Normalize(
float v[3]);
449 static double Normalize(
double v[3]);
471 static bool ProjectVector(
const float a[3],
const float b[3],
float projection[3]);
472 static bool ProjectVector(
const double a[3],
const double b[3],
double projection[3]);
483 static bool ProjectVector2D(
const double a[2],
const double b[2],
double projection[2]);
489 static float Distance2BetweenPoints(
const float p1[3],
const float p2[3]);
495 static double Distance2BetweenPoints(
const double p1[3],
const double p2[3]);
519 static double GaussianWeight(
const double variance,
const double distanceFromMean);
531 static float Dot2D(
const float x[2],
const float y[2]) {
532 return ( x[0] * y[0] + x[1] * y[1] );};
537 static double Dot2D(
const double x[2],
const double y[2]) {
538 return ( x[0] * y[0] + x[1] * y[1] );};
543 static void Outer2D(
const float x[2],
const float y[2],
float A[2][2])
545 for (
int i=0; i < 2; i++)
547 for (
int j=0; j < 2; j++)
549 A[i][j] = x[i] * y[j];
556 static void Outer2D(
const double x[2],
const double y[2],
double A[2][2])
558 for (
int i=0; i < 2; i++)
560 for (
int j=0; j < 2; j++)
562 A[i][j] = x[i] * y[j];
571 return static_cast<float> (sqrt( x[0] * x[0] + x[1] * x[1] ) );};
577 static double Norm2D(
const double x[2]) {
578 return sqrt( x[0] * x[0] + x[1] * x[1] );};
595 return (c1[0] * c2[1] - c2[0] * c1[1] );};
602 return (a * d - b * c);};
604 return (c1[0] * c2[1] - c2[0] * c1[1] );};
652 static void Multiply3x3(
const double A[3][3],
const double B[3][3],
662 unsigned int rowA,
unsigned int colA,
663 unsigned int rowB,
unsigned int colB,
680 static void Invert3x3(
const float A[3][3],
float AI[3][3]);
681 static void Invert3x3(
const double A[3][3],
double AI[3][3]);
696 static double Determinant3x3(
float A[3][3]);
697 static double Determinant3x3(
double A[3][3]);
703 static float Determinant3x3(
const float c1[3],
710 static double Determinant3x3(
const double c1[3],
720 static double Determinant3x3(
double a1,
double a2,
double a3,
721 double b1,
double b2,
double b3,
722 double c1,
double c2,
double c3);
792 float U[3][3],
float w[3],
795 double U[3][3],
double w[3],
821 int *tmp1Size,
double *tmp2Size);
864 double *x,
int size);
885 static int Jacobi(
float **a,
float *w,
float **v);
886 static int Jacobi(
double **a,
double *w,
double **v);
899 static int JacobiN(
float **a,
int n,
float *w,
float **v);
900 static int JacobiN(
double **a,
int n,
double *w,
double **v);
935 double **yt,
int yOrder,
double **mt,
int checkHomogeneous=1);
945 static void RGBToHSV(
const float rgb[3],
float hsv[3])
946 { RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); }
947 static void RGBToHSV(
float r,
float g,
float b,
float *h,
float *s,
float *v);
949 static double*
RGBToHSV(
double r,
double g,
double b);
950 static void RGBToHSV(
const double rgb[3],
double hsv[3])
951 { RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); }
952 static void RGBToHSV(
double r,
double g,
double b,
double *h,
double *s,
double *v);
963 static void HSVToRGB(
const float hsv[3],
float rgb[3])
964 { HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); }
965 static void HSVToRGB(
float h,
float s,
float v,
float *r,
float *g,
float *b);
967 static double*
HSVToRGB(
double h,
double s,
double v);
968 static void HSVToRGB(
const double hsv[3],
double rgb[3])
969 { HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); }
970 static void HSVToRGB(
double h,
double s,
double v,
double *r,
double *g,
double *b);
977 static void LabToXYZ(
const double lab[3],
double xyz[3]) {
978 LabToXYZ(lab[0], lab[1], lab[2], xyz+0, xyz+1, xyz+2);
981 double *x,
double *y,
double *z);
989 static void XYZToLab(
const double xyz[3],
double lab[3]) {
990 XYZToLab(xyz[0], xyz[1], xyz[2], lab+0, lab+1, lab+2);
993 double *L,
double *a,
double *b);
1001 static void XYZToRGB(
const double xyz[3],
double rgb[3]) {
1002 XYZToRGB(xyz[0], xyz[1], xyz[2], rgb+0, rgb+1, rgb+2);
1005 double *r,
double *g,
double *b);
1013 static void RGBToXYZ(
const double rgb[3],
double xyz[3]) {
1014 RGBToXYZ(rgb[0], rgb[1], rgb[2], xyz+0, xyz+1, xyz+2);
1017 double *x,
double *y,
double *z);
1028 static void RGBToLab(
const double rgb[3],
double lab[3]) {
1029 RGBToLab(rgb[0], rgb[1], rgb[2], lab+0, lab+1, lab+2);
1031 static void RGBToLab(
double red,
double green,
double blue,
1032 double *L,
double *a,
double *b);
1040 static void LabToRGB(
const double lab[3],
double rgb[3]) {
1041 LabToRGB(lab[0], lab[1], lab[2], rgb+0, rgb+1, rgb+2);
1044 double *red,
double *green,
double *blue);
1067 if ( bounds[1]-bounds[0]<0.0 )
1080 static T ClampValue(
const T &
value,
const T & min,
const T &
max);
1087 static void ClampValue(
double *
value,
const double range[2]);
1088 static void ClampValue(
double value,
const double range[2],
double *clamped_value);
1090 double *values,
int nb_values,
const double range[2]);
1092 const double *values,
int nb_values,
const double range[2],
double *clamped_values);
1101 static double ClampAndNormalizeValue(
double value,
1102 const double range[2]);
1113 double range_min,
double range_max,
1114 double scale = 1.0,
double shift = 0.0);
1195 void operator=(
const vtkMath&) VTK_DELETE_FUNCTION;
1201 return x * 0.017453292f;
1207 return x * 0.017453292519943295;
1213 return x * 57.2957795131f;
1219 return x * 57.29577951308232;
1225 return ((x != 0) & ((x & (x - 1)) == 0));
1232 unsigned int z = ((x > 0) ? x - 1 : 0);
1238 return static_cast<int>(z + 1);
1246 int i =
static_cast<int>(x);
1247 return i - ( i > x );
1255 int i =
static_cast<int>(x);
1256 return i + ( i < x );
1263 return (a < b ? a : b);
1270 return (a > b ? a : b);
1279 for (
int i=0; i < 3; i++)
1293 for (
int i=0; i < 3; i++)
1307 for (
int i=0; i < 2; i++)
1321 for (
int i=0; i < 2; i++)
1334 return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1335 c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1343 return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
1344 c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
1349 double b1,
double b2,
double b3,
1350 double c1,
double c2,
double c3)
1361 return ( ( p1[0] - p2[0] ) * ( p1[0] - p2[0] )
1362 + ( p1[1] - p2[1] ) * ( p1[1] - p2[1] )
1363 + ( p1[2] - p2[2] ) * ( p1[2] - p2[2] ) );
1370 return ( ( p1[0] - p2[0] ) * ( p1[0] - p2[0] )
1371 + ( p1[1] - p2[1] ) * ( p1[1] - p2[1] )
1372 + ( p1[2] - p2[2] ) * ( p1[2] - p2[2] ) );
1379 float Cx = a[1] * b[2] - a[2] * b[1];
1380 float Cy = a[2] * b[0] - a[0] * b[2];
1381 float Cz = a[0] * b[1] - a[1] * b[0];
1382 c[0] = Cx; c[1] = Cy; c[2] = Cz;
1389 double Cx = a[1] * b[2] - a[2] * b[1];
1390 double Cy = a[2] * b[0] - a[0] * b[2];
1391 double Cz = a[0] * b[1] - a[1] * b[0];
1392 c[0] = Cx; c[1] = Cy; c[2] = Cz;
1399 return A[0][0] * A[1][1] * A[2][2] + A[1][0] * A[2][1] * A[0][2] +
1400 A[2][0] * A[0][1] * A[1][2] - A[0][0] * A[2][1] * A[1][2] -
1401 A[1][0] * A[0][1] * A[2][2] - A[2][0] * A[1][1] * A[0][2];
1420 assert(
"pre: valid_range" && min<=
max);
1440 assert(
"pre: valid_range" &&
range[0]<=
range[1]);
1455 double value,
const double range[2],
double *clamped_value)
1457 if (
range && clamped_value)
1459 assert(
"pre: valid_range" &&
range[0]<=
range[1]);
1463 *clamped_value =
range[0];
1467 *clamped_value =
range[1];
1471 *clamped_value =
value;
1478 const double range[2])
1480 assert(
"pre: valid_range" &&
range[0]<=
range[1]);
1510 assert(
"post: valid_result" && result>=0.0 && result<=1.0);
1518 template <
typename OutT>
1523 *ret =
static_cast<OutT
>((val >= 0.0) ? (val + 0.5) : (val - 0.5));
1535 *retVal =
static_cast<float>(val);
1540 #if defined(VTK_HAS_ISINF) || defined(VTK_HAS_STD_ISINF)
1541 #define VTK_MATH_ISINF_IS_INLINE
1544 #if defined(VTK_HAS_STD_ISINF)
1545 return std::isinf(x);
1547 return (isinf(x) != 0);
1553 #if defined(VTK_HAS_ISNAN) || defined(VTK_HAS_STD_ISNAN)
1554 #define VTK_MATH_ISNAN_IS_INLINE
1557 #if defined(VTK_HAS_STD_ISNAN)
1558 return std::isnan(x);
1560 return (isnan(x) != 0);
1566 #if defined(VTK_HAS_ISFINITE) || defined(VTK_HAS_STD_ISFINITE) || defined(VTK_HAS_FINITE)
1567 #define VTK_MATH_ISFINITE_IS_INLINE
1570 #if defined(VTK_HAS_STD_ISFINITE)
1571 return std::isfinite(x);
1572 #elif defined(VTK_HAS_ISFINITE)
1573 return (isfinite(x) != 0);
1575 return (finite(x) != 0);
Gaussian sequence of pseudo random numbers implemented with the Box-Mueller transform.
abstract superclass for arrays of numeric data
a simple class to control print indentation
performs common math operations
static void Multiply3x3(const float A[3][3], const float B[3][3], float C[3][3])
Multiply one 3x3 matrix by another according to C = AB.
static double Dot(const double a[3], const double b[3])
Dot product of two 3-vectors (double-precision version).
static int Jacobi(double **a, double *w, double **v)
static int GetScalarTypeFittingRange(double range_min, double range_max, double scale=1.0, double shift=0.0)
Return the scalar type that is most likely to have enough precision to store a given range of data on...
static void RGBToXYZ(double r, double g, double b, double *x, double *y, double *z)
static void Multiply3x3(const double A[3][3], const double B[3][3], double C[3][3])
static double Norm(const double *x, int n)
static int Round(float f)
Rounds a float to the nearest integer.
static int * BeginCombination(int m, int n)
Start iterating over "m choose n" objects.
static double Norm2D(const double x[2])
Compute the norm of a 2-vector.
static void XYZToRGB(double x, double y, double z, double *r, double *g, double *b)
static void Matrix3x3ToQuaternion(const double A[3][3], double quat[4])
static void Subtract(const float a[3], const float b[3], float c[3])
Subtraction of two 3-vectors (float version).
static void LUSolve3x3(const double A[3][3], const int index[3], double x[3])
static void Multiply3x3(const double A[3][3], const double in[3], double out[3])
static void Outer2D(const float x[2], const float y[2], float A[2][2])
Outer product of two 2-vectors (float version).
static bool ProjectVector(const double a[3], const double b[3], double projection[3])
static vtkSmartPointer< vtkMathInternal > Internal
static float Norm(const float *x, int n)
Compute the norm of n-vector.
static void Add(const double a[3], const double b[3], double c[3])
Addition of two 3-vectors (double version).
static void RGBToHSV(float r, float g, float b, float *h, float *s, float *v)
static float Norm(const float v[3])
Compute the norm of 3-vector.
static void XYZToLab(const double xyz[3], double lab[3])
Convert Color from the CIE XYZ system to CIE-L*ab.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkTypeInt64 Factorial(int N)
Compute N factorial, N! = N*(N-1) * (N-2)...*3*2*1.
static vtkTypeInt64 Binomial(int m, int n)
The number of combinations of n objects from a pool of m objects (m>n).
static vtkTypeBool BoundsIsWithinOtherBounds(double bounds1[6], double bounds2[6], double delta[3])
Return true if first 3D bounds is within the second 3D bounds Bounds is x-min, x-max,...
static double Random()
Generate pseudo-random numbers distributed according to the uniform distribution between 0....
static void Identity3x3(float A[3][3])
Set A to the identity matrix.
static double GaussianAmplitude(const double variance, const double distanceFromMean)
Compute the amplitude of a Gaussian function with mean=0 and specified variance.
static void SingularValueDecomposition3x3(const float A[3][3], float U[3][3], float w[3], float VT[3][3])
Perform singular value decomposition on a 3x3 matrix.
static double Nan()
Special IEEE-754 number used to represent Not-A-Number (Nan).
static void Perpendiculars(const float v1[3], float v2[3], float v3[3], double theta)
static int GetAdjustedScalarRange(vtkDataArray *array, int comp, double range[2])
Get a vtkDataArray's scalar range for a given component.
static double Gaussian(double mean, double std)
Generate pseudo-random numbers distributed according to the Gaussian distribution with mean mean and ...
static bool IsFinite(double x)
Test if a number has finite value i.e.
static void LUSolveLinearSystem(double **A, int *index, double *x, int size)
Solve linear equations Ax = b using LU decomposition A = LU where L is lower triangular matrix and U ...
static void LUFactor3x3(float A[3][3], int index[3])
LU Factorization of a 3x3 matrix.
static void FreeCombination(int *combination)
Free the "iterator" array created by vtkMath::BeginCombination.
static double Random(double min, double max)
Generate pseudo-random numbers distributed according to the uniform distribution between min and max.
static void LabToXYZ(const double lab[3], double xyz[3])
Convert color from the CIE-L*ab system to CIE XYZ.
static double Solve3PointCircle(const double p1[3], const double p2[3], const double p3[3], double center[3])
In Euclidean space, there is a unique circle passing through any given three non-collinear points P1,...
static double * HSVToRGB(double h, double s, double v)
static vtkTypeBool AreBoundsInitialized(double bounds[6])
Are the bounds initialized?
static float Dot(const float a[3], const float b[3])
Dot product of two 3-vectors (float version).
static void Diagonalize3x3(const float A[3][3], float w[3], float V[3][3])
Diagonalize a symmetric 3x3 matrix and return the eigenvalues in w and the eigenvectors in the column...
static void LabToXYZ(double L, double a, double b, double *x, double *y, double *z)
static bool ProjectVector(const float a[3], const float b[3], float projection[3])
Compute the projection of vector a on vector b and return it in projection[3].
static void Cross(const float a[3], const float b[3], float c[3])
Cross product of two 3-vectors.
static void MultiplyScalar2D(float a[2], float s)
Multiplies a 2-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 double Determinant2x2(const double c1[2], const double c2[2])
static T Max(const T &a, const T &b)
Returns the maximum of the two arugments provided.
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 RandomSeed(int s)
Initialize seed value.
static double Normalize2D(double v[2])
Normalize (in place) a 2-vector.
static double NegInf()
Special IEEE-754 number used to represent negative infinity.
static void MultiplyScalar2D(double a[2], double s)
Multiplies a 2-vector by a scalar (double version).
static void LabToRGB(double L, double a, double b, double *red, double *green, double *blue)
static double Gaussian()
Generate pseudo-random numbers distributed according to the standard normal distribution.
static void Multiply3x3(const float A[3][3], const float in[3], float out[3])
Multiply a vector by a 3x3 matrix.
static int Ceil(double x)
Rounds a double to the nearest integer not less than itself.
static void HSVToRGB(const double hsv[3], double rgb[3])
static double Inf()
Special IEEE-754 number used to represent positive infinity.
static double GaussianAmplitude(const double mean, const double variance, const double position)
Compute the amplitude of a Gaussian function with specified mean and variance.
static float Normalize2D(float v[2])
Normalize (in place) a 2-vector.
static void RGBToXYZ(const double rgb[3], double xyz[3])
Convert color from the RGB system to CIE XYZ.
static float Distance2BetweenPoints(const float p1[3], const float p2[3])
Compute distance squared between two points p1 and p2.
static int NearestPowerOfTwo(int x)
Compute the nearest power of two that is not less than x.
static void HSVToRGB(double h, double s, double v, double *r, double *g, double *b)
static void SingularValueDecomposition3x3(const double A[3][3], double U[3][3], double w[3], double VT[3][3])
static void Invert3x3(const double A[3][3], double AI[3][3])
static void HSVToRGB(float h, float s, float v, float *r, float *g, float *b)
static void MultiplyQuaternion(const double q1[4], const double q2[4], double q[4])
static int JacobiN(float **a, int n, float *w, float **v)
JacobiN iteration for the solution of eigenvectors/eigenvalues of a nxn real symmetric matrix.
static void LUSolve3x3(const float A[3][3], const int index[3], float x[3])
LU back substitution for a 3x3 matrix.
static int GetSeed()
Return the current seed used by the random number generator.
static float RadiansFromDegrees(float degrees)
Convert degrees into radians.
static vtkTypeBool PointIsWithinBounds(double point[3], double bounds[6], double delta[3])
Return true if point is within the given 3D bounds Bounds is x-min, x-max, y-min, y-max,...
static void MultiplyMatrix(double **A, double **B, unsigned int rowA, unsigned int colA, unsigned int rowB, unsigned int colB, double **C)
General matrix multiplication.
static void Add(const float a[3], const float b[3], float c[3])
Addition of two 3-vectors (float version).
static int CeilLog2(vtkTypeUInt64 x)
Gives the exponent of the lowest power of two not less than x.
static void Outer(const float a[3], const float b[3], float C[3][3])
Outer product of two 3-vectors (float version).
static double Pi()
A mathematical constant.
static vtkTypeBool ExtentIsWithinOtherExtent(int extent1[6], int extent2[6])
Return true if first 3D extent is within second 3D extent Extent is x-min, x-max, y-min,...
static bool ProjectVector2D(const double a[2], const double b[2], double projection[2])
static int InvertMatrix(double **A, double **AI, int size)
Invert input square matrix A into matrix AI.
static int SolveLeastSquares(int numberOfSamples, double **xt, int xOrder, double **yt, int yOrder, double **mt, int checkHomogeneous=1)
Solves for the least squares best fit matrix for the equation X'M' = Y'.
static int NextCombination(int m, int n, int *combination)
Given m, n, and a valid combination of n integers in the range [0,m[, this function alters the intege...
static double GaussianWeight(const double variance, const double distanceFromMean)
Compute the amplitude of an unnormalized Gaussian function with mean=0 and specified variance.
static void Subtract(const double a[3], const double b[3], double c[3])
Subtraction of two 3-vectors (double version).
static double * LabToXYZ(const double lab[3])
static void Orthogonalize3x3(const double A[3][3], double B[3][3])
static void XYZToRGB(const double xyz[3], double rgb[3])
Convert color from the CIE XYZ system to RGB.
static double ClampAndNormalizeValue(double value, const double range[2])
Clamp a value against a range and then normalized it between 0 and 1.
static void MultiplyScalar(double a[3], double s)
Multiplies a 3-vector by a scalar (double version).
static int SolveHomogeneousLeastSquares(int numberOfSamples, double **xt, int xOrder, double **mt)
Solves for the least squares best fit matrix for the homogeneous equation X'M' = 0'.
static double Dot2D(const double x[2], const double y[2])
Dot product of two 2-vectors.
static void LinearSolve3x3(const float A[3][3], const float x[3], float y[3])
Solve Ay = x for y and place the result in y.
static vtkTypeBool IsNan(double x)
Test if a number is equal to the special floating point value Not-A-Number (Nan).
static void Diagonalize3x3(const double A[3][3], double w[3], double V[3][3])
static void RGBToLab(const double rgb[3], double lab[3])
Convert color from the RGB system to CIE-L*ab.
static int Floor(double x)
Rounds a double to the nearest integer not greater than itself.
static double * RGBToXYZ(const double rgb[3])
static double Determinant2x2(double a, double b, double c, double d)
Calculate the determinant of a 2x2 matrix: | a b | | c d |.
static double * XYZToLab(const double xyz[3])
static double EstimateMatrixCondition(double **A, int size)
Estimate the condition number of a LU factored matrix.
static void RGBToHSV(const double rgb[3], double hsv[3])
static double AngleBetweenVectors(const double v1[3], const double v2[3])
Compute angle in radians between two vectors.
static float DegreesFromRadians(float radians)
Convert radians into degrees.
static float Determinant2x2(const float c1[2], const float c2[2])
Compute determinant of 2x2 matrix.
static int Round(double f)
static vtkTypeBool IsInf(double x)
Test if a number is equal to the special floating point value infinity.
static void UninitializeBounds(double bounds[6])
Set the bounds to an uninitialized state.
static void RGBToHSV(double r, double g, double b, double *h, double *s, double *v)
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 double * RGBToLab(const double rgb[3])
static double Norm(const double v[3])
Compute the norm of 3-vector (double-precision version).
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 int InvertMatrix(double **A, double **AI, int size, int *tmp1Size, double *tmp2Size)
Thread safe version of InvertMatrix method.
static void Matrix3x3ToQuaternion(const float A[3][3], float quat[4])
Convert a 3x3 matrix into a quaternion.
static bool IsPowerOfTwo(vtkTypeUInt64 x)
Returns true if integer is a power of two.
static void Invert3x3(const float A[3][3], float AI[3][3])
Invert a 3x3 matrix.
static float Normalize(float v[3])
Normalize (in place) a 3-vector.
static void Transpose3x3(const double A[3][3], double AT[3][3])
static float Dot2D(const float x[2], const float y[2])
Dot product of two 2-vectors.
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 * RGBToHSV(const double rgb[3])
static int LUFactorLinearSystem(double **A, int *index, int size)
Factor linear equations Ax = b using LU decomposition into the form A = LU where L is a unit lower tr...
static void Orthogonalize3x3(const float A[3][3], float B[3][3])
Orthogonalize a 3x3 matrix and put the result in B.
static bool ProjectVector2D(const float a[2], const float b[2], float projection[2])
Compute the projection of 2D vector a on 2D vector b and returns the result in projection[2].
static int Jacobi(float **a, float *w, float **v)
Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix.
static void LabToRGB(const double lab[3], double rgb[3])
Convert color from the CIE-L*ab system to RGB.
static float Norm2D(const float x[2])
Compute the norm of a 2-vector.
static double Determinant3x3(float A[3][3])
Return the determinant of a 3x3 matrix.
static double GaussianWeight(const double mean, const double variance, const double position)
Compute the amplitude of an unnormalized Gaussian function with specified mean and variance.
static void LinearSolve3x3(const double A[3][3], const double x[3], double y[3])
static void XYZToLab(double x, double y, double z, double *L, double *a, double *b)
static void MultiplyScalar(float a[3], float s)
Multiplies a 3-vector by a scalar (float version).
static T Min(const T &a, const T &b)
Returns the minimum of the two arguments provided.
static int SolveLinearSystem(double **A, double *x, int size)
Solve linear equations Ax = b using Crout's method.
static void QuaternionToMatrix3x3(const double quat[4], double A[3][3])
static void Perpendiculars(const double v1[3], double v2[3], double v3[3], double theta)
Given a unit vector v1, find two unit vectors v2 and v3 such that v1 cross v2 = v3 (i....
static int LUFactorLinearSystem(double **A, int *index, int size, double *tmpSize)
Thread safe version of LUFactorLinearSystem method.
static double * RGBToHSV(double r, double g, double b)
static T ClampValue(const T &value, const T &min, const T &max)
Clamp some value against a range, return the result.
static int JacobiN(double **a, int n, double *w, double **v)
static void Identity3x3(double A[3][3])
static double * HSVToRGB(const double hsv[3])
static void LUFactor3x3(double A[3][3], int index[3])
static void RGBToLab(double red, double green, double blue, double *L, double *a, double *b)
static double * LabToRGB(const double lab[3])
static void MultiplyQuaternion(const float q1[4], const float q2[4], float q[4])
Multiply two quaternions.
static double * XYZToRGB(const double xyz[3])
static void QuaternionToMatrix3x3(const float quat[4], float A[3][3])
Convert a quaternion to a 3x3 rotation matrix.
static void ClampValues(const double *values, int nb_values, const double range[2], double *clamped_values)
static void Transpose3x3(const float A[3][3], float AT[3][3])
Transpose a 3x3 matrix.
static void ClampValues(double *values, int nb_values, const double range[2])
Park and Miller Sequence of pseudo random numbers.
abstract base class for most VTK objects
represent and manipulate 3D points
void RoundDoubleToIntegralIfNecessary(double val, OutT *ret)
Template defining traits of native types used by VTK.
double vtkDeterminant3x3(T A[3][3])