136#include "vtkCommonCoreModule.h"
137#include "vtkMathPrivate.hxx"
143#include "vtkMathConfigure.h"
147#include <type_traits>
150#define VTK_DBL_MIN 2.2250738585072014e-308
152#define VTK_DBL_MIN DBL_MIN
156#define VTK_DBL_EPSILON 2.2204460492503131e-16
158#define VTK_DBL_EPSILON DBL_EPSILON
161#ifndef VTK_DBL_EPSILON
163#define VTK_DBL_EPSILON 2.2204460492503131e-16
165#define VTK_DBL_EPSILON DBL_EPSILON
169VTK_ABI_NAMESPACE_BEGIN
172class vtkMathInternal;
179VTK_ABI_NAMESPACE_BEGIN
181template <
typename OutT>
186VTK_ABI_NAMESPACE_BEGIN
195 template <
class VectorT,
class =
void>
196 struct VectorImplementsSize : std::false_type
200 template <
class VectorT>
201 struct VectorImplementsSize<VectorT, decltype((void)
std::declval<VectorT>().size(), void())>
209 template <
class VectorT>
210 using EnableIfVectorImplementsSize =
211 typename std::enable_if<VectorImplementsSize<VectorT>::value>::type;
227 static constexpr double Pi() {
return 3.141592653589793; }
233 static float RadiansFromDegrees(
float degrees);
234 static double RadiansFromDegrees(
double degrees);
241 static float DegreesFromRadians(
float radians);
242 static double DegreesFromRadians(
double radians);
249 static int Round(
float f) {
return static_cast<int>(f + (f >= 0.0 ? 0.5 : -0.5)); }
250 static int Round(
double f) {
return static_cast<int>(f + (f >= 0.0 ? 0.5 : -0.5)); }
257 template <
typename OutT>
270 static int Floor(
double x);
277 static int Ceil(
double x);
291 static T
Min(
const T& a,
const T& b);
298 static T
Max(
const T& a,
const T& b);
477 template <
class VectorT1,
class VectorT2>
478 static void Assign(
const VectorT1& a, VectorT2&& b)
493 static void Add(
const float a[3],
const float b[3],
float c[3])
495 for (
int i = 0; i < 3; ++i)
504 static void Add(
const double a[3],
const double b[3],
double c[3])
506 for (
int i = 0; i < 3; ++i)
517 template <
class VectorT1,
class VectorT2,
class VectorT3>
518 static void Add(VectorT1&& a, VectorT2&& b, VectorT3& c)
520 for (
int i = 0; i < 3; ++i)
529 static void Subtract(
const float a[3],
const float b[3],
float c[3])
531 for (
int i = 0; i < 3; ++i)
540 static void Subtract(
const double a[3],
const double b[3],
double c[3])
542 for (
int i = 0; i < 3; ++i)
553 template <
class VectorT1,
class VectorT2,
class VectorT3>
554 static void Subtract(
const VectorT1& a,
const VectorT2& b, VectorT3&& c)
567 for (
int i = 0; i < 3; ++i)
579 for (
int i = 0; i < 2; ++i)
591 for (
int i = 0; i < 3; ++i)
603 for (
int i = 0; i < 2; ++i)
612 static float Dot(
const float a[3],
const float b[3])
614 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
620 static double Dot(
const double a[3],
const double b[3])
622 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
640 template <
typename ReturnTypeT = double,
typename TupleRangeT1,
typename TupleRangeT2,
641 typename EnableT =
typename std::conditional<!std::is_pointer<TupleRangeT1>::value &&
642 !std::is_array<TupleRangeT1>::value,
643 TupleRangeT1, TupleRangeT2>::type::value_type>
644 static ReturnTypeT
Dot(
const TupleRangeT1& a,
const TupleRangeT2& b)
646 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
652 static void Outer(
const float a[3],
const float b[3],
float c[3][3])
654 for (
int i = 0; i < 3; ++i)
656 for (
int j = 0; j < 3; ++j)
658 c[i][j] = a[i] * b[j];
666 static void Outer(
const double a[3],
const double b[3],
double c[3][3])
668 for (
int i = 0; i < 3; ++i)
670 for (
int j = 0; j < 3; ++j)
672 c[i][j] = a[i] * b[j];
682 template <
class VectorT1,
class VectorT2,
class VectorT3>
683 static void Cross(VectorT1&& a, VectorT2&& b, VectorT3& c);
689 static void Cross(
const float a[3],
const float b[3],
float c[3]);
695 static void Cross(
const double a[3],
const double b[3],
double c[3]);
701 static float Norm(
const float* x,
int n);
702 static double Norm(
const double* x,
int n);
708 static float Norm(
const float v[3]) {
return std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); }
713 static double Norm(
const double v[3])
715 return std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
727 template <
typename ReturnTypeT =
double,
typename TupleRangeT>
730 return v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
737 static inline float Normalize(
float v[3]);
743 static inline double Normalize(
double v[3]);
753 static void Perpendiculars(
const double v1[3],
double v2[3],
double v3[3],
double theta);
754 static void Perpendiculars(
const float v1[3],
float v2[3],
float v3[3],
double theta);
763 static bool ProjectVector(
const float a[3],
const float b[3],
float projection[3]);
764 static bool ProjectVector(
const double a[3],
const double b[3],
double projection[3]);
775 static bool ProjectVector2D(
const double a[2],
const double b[2],
double projection[2]);
793 template <
typename ReturnTypeT = double,
typename TupleRangeT1,
typename TupleRangeT2,
794 typename EnableT =
typename std::conditional<!std::is_pointer<TupleRangeT1>::value &&
795 !std::is_array<TupleRangeT1>::value,
796 TupleRangeT1, TupleRangeT2>::type::value_type>
826 const double v1[3],
const double v2[3],
const double vn[3]);
857 static float Dot2D(
const float x[2],
const float y[2]) {
return x[0] * y[0] + x[1] * y[1]; }
862 static double Dot2D(
const double x[2],
const double y[2]) {
return x[0] * y[0] + x[1] * y[1]; }
867 static void Outer2D(
const float x[2],
const float y[2],
float A[2][2])
869 for (
int i = 0; i < 2; ++i)
871 for (
int j = 0; j < 2; ++j)
873 A[i][j] = x[i] * y[j];
881 static void Outer2D(
const double x[2],
const double y[2],
double A[2][2])
883 for (
int i = 0; i < 2; ++i)
885 for (
int j = 0; j < 2; ++j)
887 A[i][j] = x[i] * y[j];
896 static float Norm2D(
const float x[2]) {
return std::sqrt(x[0] * x[0] + x[1] * x[1]); }
902 static double Norm2D(
const double x[2]) {
return std::sqrt(x[0] * x[0] + x[1] * x[1]); }
908 static float Normalize2D(
float v[2]);
914 static double Normalize2D(
double v[2]);
921 return c1[0] * c2[1] - c2[0] * c1[1];
928 static double Determinant2x2(
double a,
double b,
double c,
double d) {
return a * d - b * c; }
931 return c1[0] * c2[1] - c2[0] * c1[1];
947 static void LUSolve3x3(
const float A[3][3],
const int index[3],
float x[3]);
948 static void LUSolve3x3(
const double A[3][3],
const int index[3],
double x[3]);
957 static void LinearSolve3x3(
const double A[3][3],
const double x[3],
double y[3]);
964 static void Multiply3x3(
const float A[3][3],
const float v[3],
float u[3]);
965 static void Multiply3x3(
const double A[3][3],
const double v[3],
double u[3]);
972 static void Multiply3x3(
const float A[3][3],
const float B[3][3],
float C[3][3]);
973 static void Multiply3x3(
const double A[3][3],
const double B[3][3],
double C[3][3]);
999 template <
int RowsT,
int MidDimT,
int ColsT,
1000 class LayoutT1 = vtkMatrixUtilities::Layout::Identity,
1001 class LayoutT2 = vtkMatrixUtilities::Layout::Identity,
class MatrixT1,
class MatrixT2,
1005 vtkMathPrivate::MultiplyMatrix<RowsT, MidDimT, ColsT, LayoutT1, LayoutT2>::Compute(
1006 std::forward<MatrixT1>(M1), std::forward<MatrixT2>(M2), std::forward<MatrixT3>(M3));
1029 template <
int RowsT,
int ColsT,
class LayoutT = vtkMatrixUtilities::Layout::Identity,
1030 class MatrixT,
class VectorT1,
class VectorT2>
1033 vtkMathPrivate::MultiplyMatrix<RowsT, ColsT, 1, LayoutT>::Compute(
1034 std::forward<MatrixT>(M), std::forward<VectorT1>(X), std::forward<VectorT2>(Y));
1042 template <
class ScalarT,
int SizeT,
class VectorT1,
class VectorT2,
1043 class =
typename std::enable_if<SizeT != DYNAMIC_VECTOR_SIZE()>::type>
1044 static ScalarT
Dot(VectorT1&& x, VectorT2&& y)
1046 return vtkMathPrivate::ContractRowWithCol<ScalarT, 1, SizeT, 1, 0, 0,
1047 vtkMatrixUtilities::Layout::Identity,
1048 vtkMatrixUtilities::Layout::Transpose>::Compute(std::forward<VectorT1>(x),
1049 std::forward<VectorT2>(y));
1058 template <
class ScalarT,
int SizeT,
class VectorT1,
class VectorT2,
1059 class =
typename std::enable_if<SizeT == DYNAMIC_VECTOR_SIZE()>::type,
1060 class = EnableIfVectorImplementsSize<VectorT1>>
1061 static ScalarT
Dot(VectorT1&& x, VectorT2&& y)
1064 using SizeType =
decltype(std::declval<VectorT1>().size());
1065 for (SizeType dim = 0; dim < x.size(); ++dim)
1067 dot += x[dim] * y[dim];
1079 template <
int SizeT,
class VectorT>
1103 template <
int SizeT,
class LayoutT = vtkMatrixUtilities::Layout::Identity,
class MatrixT>
1107 return vtkMathPrivate::Determinant<SizeT, LayoutT>::Compute(std::forward<MatrixT>(M));
1125 template <
int SizeT,
class LayoutT = vtkMatrixUtilities::Layout::Identity,
class MatrixT1,
1129 vtkMathPrivate::InvertMatrix<SizeT, LayoutT>::Compute(
1130 std::forward<MatrixT1>(M1), std::forward<MatrixT2>(M2));
1146 template <
int RowsT,
int ColsT,
class LayoutT = vtkMatrixUtilities::Layout::Identity,
1147 class MatrixT,
class VectorT1,
class VectorT2>
1150 vtkMathPrivate::LinearSolve<RowsT, ColsT, LayoutT>::Compute(
1151 std::forward<MatrixT>(M), std::forward<VectorT1>(x), std::forward<VectorT2>(y));
1168 template <
class ScalarT,
int SizeT,
class LayoutT = vtkMatrixUtilities::Layout::Identity,
1169 class VectorT1,
class MatrixT,
class VectorT2,
1170 class =
typename std::enable_if<SizeT != DYNAMIC_VECTOR_SIZE()>::type>
1171 static ScalarT
Dot(VectorT1&& x, MatrixT&& M, VectorT2&& y)
1174 vtkMathPrivate::MultiplyMatrix<SizeT, SizeT, 1, LayoutT>::Compute(
1175 std::forward<MatrixT>(M), std::forward<VectorT2>(y), tmp);
1176 return vtkMathPrivate::ContractRowWithCol<ScalarT, 1, SizeT, 1, 0, 0,
1177 vtkMatrixUtilities::Layout::Identity,
1178 vtkMatrixUtilities::Layout::Transpose>::Compute(std::forward<VectorT1>(x), tmp);
1186 static void MultiplyMatrix(
const double*
const* A,
const double*
const* B,
unsigned int rowA,
1187 unsigned int colA,
unsigned int rowB,
unsigned int colB,
double** C);
1204 static void Invert3x3(
const double A[3][3],
double AI[3][3]);
1226 static float Determinant3x3(
const float c1[3],
const float c2[3],
const float c3[3]);
1231 static double Determinant3x3(
const double c1[3],
const double c2[3],
const double c3[3]);
1239 static double Determinant3x3(
double a1,
double a2,
double a3,
double b1,
double b2,
double b3,
1240 double c1,
double c2,
double c3);
1252 template <
class QuaternionT,
class MatrixT,
1253 class EnableT =
typename std::enable_if<!vtkMatrixUtilities::MatrixIs2DArray<MatrixT>()>::type>
1269 template <
class MatrixT,
class QuaternionT,
1270 class EnableT =
typename std::enable_if<!vtkMatrixUtilities::MatrixIs2DArray<MatrixT>()>::type>
1335 const float A[3][3],
float U[3][3],
float w[3],
float VT[3][3]);
1337 const double A[3][3],
double U[3][3],
double w[3],
double VT[3][3]);
1348 double a00,
double a01,
double a10,
double a11,
double b0,
double b1,
double& x0,
double& x1);
1374 double** A,
double** AI,
int size,
int* tmp1Size,
double* tmp2Size);
1468 int numberOfSamples,
double** xt,
int xOrder,
double**
mt);
1485 int yOrder,
double**
mt,
int checkHomogeneous = 1);
1497 RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
1499 static void RGBToHSV(
float r,
float g,
float b,
float*
h,
float* s,
float* v);
1500 static void RGBToHSV(
const double rgb[3],
double hsv[3])
1502 RGBToHSV(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
1504 static void RGBToHSV(
double r,
double g,
double b,
double*
h,
double* s,
double* v);
1517 HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
1519 static void HSVToRGB(
float h,
float s,
float v,
float* r,
float* g,
float* b);
1520 static void HSVToRGB(
const double hsv[3],
double rgb[3])
1522 HSVToRGB(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
1524 static void HSVToRGB(
double h,
double s,
double v,
double* r,
double* g,
double* b);
1534 ProLabToXYZ(prolab[0], prolab[1], prolab[2], xyz + 0, xyz + 1, xyz + 2);
1536 static void ProLabToXYZ(
double L,
double a,
double b,
double* x,
double* y,
double* z);
1546 XYZToProLab(xyz[0], xyz[1], xyz[2], prolab + 0, prolab + 1, prolab + 2);
1548 static void XYZToProLab(
double x,
double y,
double z,
double* L,
double* a,
double* b);
1555 static void LabToXYZ(
const double lab[3],
double xyz[3])
1557 LabToXYZ(lab[0], lab[1], lab[2], xyz + 0, xyz + 1, xyz + 2);
1559 static void LabToXYZ(
double L,
double a,
double b,
double* x,
double* y,
double* z);
1566 static void XYZToLab(
const double xyz[3],
double lab[3])
1568 XYZToLab(xyz[0], xyz[1], xyz[2], lab + 0, lab + 1, lab + 2);
1570 static void XYZToLab(
double x,
double y,
double z,
double* L,
double* a,
double* b);
1577 static void XYZToRGB(
const double xyz[3],
double rgb[3])
1579 XYZToRGB(xyz[0], xyz[1], xyz[2], rgb + 0, rgb + 1, rgb + 2);
1581 static void XYZToRGB(
double x,
double y,
double z,
double* r,
double* g,
double* b);
1588 static void RGBToXYZ(
const double rgb[3],
double xyz[3])
1590 RGBToXYZ(rgb[0], rgb[1], rgb[2], xyz + 0, xyz + 1, xyz + 2);
1592 static void RGBToXYZ(
double r,
double g,
double b,
double* x,
double* y,
double* z);
1603 static void RGBToLab(
const double rgb[3],
double lab[3])
1605 RGBToLab(rgb[0], rgb[1], rgb[2], lab + 0, lab + 1, lab + 2);
1607 static void RGBToLab(
double red,
double green,
double blue,
double* L,
double* a,
double* b);
1616 ProLabToRGB(prolab[0], prolab[1], prolab[2], rgb + 0, rgb + 1, rgb + 2);
1618 static void ProLabToRGB(
double L,
double a,
double b,
double* red,
double* green,
double* blue);
1631 RGBToProLab(rgb[0], rgb[1], rgb[2], prolab + 0, prolab + 1, prolab + 2);
1633 static void RGBToProLab(
double red,
double green,
double blue,
double* L,
double* a,
double* b);
1640 static void LabToRGB(
const double lab[3],
double rgb[3])
1642 LabToRGB(lab[0], lab[1], lab[2], rgb + 0, rgb + 1, rgb + 2);
1644 static void LabToRGB(
double L,
double a,
double b,
double* red,
double* green,
double* blue);
1668 if (bounds[1] - bounds[0] < 0.0)
1681 static T ClampValue(
const T& value,
const T& min,
const T&
max);
1688 static void ClampValue(
double* value,
const double range[2]);
1689 static void ClampValue(
double value,
const double range[2],
double* clamped_value);
1690 static void ClampValues(
double* values,
int nb_values,
const double range[2]);
1692 const double* values,
int nb_values,
const double range[2],
double* clamped_values);
1707 template <
class T1,
class T2>
1727 double range_min,
double range_max,
double scale = 1.0,
double shift = 0.0);
1751 const double bounds1[6],
const double bounds2[6],
const double delta[3]);
1759 const double point[3],
const double bounds[6],
const double delta[3]);
1771 const double bounds[6],
const double normal[3],
const double point[3]);
1783 const double p1[3],
const double p2[3],
const double p3[3],
double center[3]);
1861 template <
class Iter1,
class Iter2,
class Iter3>
1862 static void Convolve1D(Iter1 beginSample, Iter1 endSample, Iter2 beginKernel, Iter2 endKernel,
1865 int sampleSize = std::distance(beginSample, endSample);
1866 int kernelSize = std::distance(beginKernel, endKernel);
1867 int outSize = std::distance(beginOut, endOut);
1869 if (sampleSize <= 0 || kernelSize <= 0 || outSize <= 0)
1880 begin =
static_cast<int>(std::ceil((std::min)(sampleSize, kernelSize) / 2.0)) - 1;
1881 end = begin + (std::max)(sampleSize, kernelSize);
1884 begin = (std::min)(sampleSize, kernelSize) - 1;
1885 end = begin + std::abs(sampleSize - kernelSize) + 1;
1892 for (
int i = begin; i < end; i++)
1894 Iter3 out = beginOut + i - begin;
1896 for (
int j = (std::max)(i - sampleSize + 1, 0); j <= (std::min)(i, kernelSize - 1); j++)
1898 *out += *(beginSample + (i - j)) * *(beginKernel + j);
1909 double directionVector[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
1911 result[0] = p2[0] + (offset * directionVector[0]);
1912 result[1] = p2[1] + (offset * directionVector[1]);
1913 result[2] = p2[2] + (offset * directionVector[2]);
1924 void operator=(
const vtkMath&) =
delete;
1930 return x * 0.017453292f;
1936 return x * 0.017453292519943295;
1942 return x * 57.2957795131f;
1948 return x * 57.29577951308232;
1954 return ((x != 0) & ((x & (x - 1)) == 0));
1961 unsigned int z =
static_cast<unsigned int>(((x > 0) ? x - 1 : 0));
1967 return static_cast<int>(z + 1);
1975 int i =
static_cast<int>(x);
1984 int i =
static_cast<int>(x);
1992 return (b <= a ? b : a);
1999 return (b > a ? b : a);
2008 for (
int i = 0; i < 3; ++i)
2022 for (
int i = 0; i < 3; ++i)
2036 for (
int i = 0; i < 2; ++i)
2050 for (
int i = 0; i < 2; ++i)
2061 return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
2062 c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
2068 return c1[0] * c2[1] * c3[2] + c2[0] * c3[1] * c1[2] + c3[0] * c1[1] * c2[2] -
2069 c1[0] * c3[1] * c2[2] - c2[0] * c1[1] * c3[2] - c3[0] * c2[1] * c1[2];
2074 double a1,
double a2,
double a3,
double b1,
double b2,
double b3,
double c1,
double c2,
double c3)
2083 return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
2084 (p1[2] - p2[2]) * (p1[2] - p2[2]));
2090 return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
2091 (p1[2] - p2[2]) * (p1[2] - p2[2]));
2095template <
typename ReturnTypeT,
typename TupleRangeT1,
typename TupleRangeT2,
typename EnableT>
2098 return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) +
2099 (p1[2] - p2[2]) * (p1[2] - p2[2]));
2105 return ((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]));
2109template <
class VectorT1,
class VectorT2,
class VectorT3>
2113 ValueType Cx = a[1] * b[2] - a[2] * b[1];
2114 ValueType Cy = a[2] * b[0] - a[0] * b[2];
2115 ValueType Cz = a[0] * b[1] - a[1] * b[0];
2125 float Cx = a[1] * b[2] - a[2] * b[1];
2126 float Cy = a[2] * b[0] - a[0] * b[2];
2127 float Cz = a[0] * b[1] - a[1] * b[0];
2137 double Cx = a[1] * b[2] - a[2] * b[1];
2138 double Cy = a[2] * b[0] - a[0] * b[2];
2139 double Cz = a[0] * b[1] - a[1] * b[0];
2149 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] -
2150 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];
2169 assert(
"pre: valid_range" && min <=
max);
2170 return std::clamp(value, min,
max);
2178 assert(
"pre: valid_range" && range[0] <= range[1]);
2187 if (range && clamped_value)
2189 assert(
"pre: valid_range" && range[0] <= range[1]);
2198 assert(
"pre: valid_range" && range[0] <= range[1]);
2201 if (range[0] == range[1])
2211 result = (result - range[0]) / (range[1] - range[0]);
2214 assert(
"post: valid_result" && result >= 0.0 && result <= 1.0);
2220template <
class T1,
class T2>
2223 for (
int i = 0; i < 3; ++i)
2225 tensor[4 * i] = symmTensor[i];
2227 tensor[1] = tensor[3] = symmTensor[3];
2228 tensor[2] = tensor[6] = symmTensor[5];
2229 tensor[5] = tensor[7] = symmTensor[4];
2236 tensor[6] = tensor[5];
2237 tensor[7] = tensor[4];
2238 tensor[8] = tensor[2];
2239 tensor[4] = tensor[1];
2240 tensor[5] = tensor[7];
2241 tensor[2] = tensor[6];
2242 tensor[1] = tensor[3];
2244VTK_ABI_NAMESPACE_END
2248template <
class QuaternionT,
class MatrixT>
2249inline void vtkQuaternionToMatrix3x3(QuaternionT&& quat, MatrixT&& A)
2253 Scalar
ww = quat[0] * quat[0];
2254 Scalar wx = quat[0] * quat[1];
2255 Scalar wy = quat[0] * quat[2];
2256 Scalar wz = quat[0] * quat[3];
2258 Scalar
xx = quat[1] * quat[1];
2259 Scalar
yy = quat[2] * quat[2];
2260 Scalar zz = quat[3] * quat[3];
2262 Scalar xy = quat[1] * quat[2];
2263 Scalar xz = quat[1] * quat[3];
2264 Scalar yz = quat[2] * quat[3];
2266 Scalar rr =
xx +
yy + zz;
2268 Scalar f = 1 / (
ww + rr);
2269 Scalar s = (
ww - rr) * f;
2275 Wrapper::template Get<0, 0>(Ar) =
xx * f + s;
2276 Wrapper::template Get<1, 0>(Ar) = (xy + wz) * f;
2277 Wrapper::template Get<2, 0>(Ar) = (xz - wy) * f;
2279 Wrapper::template Get<0, 1>(Ar) = (xy - wz) * f;
2280 Wrapper::template Get<1, 1>(Ar) =
yy * f + s;
2281 Wrapper::template Get<2, 1>(Ar) = (yz + wx) * f;
2283 Wrapper::template Get<0, 2>(Ar) = (xz + wy) * f;
2284 Wrapper::template Get<1, 2>(Ar) = (yz - wx) * f;
2285 Wrapper::template Get<2, 2>(Ar) = zz * f + s;
2289VTK_ABI_NAMESPACE_BEGIN
2293 vtkQuaternionToMatrix3x3(quat, A);
2299 vtkQuaternionToMatrix3x3(quat, A);
2303template <
class QuaternionT,
class MatrixT,
class EnableT>
2306 vtkQuaternionToMatrix3x3(std::forward<QuaternionT>(q), std::forward<MatrixT>(A));
2308VTK_ABI_NAMESPACE_END
2317template <
class MatrixT,
class QuaternionT>
2318inline void vtkMatrix3x3ToQuaternion(MatrixT&& A, QuaternionT&& quat)
2329 N[0][0] = Wrapper::template Get<0, 0>(Ar) + Wrapper::template Get<1, 1>(Ar) +
2330 Wrapper::template Get<2, 2>(Ar);
2331 N[1][1] = Wrapper::template Get<0, 0>(Ar) - Wrapper::template Get<1, 1>(Ar) -
2332 Wrapper::template Get<2, 2>(Ar);
2333 N[2][2] = -Wrapper::template Get<0, 0>(Ar) + Wrapper::template Get<1, 1>(Ar) -
2334 Wrapper::template Get<2, 2>(Ar);
2335 N[3][3] = -Wrapper::template Get<0, 0>(Ar) - Wrapper::template Get<1, 1>(Ar) +
2336 Wrapper::template Get<2, 2>(Ar);
2339 N[0][1] = N[1][0] = Wrapper::template Get<2, 1>(Ar) - Wrapper::template Get<1, 2>(Ar);
2340 N[0][2] = N[2][0] = Wrapper::template Get<0, 2>(Ar) - Wrapper::template Get<2, 0>(Ar);
2341 N[0][3] = N[3][0] = Wrapper::template Get<1, 0>(Ar) - Wrapper::template Get<0, 1>(Ar);
2343 N[1][2] = N[2][1] = Wrapper::template Get<1, 0>(Ar) + Wrapper::template Get<0, 1>(Ar);
2344 N[1][3] = N[3][1] = Wrapper::template Get<0, 2>(Ar) + Wrapper::template Get<2, 0>(Ar);
2345 N[2][3] = N[3][2] = Wrapper::template Get<2, 1>(Ar) + Wrapper::template Get<1, 2>(Ar);
2347 Scalar eigenvectors[4][4], eigenvalues[4];
2351 Scalar *NTemp[4], *eigenvectorsTemp[4];
2352 for (
int i = 0; i < 4; ++i)
2355 eigenvectorsTemp[i] = eigenvectors[i];
2360 quat[0] = eigenvectors[0][0];
2361 quat[1] = eigenvectors[1][0];
2362 quat[2] = eigenvectors[2][0];
2363 quat[3] = eigenvectors[3][0];
2367VTK_ABI_NAMESPACE_BEGIN
2371 vtkMatrix3x3ToQuaternion(A, quat);
2377 vtkMatrix3x3ToQuaternion(A, quat);
2381template <
class MatrixT,
class QuaternionT,
class EnableT>
2384 vtkMatrix3x3ToQuaternion(std::forward<MatrixT>(A), std::forward<QuaternionT>(q));
2386VTK_ABI_NAMESPACE_END
2390VTK_ABI_NAMESPACE_BEGIN
2392template <
typename OutT>
2400 *ret =
static_cast<OutT
>((val >= 0.0) ? (val + 0.5) : (val - 0.5));
2420 *retVal =
static_cast<float>(val);
2422VTK_ABI_NAMESPACE_END
2425VTK_ABI_NAMESPACE_BEGIN
2427#if defined(VTK_HAS_ISINF) || defined(VTK_HAS_STD_ISINF)
2428#define VTK_MATH_ISINF_IS_INLINE
2431#if defined(VTK_HAS_STD_ISINF)
2432 return std::isinf(x);
2434 return (isinf(x) != 0);
2440#if defined(VTK_HAS_ISNAN) || defined(VTK_HAS_STD_ISNAN)
2441#define VTK_MATH_ISNAN_IS_INLINE
2444#if defined(VTK_HAS_STD_ISNAN)
2445 return std::isnan(x);
2447 return (
isnan(x) != 0);
2453#if defined(VTK_HAS_ISFINITE) || defined(VTK_HAS_STD_ISFINITE) || defined(VTK_HAS_FINITE)
2454#define VTK_MATH_ISFINITE_IS_INLINE
2457#if defined(VTK_HAS_STD_ISFINITE)
2458 return std::isfinite(x);
2459#elif defined(VTK_HAS_ISFINITE)
2460 return (isfinite(x) != 0);
2462 return (finite(x) != 0);
2467VTK_ABI_NAMESPACE_END
Gaussian sequence of pseudo random numbers implemented with the Box-Mueller transform.
a simple class to control print indentation
static ReturnTypeT Distance2BetweenPoints(const TupleRangeT1 &p1, const TupleRangeT2 &p2)
Compute distance squared between two points p1 and p2.
static void Multiply3x3(const float A[3][3], const float B[3][3], float C[3][3])
Multiply one 3x3 matrix by another according to C = AB.
static double Dot(const double a[3], const double b[3])
Dot product of two 3-vectors (double version).
static int GetScalarTypeFittingRange(double range_min, double range_max, double scale=1.0, double shift=0.0)
Return the scalar type that is most likely to have enough precision to store a given range of data on...
static void RGBToXYZ(double r, double g, double b, double *x, double *y, double *z)
Convert color from the RGB system to CIE XYZ.
static void Multiply3x3(const double A[3][3], const double B[3][3], double C[3][3])
Multiply one 3x3 matrix by another according to C = AB.
static double Norm(const double *x, int n)
Compute the norm of n-vector.
static int Round(float f)
Rounds a float to the nearest integer.
static vtkIdType ComputeGCD(vtkIdType m, vtkIdType n)
Compute the greatest common divisor (GCD) of two positive integers m and n.
static void XYZToProLab(const double xyz[3], double prolab[3])
Convert Color from the CIE XYZ system to ProLAB.
static double Norm2D(const double x[2])
Compute the norm of a 2-vector.
static void XYZToProLab(double x, double y, double z, double *L, double *a, double *b)
Convert Color from the CIE XYZ system to ProLAB.
static double GaussianAmplitude(double variance, double distanceFromMean)
Compute the amplitude of a Gaussian function with mean=0 and specified variance.
static void XYZToRGB(double x, double y, double z, double *r, double *g, double *b)
Convert color from the CIE XYZ system to RGB.
static void GetPointAlongLine(double result[3], double p1[3], double p2[3], const double offset)
Get the coordinates of a point along a line defined by p1 and p2, at a specified offset relative to p...
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])
LU back substitution for a 3x3 matrix.
static vtkTypeBool SolveHomogeneousLeastSquares(int numberOfSamples, double **xt, int xOrder, double **mt)
Solves for the least squares best fit matrix for the homogeneous equation X'M' = 0'.
static void Outer2D(const float x[2], const float y[2], float A[2][2])
Outer product of two 2-vectors (float version).
static bool ProjectVector(const double a[3], const double b[3], double projection[3])
Compute the projection of vector a on vector b and return it in projection[3].
static vtkSmartPointer< vtkMathInternal > Internal
static float Norm(const float *x, int n)
Compute the norm of n-vector.
static vtkTypeBool ExtentIsWithinOtherExtent(const int extent1[6], const int extent2[6])
Return true if first 3D extent is within second 3D extent Extent is x-min, x-max, y-min,...
static double GaussianAmplitude(double mean, double variance, double position)
Compute the amplitude of a Gaussian function with specified mean and variance.
static void Add(const double a[3], const double b[3], double c[3])
Addition of two 3-vectors (double version).
static void RGBToHSV(float r, float g, float b, float *h, float *s, float *v)
Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).
static float Norm(const float v[3])
Compute the norm of 3-vector (float version).
static ReturnTypeT Dot(const TupleRangeT1 &a, const TupleRangeT2 &b)
Compute dot product between two points p1 and p2.
static vtkTypeBool Jacobi(double **a, double *w, double **v)
Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix.
static ScalarT Dot(VectorT1 &&x, VectorT2 &&y)
Computes the dot product between 2 vectors x and y.
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!
static vtkTypeInt64 Binomial(int m, int n)
The number of combinations of n objects from a pool of m objects (m>n).
static double Random()
Generate pseudo-random numbers distributed according to the uniform distribution between 0....
static void Identity3x3(float A[3][3])
Set A to the identity matrix.
static void SingularValueDecomposition3x3(const float A[3][3], float U[3][3], float w[3], float VT[3][3])
Perform singular value decomposition on a 3x3 matrix.
static double Nan()
Special IEEE-754 number used to represent Not-A-Number (Nan).
static void Perpendiculars(const float v1[3], float v2[3], float v3[3], double theta)
Given a unit vector v1, find two unit vectors v2 and v3 such that v1 cross v2 = v3 (i....
static double Gaussian(double mean, double std)
Generate pseudo-random numbers distributed according to the Gaussian distribution with mean mean and ...
static bool IsFinite(double x)
Test if a number has finite value i.e.
static void LUSolveLinearSystem(double **A, int *index, double *x, int size)
Solve linear equations Ax = b using LU decomposition A = LU where L is lower triangular matrix and U ...
static double EstimateMatrixCondition(const double *const *A, int size)
Estimate the condition number of a LU factored matrix.
static void LUFactor3x3(float A[3][3], int index[3])
LU Factorization of a 3x3 matrix.
static void LinearSolve(MatrixT &&M, VectorT1 &&x, VectorT2 &&y)
This method solves linear systems M * x = y.
static void FreeCombination(int *combination)
Free the "iterator" array created by vtkMath::BeginCombination.
static double Random(double min, double max)
Generate pseudo-random numbers distributed according to the uniform distribution between min and max.
static void TensorFromSymmetricTensor(const T1 symmTensor[6], T2 tensor[9])
Convert a 6-Component symmetric tensor into a 9-Component tensor, no allocation performed.
static void LabToXYZ(const double lab[3], double xyz[3])
Convert color from the CIE-L*ab system to CIE XYZ.
static double Solve3PointCircle(const double p1[3], const double p2[3], const double p3[3], double center[3])
In Euclidean space, there is a unique circle passing through any given three non-collinear points P1,...
static vtkTypeBool PointIsWithinBounds(const double point[3], const double bounds[6], const double delta[3])
Return true if point is within the given 3D bounds Bounds is x-min, x-max, y-min, y-max,...
static float Dot(const float a[3], const float b[3])
Dot product of two 3-vectors (float version).
static void Diagonalize3x3(const float A[3][3], float w[3], float V[3][3])
Diagonalize a symmetric 3x3 matrix and return the eigenvalues in w and the eigenvectors in the column...
static void LabToXYZ(double L, double a, double b, double *x, double *y, double *z)
Convert color from the CIE-L*ab system to CIE XYZ.
static vtkTypeBool GetAdjustedScalarRange(vtkDataArray *array, int comp, double range[2])
Get a vtkDataArray's scalar range for a given component.
static bool ProjectVector(const float a[3], const float b[3], float projection[3])
Compute the projection of vector a on vector b and return it in projection[3].
static void MultiplyScalar2D(float a[2], float s)
Multiplies a 2-vector by a scalar (float version).
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 Assign(const double a[3], double b[3])
Assign values to a 3-vector (double version).
static double Determinant2x2(const double c1[2], const double c2[2])
Calculate the determinant of a 2x2 matrix: | a b | | c d |.
static T Max(const T &a, const T &b)
Returns the maximum of the two arguments provided.
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 RandomSeed(int s)
Initialize seed value.
static double NegInf()
Special IEEE-754 number used to represent negative infinity.
static void MultiplyScalar2D(double a[2], double s)
Multiplies a 2-vector by a scalar (double version).
static void LabToRGB(double L, double a, double b, double *red, double *green, double *blue)
Convert color from the CIE-L*ab system to RGB.
static double Gaussian()
Generate pseudo-random numbers distributed according to the standard normal distribution.
static double RealBinomial(double mm, int nn)
A version of Binomial that allows mm to be real-valued.
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])
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
~vtkMath() override=default
static double Inf()
Special IEEE-754 number used to represent positive infinity.
static vtkTypeBool Jacobi(float **a, float *w, float **v)
Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix.
static int PlaneIntersectsAABB(const double bounds[6], const double normal[3], const double point[3])
Implements Plane / Axis-Aligned Bounding-Box intersection as described in Graphics Gems IV,...
static ScalarT Dot(VectorT1 &&x, VectorT2 &&y)
Computes the dot product between 2 vectors x and y.
static void RGBToXYZ(const double rgb[3], double xyz[3])
Convert color from the RGB system to CIE XYZ.
static void QuaternionToMatrix3x3(const float quat[4], float A[3][3])
Convert a quaternion to a 3x3 rotation matrix.
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)
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
static void SingularValueDecomposition3x3(const double A[3][3], double U[3][3], double w[3], double VT[3][3])
Perform singular value decomposition on a 3x3 matrix.
static double SignedAngleBetweenVectors(const double v1[3], const double v2[3], const double vn[3])
Compute signed angle in radians between two vectors with regard to a third orthogonal vector.
static ScalarT Dot(VectorT1 &&x, MatrixT &&M, VectorT2 &&y)
Computes the dot product x^T M y, where x and y are vectors and M is a metric matrix.
static float Normalize2D(float v[2])
Normalize (in place) a 2-vector.
static void Invert3x3(const double A[3][3], double AI[3][3])
Invert a 3x3 matrix.
static void HSVToRGB(float h, float s, float v, float *r, float *g, float *b)
Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).
static constexpr int DYNAMIC_VECTOR_SIZE()
When this value is passed to a select templated functions in vtkMath, the computation can be performe...
static void MultiplyQuaternion(const double q1[4], const double q2[4], double q[4])
Multiply two quaternions.
static void Multiply3x3(const double A[3][3], const double v[3], double u[3])
Multiply a vector by a 3x3 matrix.
static void Outer(const double a[3], const double b[3], double c[3][3])
Outer product of two 3-vectors (double version).
static vtkTypeBool InvertMatrix(double **A, double **AI, int size, int *tmp1Size, double *tmp2Size)
Thread safe version of InvertMatrix method.
static vtkTypeBool InvertMatrix(double **A, double **AI, int size)
Invert input square matrix A into matrix AI.
static void LUSolve3x3(const float A[3][3], const int index[3], float x[3])
LU back substitution for a 3x3 matrix.
static int GetSeed()
Return the current seed used by the random number generator.
static void Assign(const VectorT1 &a, VectorT2 &&b)
Assign values to a 3-vector (templated version).
static float RadiansFromDegrees(float degrees)
Convert degrees into radians.
static void Convolve1D(Iter1 beginSample, Iter1 endSample, Iter2 beginKernel, Iter2 endKernel, Iter3 beginOut, Iter3 endOut, ConvolutionMode mode=ConvolutionMode::FULL)
Compute the convolution of a sampled 1D signal by a given kernel.
static void RotateVectorByWXYZ(const double v[3], const double q[4], double r[3])
rotate a vector by WXYZ using // https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula
static void Add(const float a[3], const float b[3], float c[3])
Addition of two 3-vectors (float version).
static int CeilLog2(vtkTypeUInt64 x)
Gives the exponent of the lowest power of two not less than x.
static void RGBToProLab(double red, double green, double blue, double *L, double *a, double *b)
Convert color from the RGB system to Prolab The input RGB must be values in the range [0,...
static void ProLabToXYZ(const double prolab[3], double xyz[3])
Convert color from the ProLAB system to CIE XYZ.
static vtkTypeBool AreBoundsInitialized(const double bounds[6])
Are the bounds initialized?
static bool ProjectVector2D(const double a[2], const double b[2], double projection[2])
Compute the projection of 2D vector a on 2D vector b and returns the result in projection[2].
static vtkTypeBool JacobiN(float **a, int n, float *w, float **v)
JacobiN iteration for the solution of eigenvectors/eigenvalues of a nxn real symmetric matrix.
static int NextCombination(int m, int n, int *combination)
Given m, n, and a valid combination of n integers in the range [0,m[, this function alters the intege...
static constexpr double Pi()
A mathematical constant.
static void Multiply3x3(const float A[3][3], const float v[3], float u[3])
Multiply a vector by a 3x3 matrix.
static void Subtract(const double a[3], const double b[3], double c[3])
Subtraction of two 3-vectors (double version).
static void ProLabToXYZ(double L, double a, double b, double *x, double *y, double *z)
Convert color from the ProLAB system to CIE XYZ.
static void RGBToProLab(const double rgb[3], double prolab[3])
Convert color from the RGB system to Prolab The input RGB must be values in the range [0,...
static void ProLabToRGB(double L, double a, double b, double *red, double *green, double *blue)
Convert color from the ProLab system to RGB.
static void Matrix3x3ToQuaternion(const float A[3][3], float quat[4])
Convert a 3x3 matrix into a quaternion.
static void Orthogonalize3x3(const double A[3][3], double B[3][3])
Orthogonalize a 3x3 matrix and put the result in B.
static void XYZToRGB(const double xyz[3], double rgb[3])
Convert color from the CIE XYZ system to RGB.
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 MultiplyScalar(double a[3], double s)
Multiplies a 3-vector by a scalar (double version).
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])
Diagonalize a symmetric 3x3 matrix and return the eigenvalues in w and the eigenvectors in the column...
static void RGBToLab(const double rgb[3], double lab[3])
Convert color from the RGB system to CIE-L*ab.
static void ProLabToRGB(const double prolab[3], double rgb[3])
Convert color from the ProLab system to RGB.
static int Floor(double x)
Rounds a double to the nearest integer not greater than itself.
static void RotateVectorByNormalizedQuaternion(const double v[3], const double q[4], double r[3])
rotate a vector by a normalized quaternion using // https://en.wikipedia.org/wiki/Rodrigues%27_rotati...
static void Subtract(const VectorT1 &a, const VectorT2 &b, VectorT3 &&c)
Subtraction of two 3-vectors (templated version).
static vtkTypeBool BoundsIsWithinOtherBounds(const double bounds1[6], const double bounds2[6], const double delta[3])
Return true if first 3D bounds is within the second 3D bounds Bounds is x-min, x-max,...
static double Determinant2x2(double a, double b, double c, double d)
Calculate the determinant of a 2x2 matrix: | a b | | c d |.
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 JacobiN(double **a, int n, double *w, double **v)
JacobiN iteration for the solution of eigenvectors/eigenvalues of a nxn real symmetric matrix.
static double AngleBetweenVectors(const double v1[3], const double v2[3])
Compute angle in radians between two vectors.
static void MultiplyMatrix(const double *const *A, const double *const *B, unsigned int rowA, unsigned int colA, unsigned int rowB, unsigned int colB, double **C)
General matrix multiplication.
static float DegreesFromRadians(float radians)
Convert radians into degrees.
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 double GaussianWeight(double mean, double variance, double position)
Compute the amplitude of an unnormalized Gaussian function with specified mean and variance.
static void UninitializeBounds(double bounds[6])
Set the bounds to an uninitialized state.
static void RGBToHSV(double r, double g, double b, double *h, double *s, double *v)
Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).
static void Outer(const float a[3], const float b[3], float c[3][3])
Outer product of two 3-vectors (float version).
static int * BeginCombination(int m, int n)
Start iterating over "m choose n" objects.
static double Norm(const double v[3])
Compute the norm of 3-vector (double 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 void RotateVectorByWXYZ(const float v[3], const float q[4], float r[3])
rotate a vector by WXYZ using // https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula
static double JacobiPolynomial(int nn, double alpha, double beta, double xx)
Returns the value of the nn-th Jacobi polynomial for parameters alpha > -1, beta > -1 and (typically)...
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])
Transpose a 3x3 matrix.
static ReturnTypeT SquaredNorm(const TupleRangeT &v)
Compute the squared norm of a 3-vector.
static double Determinant3x3(const float A[3][3])
Return the determinant of a 3x3 matrix.
static float Dot2D(const float x[2], const float y[2])
Dot product of two 2-vectors.
ConvolutionMode
Support the convolution operations.
static void RotateVectorByNormalizedQuaternion(const float v[3], const float q[4], float r[3])
rotate a vector by a normalized quaternion using // https://en.wikipedia.org/wiki/Rodrigues%27_rotati...
static 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 DoubleBinomial(int m, int n)
The number of combinations of n objects from a pool of m objects (m>n).
static void Add(VectorT1 &&a, VectorT2 &&b, VectorT3 &c)
Addition of two 3-vectors (double version).
static void Orthogonalize3x3(const float A[3][3], float B[3][3])
Orthogonalize a 3x3 matrix and put the result in B.
static bool ProjectVector2D(const float a[2], const float b[2], float projection[2])
Compute the projection of 2D vector a on 2D vector b and returns the result in projection[2].
static vtkTypeBool SolveLinearSystemGEPP2x2(double a00, double a01, double a10, double a11, double b0, double b1, double &x0, double &x1)
Solve linear equation Ax = b using Gaussian Elimination with Partial Pivoting for a 2x2 system.
static vtkMatrixUtilities::ScalarTypeExtractor< MatrixT >::value_type Determinant(MatrixT &&M)
Computes the determinant of input square SizeT x SizeT matrix M.
static vtkTypeBool SolveLinearSystem(double **A, double *x, int size)
Solve linear equations Ax = b using Crout's method.
static void LabToRGB(const double lab[3], double rgb[3])
Convert color from the CIE-L*ab system to RGB.
static float Norm2D(const float x[2])
Compute the norm of a 2-vector.
static vtkTypeBool LUFactorLinearSystem(double **A, int *index, int size, double *tmpSize)
Thread safe version of LUFactorLinearSystem method.
static void LinearSolve3x3(const double A[3][3], const double x[3], double y[3])
Solve Ay = x for y and place the result in y.
static void XYZToLab(double x, double y, double z, double *L, double *a, double *b)
Convert Color from the CIE XYZ system to CIE-L*ab.
static void 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 void InvertMatrix(MatrixT1 &&M1, MatrixT2 &&M2)
Computes the inverse of input matrix M1 into M2.
static void Cross(VectorT1 &&a, VectorT2 &&b, VectorT3 &c)
Cross product of two 3-vectors.
static void MultiplyMatrix(MatrixT1 &&M1, MatrixT2 &&M2, MatrixT3 &&M3)
Multiply matrices such that M3 = M1 x M2.
static void Perpendiculars(const double v1[3], double v2[3], double v3[3], double theta)
Given a unit vector v1, find two unit vectors v2 and v3 such that v1 cross v2 = v3 (i....
static T ClampValue(const T &value, const T &min, const T &max)
Clamp some value against a range, return the result.
static vtkTypeBool SolveLeastSquares(int numberOfSamples, double **xt, int xOrder, double **yt, int yOrder, double **mt, int checkHomogeneous=1)
Solves for the least squares best fit matrix for the equation X'M' = Y'.
static void Identity3x3(double A[3][3])
Set A to the identity matrix.
static double JacobiPolynomialDerivative(int nn, double alpha, double beta, double xx)
Returns the derivative (with respect to xx) of the nn-th Jacobi polynomial.
static void LUFactor3x3(double A[3][3], int index[3])
LU Factorization of a 3x3 matrix.
static vtkTypeBool LUFactorLinearSystem(double **A, int *index, int size)
Factor linear equations Ax = b using LU decomposition into the form A = LU where L is a unit lower tr...
static void RGBToLab(double red, double green, double blue, double *L, double *a, double *b)
Convert color from the RGB system to CIE-L*ab.
static void MultiplyQuaternion(const float q1[4], const float q2[4], float q[4])
Multiply two quaternions.
static double GaussianWeight(double variance, double distanceFromMean)
Compute the amplitude of an unnormalized Gaussian function with mean=0 and specified variance.
static void ClampValues(const double *values, int nb_values, const double range[2], double *clamped_values)
Clamp some values against a range The method without 'clamped_values' will perform in-place clamping.
static void Transpose3x3(const float A[3][3], float AT[3][3])
Transpose a 3x3 matrix.
static double Distance2BetweenPoints2D(const double p1[2], const double p2[2])
Compute distance squared between two 2D points p1 and p2.
static vtkMatrixUtilities::ScalarTypeExtractor< VectorT >::value_type SquaredNorm(VectorT &&x)
Computes the dot product between 2 vectors x and y.
static void ClampValues(double *values, int nb_values, const double range[2])
Clamp some values against a range The method without 'clamped_values' will perform in-place clamping.
static int QuadraticRoot(double a, double b, double c, double min, double max, double *u)
find roots of ax^2+bx+c=0 in the interval min,max.
static void MultiplyMatrixWithVector(MatrixT &&M, VectorT1 &&X, VectorT2 &&Y)
Multiply matrix M with vector Y such that Y = M x X.
Park and Miller Sequence of pseudo random numbers.
represent and manipulate 3D points
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.
void RoundDoubleToIntegralIfNecessary(double val, OutT *ret)
Template defining traits of native types used by VTK.
double vtkDeterminant3x3(const T A[3][3])
#define Distance2BetweenPoints2D(p1, p2)