VTK  9.3.20240419
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
vtkMath Class Reference

performs common math operations More...

#include <vtkMath.h>

Inheritance diagram for vtkMath:
[legend]
Collaboration diagram for vtkMath:
[legend]

Public Types

enum class  ConvolutionMode { FULL , SAME , VALID }
 Support the convolution operations. More...
 
typedef vtkObject Superclass
 

Public Member Functions

virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
vtkMathNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
template<class T1 , class T2 >
void TensorFromSymmetricTensor (const T1 symmTensor[9], T2 tensor[9])
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 Turn debugging output on. More...
 
virtual void DebugOff ()
 Turn debugging output off. More...
 
bool GetDebug ()
 Get the value of the debug flag. More...
 
void SetDebug (bool debugFlag)
 Set the value of the debug flag. More...
 
virtual void Modified ()
 Update the modification time for this object. More...
 
virtual vtkMTimeType GetMTime ()
 Return this object's modified time. More...
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
vtkTypeBool HasObserver (unsigned long event)
 
vtkTypeBool HasObserver (const char *event)
 
vtkTypeBool InvokeEvent (unsigned long event)
 
vtkTypeBool InvokeEvent (const char *event)
 
std::string GetObjectDescription () const override
 The object description printed in messages and PrintSelf output. More...
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkCommandGetCommand (unsigned long tag)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObserver (vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Allow user to set the AbortFlagOn() with the return value of the callback method. More...
 
vtkTypeBool InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
vtkTypeBool InvokeEvent (const char *event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
virtual void SetObjectName (const std::string &objectName)
 Set/get the name of this object for reporting purposes. More...
 
virtual std::string GetObjectName () const
 Set/get the name of this object for reporting purposes. More...
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. More...
 
virtual vtkIdType GetNumberOfGenerationsFromBase (const char *name)
 Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
virtual void Delete ()
 Delete a VTK object. More...
 
virtual void FastDelete ()
 Delete a reference to this object. More...
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream. More...
 
void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object). More...
 
virtual void UnRegister (vtkObjectBase *o)
 Decrease the reference count (release by another object). More...
 
int GetReferenceCount ()
 Return the current reference count of this object. More...
 
void SetReferenceCount (int)
 Sets the reference count. More...
 
bool GetIsInMemkind () const
 A local state flag that remembers whether this object lives in the normal or extended memory space. More...
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual bool UsesGarbageCollector () const
 Indicate whether the class uses vtkGarbageCollector or not. More...
 

Static Public Member Functions

static vtkMathNew ()
 
static vtkTypeBool IsTypeOf (const char *type)
 
static vtkMathSafeDownCast (vtkObjectBase *o)
 
static constexpr int DYNAMIC_VECTOR_SIZE ()
 When this value is passed to a select templated functions in vtkMath, the computation can be performed on dynamic sized arrays as long as they implement the method size(). More...
 
static constexpr double Pi ()
 A mathematical constant. More...
 
static int Round (float f)
 Rounds a float to the nearest integer. More...
 
static int Round (double f)
 
template<typename OutT >
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. More...
 
static int Floor (double x)
 Rounds a double to the nearest integer not greater than itself. More...
 
static int Ceil (double x)
 Rounds a double to the nearest integer not less than itself. More...
 
static int CeilLog2 (vtkTypeUInt64 x)
 Gives the exponent of the lowest power of two not less than x. More...
 
template<class T >
static T Min (const T &a, const T &b)
 Returns the minimum of the two arguments provided. More...
 
template<class T >
static T Max (const T &a, const T &b)
 Returns the maximum of the two arguments provided. More...
 
static bool IsPowerOfTwo (vtkTypeUInt64 x)
 Returns true if integer is a power of two. More...
 
static int NearestPowerOfTwo (int x)
 Compute the nearest power of two that is not less than x. More...
 
static vtkTypeInt64 Factorial (int N)
 Compute N factorial, N! = N*(N-1) * (N-2)...*3*2*1. More...
 
static vtkTypeInt64 Binomial (int m, int n)
 The number of combinations of n objects from a pool of m objects (m>n). More...
 
static int * BeginCombination (int m, int n)
 Start iterating over "m choose n" objects. More...
 
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 integers into the next combination in a sequence of all combinations of n items from a pool of m. More...
 
static void FreeCombination (int *combination)
 Free the "iterator" array created by vtkMath::BeginCombination. More...
 
static void RandomSeed (int s)
 Initialize seed value. More...
 
static int GetSeed ()
 Return the current seed used by the random number generator. More...
 
static double Random ()
 Generate pseudo-random numbers distributed according to the uniform distribution between 0.0 and 1.0. More...
 
static double Random (double min, double max)
 Generate pseudo-random numbers distributed according to the uniform distribution between min and max. More...
 
static double Gaussian ()
 Generate pseudo-random numbers distributed according to the standard normal distribution. More...
 
static double Gaussian (double mean, double std)
 Generate pseudo-random numbers distributed according to the Gaussian distribution with mean mean and standard deviation std. More...
 
template<class VectorT1 , class VectorT2 >
static void Assign (const VectorT1 &a, VectorT2 &&b)
 Assign values to a 3-vector (templated version). More...
 
static void Assign (const double a[3], double b[3])
 Assign values to a 3-vector (double version). More...
 
static void Add (const float a[3], const float b[3], float c[3])
 Addition of two 3-vectors (float version). More...
 
static void Add (const double a[3], const double b[3], double c[3])
 Addition of two 3-vectors (double version). More...
 
template<class VectorT1 , class VectorT2 , class VectorT3 >
static void Add (VectorT1 &&a, VectorT2 &&b, VectorT3 &c)
 Addition of two 3-vectors (double version). More...
 
static void Subtract (const float a[3], const float b[3], float c[3])
 Subtraction of two 3-vectors (float version). More...
 
static void Subtract (const double a[3], const double b[3], double c[3])
 Subtraction of two 3-vectors (double version). More...
 
template<class VectorT1 , class VectorT2 , class VectorT3 >
static void Subtract (const VectorT1 &a, const VectorT2 &b, VectorT3 &&c)
 Subtraction of two 3-vectors (templated version). More...
 
static void MultiplyScalar (float a[3], float s)
 Multiplies a 3-vector by a scalar (float version). More...
 
static void MultiplyScalar2D (float a[2], float s)
 Multiplies a 2-vector by a scalar (float version). More...
 
static void MultiplyScalar (double a[3], double s)
 Multiplies a 3-vector by a scalar (double version). More...
 
static void MultiplyScalar2D (double a[2], double s)
 Multiplies a 2-vector by a scalar (double version). More...
 
static float Dot (const float a[3], const float b[3])
 Dot product of two 3-vectors (float version). More...
 
static double Dot (const double a[3], const double b[3])
 Dot product of two 3-vectors (double version). More...
 
template<typename ReturnTypeT = double, typename TupleRangeT1 , typename TupleRangeT2 , typename EnableT = typename std::conditional<!std::is_pointer<TupleRangeT1>::value && !std::is_array<TupleRangeT1>::value, TupleRangeT1, TupleRangeT2>::type::value_type>
static ReturnTypeT Dot (const TupleRangeT1 &a, const TupleRangeT2 &b)
 Compute dot product between two points p1 and p2. More...
 
static void Outer (const float a[3], const float b[3], float c[3][3])
 Outer product of two 3-vectors (float version). More...
 
static void Outer (const double a[3], const double b[3], double c[3][3])
 Outer product of two 3-vectors (double version). More...
 
template<class VectorT1 , class VectorT2 , class VectorT3 >
static void Cross (VectorT1 &&a, VectorT2 &&b, VectorT3 &c)
 Cross product of two 3-vectors. More...
 
static void Cross (const float a[3], const float b[3], float c[3])
 Cross product of two 3-vectors. More...
 
static void Cross (const double a[3], const double b[3], double c[3])
 Cross product of two 3-vectors. More...
 
static float Norm (const float v[3])
 Compute the norm of 3-vector (float version). More...
 
static double Norm (const double v[3])
 Compute the norm of 3-vector (double version). More...
 
template<typename ReturnTypeT = double, typename TupleRangeT >
static ReturnTypeT SquaredNorm (const TupleRangeT &v)
 Compute the squared norm of a 3-vector. More...
 
static float Normalize (float v[3])
 Normalize (in place) a 3-vector. More...
 
static double Normalize (double v[3])
 Normalize (in place) a 3-vector. More...
 
template<typename ReturnTypeT = double, typename TupleRangeT1 , typename TupleRangeT2 , typename EnableT = typename std::conditional<!std::is_pointer<TupleRangeT1>::value && !std::is_array<TupleRangeT1>::value, TupleRangeT1, TupleRangeT2>::type::value_type>
static ReturnTypeT Distance2BetweenPoints (const TupleRangeT1 &p1, const TupleRangeT2 &p2)
 Compute distance squared between two points p1 and p2. More...
 
static float Distance2BetweenPoints (const float p1[3], const float p2[3])
 Compute distance squared between two points p1 and p2. More...
 
static double Distance2BetweenPoints (const double p1[3], const double p2[3])
 Compute distance squared between two points p1 and p2. More...
 
static double AngleBetweenVectors (const double v1[3], const double v2[3])
 Compute angle in radians between two vectors. More...
 
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. More...
 
static double GaussianAmplitude (double variance, double distanceFromMean)
 Compute the amplitude of a Gaussian function with mean=0 and specified variance. More...
 
static double GaussianAmplitude (double mean, double variance, double position)
 Compute the amplitude of a Gaussian function with specified mean and variance. More...
 
static double GaussianWeight (double variance, double distanceFromMean)
 Compute the amplitude of an unnormalized Gaussian function with mean=0 and specified variance. More...
 
static double GaussianWeight (double mean, double variance, double position)
 Compute the amplitude of an unnormalized Gaussian function with specified mean and variance. More...
 
static float Dot2D (const float x[2], const float y[2])
 Dot product of two 2-vectors. More...
 
static double Dot2D (const double x[2], const double y[2])
 Dot product of two 2-vectors. More...
 
static void Outer2D (const float x[2], const float y[2], float A[2][2])
 Outer product of two 2-vectors (float version). More...
 
static void Outer2D (const double x[2], const double y[2], double A[2][2])
 Outer product of two 2-vectors (double version). More...
 
static float Norm2D (const float x[2])
 Compute the norm of a 2-vector. More...
 
static double Norm2D (const double x[2])
 Compute the norm of a 2-vector. More...
 
static float Normalize2D (float v[2])
 Normalize (in place) a 2-vector. More...
 
static double Normalize2D (double v[2])
 Normalize (in place) a 2-vector. More...
 
static float Determinant2x2 (const float c1[2], const float c2[2])
 Compute determinant of 2x2 matrix. More...
 
template<int RowsT, int MidDimT, int ColsT, class LayoutT1 = vtkMatrixUtilities::Layout::Identity, class LayoutT2 = vtkMatrixUtilities::Layout::Identity, class MatrixT1 , class MatrixT2 , class MatrixT3 >
static void MultiplyMatrix (MatrixT1 &&M1, MatrixT2 &&M2, MatrixT3 &&M3)
 Multiply matrices such that M3 = M1 x M2. More...
 
template<int RowsT, int ColsT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT , class VectorT1 , class VectorT2 >
static void MultiplyMatrixWithVector (MatrixT &&M, VectorT1 &&X, VectorT2 &&Y)
 Multiply matrix M with vector Y such that Y = M x X. More...
 
template<class ScalarT , int SizeT, class VectorT1 , class VectorT2 , class = typename std::enable_if<SizeT != DYNAMIC_VECTOR_SIZE()>::type>
static ScalarT Dot (VectorT1 &&x, VectorT2 &&y)
 Computes the dot product between 2 vectors x and y. More...
 
template<class ScalarT , int SizeT, class VectorT1 , class VectorT2 , class = typename std::enable_if<SizeT == DYNAMIC_VECTOR_SIZE()>::type, class = EnableIfVectorImplementsSize<VectorT1>>
static ScalarT Dot (VectorT1 &&x, VectorT2 &&y)
 Computes the dot product between 2 vectors x and y. More...
 
template<int SizeT, class VectorT >
static vtkMatrixUtilities::ScalarTypeExtractor< VectorT >::value_type SquaredNorm (VectorT &&x)
 Computes the dot product between 2 vectors x and y. More...
 
template<int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT >
static vtkMatrixUtilities::ScalarTypeExtractor< MatrixT >::value_type Determinant (MatrixT &&M)
 Computes the determinant of input square SizeT x SizeT matrix M. More...
 
template<int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT1 , class MatrixT2 >
static void InvertMatrix (MatrixT1 &&M1, MatrixT2 &&M2)
 Computes the inverse of input matrix M1 into M2. More...
 
template<int RowsT, int ColsT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT , class VectorT1 , class VectorT2 >
static void LinearSolve (MatrixT &&M, VectorT1 &&x, VectorT2 &&y)
 This method solves linear systems M * x = y. More...
 
template<class ScalarT , int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class VectorT1 , class MatrixT , class VectorT2 , class = typename std::enable_if<SizeT != DYNAMIC_VECTOR_SIZE()>::type>
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. More...
 
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. More...
 
static float Determinant3x3 (const float c1[3], const float c2[3], const float c3[3])
 Compute determinant of 3x3 matrix. More...
 
static double Determinant3x3 (const double c1[3], const double c2[3], const double c3[3])
 Compute determinant of 3x3 matrix. More...
 
static double Determinant3x3 (double a1, double a2, double a3, double b1, double b2, double b3, double c1, double c2, double c3)
 Calculate the determinant of a 3x3 matrix in the form: | a1, b1, c1 | | a2, b2, c2 | | a3, b3, c3 |. More...
 
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. More...
 
static vtkTypeBool SolveLinearSystem (double **A, double *x, int size)
 Solve linear equations Ax = b using Crout's method. More...
 
static vtkTypeBool InvertMatrix (double **A, double **AI, int size)
 Invert input square matrix A into matrix AI. More...
 
static vtkTypeBool InvertMatrix (double **A, double **AI, int size, int *tmp1Size, double *tmp2Size)
 Thread safe version of InvertMatrix method. More...
 
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 triangular matrix and U is upper triangular matrix. More...
 
static vtkTypeBool LUFactorLinearSystem (double **A, int *index, int size, double *tmpSize)
 Thread safe version of LUFactorLinearSystem method. More...
 
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 is upper triangular matrix. More...
 
static double EstimateMatrixCondition (const double *const *A, int size)
 Estimate the condition number of a LU factored matrix. More...
 
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'. More...
 
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'. More...
 
template<class T >
static T ClampValue (const T &value, const T &min, const T &max)
 Clamp some value against a range, return the result. More...
 
static double ClampAndNormalizeValue (double value, const double range[2])
 Clamp a value against a range and then normalize it between 0 and 1. More...
 
template<class T1 , class T2 >
static void TensorFromSymmetricTensor (const T1 symmTensor[6], T2 tensor[9])
 Convert a 6-Component symmetric tensor into a 9-Component tensor, no allocation performed. More...
 
template<class T >
static void TensorFromSymmetricTensor (T tensor[9])
 Convert a 6-Component symmetric tensor into a 9-Component tensor, overwriting the tensor input. More...
 
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 once it has been scaled and shifted (i.e. More...
 
static vtkTypeBool GetAdjustedScalarRange (vtkDataArray *array, int comp, double range[2])
 Get a vtkDataArray's scalar range for a given component. More...
 
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, y-max, z-min, z-max. More...
 
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, y-min, y-max, z-min, z-max Delta is the error margin along each axis (usually a small number) More...
 
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, z-min, z-max Delta is the error margin along each axis (usually a small number) More...
 
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, Ned Greene; pp. More...
 
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, P2, and P3. More...
 
static double Inf ()
 Special IEEE-754 number used to represent positive infinity. More...
 
static double NegInf ()
 Special IEEE-754 number used to represent negative infinity. More...
 
static double Nan ()
 Special IEEE-754 number used to represent Not-A-Number (Nan). More...
 
static vtkTypeBool IsInf (double x)
 Test if a number is equal to the special floating point value infinity. More...
 
static vtkTypeBool IsNan (double x)
 Test if a number is equal to the special floating point value Not-A-Number (Nan). More...
 
static bool IsFinite (double x)
 Test if a number has finite value i.e. More...
 
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. More...
 
static vtkIdType ComputeGCD (vtkIdType m, vtkIdType n)
 Compute the greatest common divisor (GCD) of two positive integers m and n. More...
 
template<class Iter1 , class Iter2 , class Iter3 >
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. More...
 
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 p2. More...
 
static float RadiansFromDegrees (float degrees)
 Convert degrees into radians. More...
 
static double RadiansFromDegrees (double degrees)
 Convert degrees into radians. More...
 
static float DegreesFromRadians (float radians)
 Convert radians into degrees. More...
 
static double DegreesFromRadians (double radians)
 Convert radians into degrees. More...
 
static float Norm (const float *x, int n)
 Compute the norm of n-vector. More...
 
static double Norm (const double *x, int n)
 Compute the norm of n-vector. More...
 
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.e. More...
 
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.e. More...
 
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]. More...
 
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]. More...
 
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]. More...
 
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]. More...
 
static double Determinant2x2 (double a, double b, double c, double d)
 Calculate the determinant of a 2x2 matrix: | a b | | c d |. More...
 
static double Determinant2x2 (const double c1[2], const double c2[2])
 Calculate the determinant of a 2x2 matrix: | a b | | c d |. More...
 
static void LUFactor3x3 (float A[3][3], int index[3])
 LU Factorization of a 3x3 matrix. More...
 
static void LUFactor3x3 (double A[3][3], int index[3])
 LU Factorization of a 3x3 matrix. More...
 
static void LUSolve3x3 (const float A[3][3], const int index[3], float x[3])
 LU back substitution for a 3x3 matrix. More...
 
static void LUSolve3x3 (const double A[3][3], const int index[3], double x[3])
 LU back substitution for a 3x3 matrix. More...
 
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. More...
 
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. More...
 
static void Multiply3x3 (const float A[3][3], const float v[3], float u[3])
 Multiply a vector by a 3x3 matrix. More...
 
static void Multiply3x3 (const double A[3][3], const double v[3], double u[3])
 Multiply a vector by a 3x3 matrix. More...
 
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. More...
 
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. More...
 
static void Transpose3x3 (const float A[3][3], float AT[3][3])
 Transpose a 3x3 matrix. More...
 
static void Transpose3x3 (const double A[3][3], double AT[3][3])
 Transpose a 3x3 matrix. More...
 
static void Invert3x3 (const float A[3][3], float AI[3][3])
 Invert a 3x3 matrix. More...
 
static void Invert3x3 (const double A[3][3], double AI[3][3])
 Invert a 3x3 matrix. More...
 
static void Identity3x3 (float A[3][3])
 Set A to the identity matrix. More...
 
static void Identity3x3 (double A[3][3])
 Set A to the identity matrix. More...
 
static double Determinant3x3 (const float A[3][3])
 Return the determinant of a 3x3 matrix. More...
 
static double Determinant3x3 (const double A[3][3])
 Return the determinant of a 3x3 matrix. More...
 
static void QuaternionToMatrix3x3 (const float quat[4], float A[3][3])
 Convert a quaternion to a 3x3 rotation matrix. More...
 
static void QuaternionToMatrix3x3 (const double quat[4], double A[3][3])
 Convert a quaternion to a 3x3 rotation matrix. More...
 
template<class QuaternionT , class MatrixT , class EnableT = typename std::enable_if<!vtkMatrixUtilities::MatrixIs2DArray<MatrixT>()>::type>
static void QuaternionToMatrix3x3 (QuaternionT &&q, MatrixT &&A)
 Convert a quaternion to a 3x3 rotation matrix. More...
 
static void Matrix3x3ToQuaternion (const float A[3][3], float quat[4])
 Convert a 3x3 matrix into a quaternion. More...
 
static void Matrix3x3ToQuaternion (const double A[3][3], double quat[4])
 Convert a 3x3 matrix into a quaternion. More...
 
template<class MatrixT , class QuaternionT , class EnableT = typename std::enable_if<!vtkMatrixUtilities::MatrixIs2DArray<MatrixT>()>::type>
static void Matrix3x3ToQuaternion (MatrixT &&A, QuaternionT &&q)
 Convert a 3x3 matrix into a quaternion. More...
 
static void MultiplyQuaternion (const float q1[4], const float q2[4], float q[4])
 Multiply two quaternions. More...
 
static void MultiplyQuaternion (const double q1[4], const double q2[4], double q[4])
 Multiply two quaternions. More...
 
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_rotation_formula More...
 
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_rotation_formula More...
 
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 More...
 
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 More...
 
static void Orthogonalize3x3 (const float A[3][3], float B[3][3])
 Orthogonalize a 3x3 matrix and put the result in B. More...
 
static void Orthogonalize3x3 (const double A[3][3], double B[3][3])
 Orthogonalize a 3x3 matrix and put the result in B. More...
 
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 columns of V. More...
 
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 columns of V. More...
 
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. More...
 
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. More...
 
static vtkTypeBool Jacobi (float **a, float *w, float **v)
 Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix. More...
 
static vtkTypeBool Jacobi (double **a, double *w, double **v)
 Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix. More...
 
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. More...
 
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. More...
 
static void RGBToHSV (const float rgb[3], float hsv[3])
 Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value). More...
 
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). More...
 
static void RGBToHSV (const double rgb[3], double hsv[3])
 Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value). More...
 
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). More...
 
static void HSVToRGB (const float hsv[3], float rgb[3])
 Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue). More...
 
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). More...
 
static void HSVToRGB (const double hsv[3], double rgb[3])
 Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue). More...
 
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). More...
 
static void LabToXYZ (const double lab[3], double xyz[3])
 Convert color from the CIE-L*ab system to CIE XYZ. More...
 
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. More...
 
static void XYZToLab (const double xyz[3], double lab[3])
 Convert Color from the CIE XYZ system to CIE-L*ab. More...
 
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. More...
 
static void XYZToRGB (const double xyz[3], double rgb[3])
 Convert color from the CIE XYZ system to RGB. More...
 
static void XYZToRGB (double x, double y, double z, double *r, double *g, double *b)
 Convert color from the CIE XYZ system to RGB. More...
 
static void RGBToXYZ (const double rgb[3], double xyz[3])
 Convert color from the RGB system to CIE XYZ. More...
 
static void RGBToXYZ (double r, double g, double b, double *x, double *y, double *z)
 Convert color from the RGB system to CIE XYZ. More...
 
static void RGBToLab (const double rgb[3], double lab[3])
 Convert color from the RGB system to CIE-L*ab. More...
 
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. More...
 
static void LabToRGB (const double lab[3], double rgb[3])
 Convert color from the CIE-L*ab system to RGB. More...
 
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. More...
 
static void UninitializeBounds (double bounds[6])
 Set the bounds to an uninitialized state. More...
 
static vtkTypeBool AreBoundsInitialized (const double bounds[6])
 Are the bounds initialized? More...
 
static void ClampValue (double *value, const double range[2])
 Clamp some values against a range The method without 'clamped_values' will perform in-place clamping. More...
 
static void ClampValue (double value, const double range[2], double *clamped_value)
 Clamp some values against a range The method without 'clamped_values' will perform in-place clamping. More...
 
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. More...
 
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. More...
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void BreakOnError ()
 This method is called when vtkErrorMacro executes. More...
 
static void SetGlobalWarningDisplay (vtkTypeBool val)
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOn ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOff ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static vtkTypeBool GetGlobalWarningDisplay ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class. More...
 
static vtkIdType GetNumberOfGenerationsFromBaseType (const char *name)
 Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void SetMemkindDirectory (const char *directoryname)
 The name of a directory, ideally mounted -o dax, to memory map an extended memory space within. More...
 
static bool GetUsingMemkind ()
 A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space. More...
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkMath ()=default
 
 ~vtkMath () override=default
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
 ~vtkObject () override
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
 These methods allow a command to exclusively grab all events. More...
 
void InternalReleaseFocus ()
 These methods allow a command to exclusively grab all events. More...
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Static Protected Attributes

static vtkSmartPointer< vtkMathInternal > Internal
 

Additional Inherited Members

- Static Protected Member Functions inherited from vtkObjectBase
static vtkMallocingFunction GetCurrentMallocFunction ()
 
static vtkReallocingFunction GetCurrentReallocFunction ()
 
static vtkFreeingFunction GetCurrentFreeFunction ()
 
static vtkFreeingFunction GetAlternateFreeFunction ()
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
std::string ObjectName
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

performs common math operations

vtkMath provides methods to perform common math operations. These include providing constants such as Pi; conversion from degrees to radians; vector operations such as dot and cross products and vector norm; matrix determinant for 2x2 and 3x3 matrices; univariate polynomial solvers; and for random number generation (for backward compatibility only).

See also
vtkMinimalStandardRandomSequence, vtkBoxMuellerRandomSequence, vtkQuaternion
Examples:
vtkMath (Examples)
Online Examples:

Tests:
vtkMath (Tests)

Definition at line 187 of file vtkMath.h.

Member Typedef Documentation

◆ Superclass

Definition at line 191 of file vtkMath.h.

Member Enumeration Documentation

◆ ConvolutionMode

Support the convolution operations.

Enumerator
FULL 
SAME 
VALID 

Definition at line 1744 of file vtkMath.h.

Constructor & Destructor Documentation

◆ vtkMath()

vtkMath::vtkMath ( )
protecteddefault

◆ ~vtkMath()

vtkMath::~vtkMath ( )
overrideprotecteddefault

Member Function Documentation

◆ New()

static vtkMath* vtkMath::New ( )
static

◆ IsTypeOf()

static vtkTypeBool vtkMath::IsTypeOf ( const char *  type)
static

◆ IsA()

virtual vtkTypeBool vtkMath::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class.

Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObjectBase.

◆ SafeDownCast()

static vtkMath* vtkMath::SafeDownCast ( vtkObjectBase o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase* vtkMath::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkMath* vtkMath::NewInstance ( ) const

◆ PrintSelf()

void vtkMath::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
overridevirtual

Methods invoked by print to print information about the object including superclasses.

Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObjectBase.

◆ DYNAMIC_VECTOR_SIZE()

static constexpr int vtkMath::DYNAMIC_VECTOR_SIZE ( )
inlinestaticconstexpr

When this value is passed to a select templated functions in vtkMath, the computation can be performed on dynamic sized arrays as long as they implement the method size().

One can also pass this constant to vtkDataArrayTupleRange to get dynamic sized tuples.

See also
vtkDataArrayRange

Definition at line 222 of file vtkMath.h.

◆ Pi()

static constexpr double vtkMath::Pi ( )
inlinestaticconstexpr

A mathematical constant.

This version is atan(1.0) * 4.0

Definition at line 227 of file vtkMath.h.

◆ RadiansFromDegrees() [1/2]

float vtkMath::RadiansFromDegrees ( float  degrees)
inlinestatic

Convert degrees into radians.

Definition at line 1840 of file vtkMath.h.

◆ RadiansFromDegrees() [2/2]

double vtkMath::RadiansFromDegrees ( double  degrees)
inlinestatic

Convert degrees into radians.

Definition at line 1846 of file vtkMath.h.

◆ DegreesFromRadians() [1/2]

float vtkMath::DegreesFromRadians ( float  radians)
inlinestatic

Convert radians into degrees.

Definition at line 1852 of file vtkMath.h.

◆ DegreesFromRadians() [2/2]

double vtkMath::DegreesFromRadians ( double  radians)
inlinestatic

Convert radians into degrees.

Definition at line 1858 of file vtkMath.h.

◆ Round() [1/2]

static int vtkMath::Round ( float  f)
inlinestatic

Rounds a float to the nearest integer.

Definition at line 249 of file vtkMath.h.

◆ Round() [2/2]

static int vtkMath::Round ( double  f)
inlinestatic

Definition at line 250 of file vtkMath.h.

◆ RoundDoubleToIntegralIfNecessary()

template<typename OutT >
static void vtkMath::RoundDoubleToIntegralIfNecessary ( double  val,
OutT *  ret 
)
inlinestatic

Round a double to type OutT if OutT is integral, otherwise simply clamp the value to the output range.

Definition at line 258 of file vtkMath.h.

◆ Floor()

int vtkMath::Floor ( double  x)
inlinestatic

Rounds a double to the nearest integer not greater than itself.

This is faster than floor() but provides undefined output on overflow.

Definition at line 1885 of file vtkMath.h.

◆ Ceil()

int vtkMath::Ceil ( double  x)
inlinestatic

Rounds a double to the nearest integer not less than itself.

This is faster than ceil() but provides undefined output on overflow.

Definition at line 1894 of file vtkMath.h.

◆ CeilLog2()

static int vtkMath::CeilLog2 ( vtkTypeUInt64  x)
static

Gives the exponent of the lowest power of two not less than x.

Or in mathspeak, return the smallest "i" for which 2^i >= x. If x is zero, then the return value will be zero.

◆ Min()

template<class T >
T vtkMath::Min ( const T &  a,
const T &  b 
)
inlinestatic

Returns the minimum of the two arguments provided.

If either argument is NaN, the first argument will always be returned.

Definition at line 1902 of file vtkMath.h.

◆ Max()

template<class T >
T vtkMath::Max ( const T &  a,
const T &  b 
)
inlinestatic

Returns the maximum of the two arguments provided.

If either argument is NaN, the first argument will always be returned.

Definition at line 1909 of file vtkMath.h.

◆ IsPowerOfTwo()

bool vtkMath::IsPowerOfTwo ( vtkTypeUInt64  x)
inlinestatic

Returns true if integer is a power of two.

Definition at line 1864 of file vtkMath.h.

◆ NearestPowerOfTwo()

int vtkMath::NearestPowerOfTwo ( int  x)
inlinestatic

Compute the nearest power of two that is not less than x.

The return value is 1 if x is less than or equal to zero, and is VTK_INT_MIN if result is too large to fit in an int.

Definition at line 1871 of file vtkMath.h.

◆ Factorial()

static vtkTypeInt64 vtkMath::Factorial ( int  N)
static

Compute N factorial, N! = N*(N-1) * (N-2)...*3*2*1.

0! is taken to be 1.

◆ Binomial()

static vtkTypeInt64 vtkMath::Binomial ( int  m,
int  n 
)
static

The number of combinations of n objects from a pool of m objects (m>n).

This is commonly known as "m choose n" and sometimes denoted \(_mC_n\) or \(\left(\begin{array}{c}m \\ n\end{array}\right)\).

◆ BeginCombination()

static int* vtkMath::BeginCombination ( int  m,
int  n 
)
static

Start iterating over "m choose n" objects.

This function returns an array of n integers, each from 0 to m-1. These integers represent the n items chosen from the set [0,m[.

You are responsible for calling vtkMath::FreeCombination() once the iterator is no longer needed.

Warning: this gets large very quickly, especially when n nears m/2! (Hint: think of Pascal's triangle.)

◆ NextCombination()

static int vtkMath::NextCombination ( int  m,
int  n,
int *  combination 
)
static

Given m, n, and a valid combination of n integers in the range [0,m[, this function alters the integers into the next combination in a sequence of all combinations of n items from a pool of m.

If the combination is the last item in the sequence on input, then combination is unaltered and 0 is returned. Otherwise, 1 is returned and combination is updated.

◆ FreeCombination()

static void vtkMath::FreeCombination ( int *  combination)
static

Free the "iterator" array created by vtkMath::BeginCombination.

◆ RandomSeed()

static void vtkMath::RandomSeed ( int  s)
static

Initialize seed value.

NOTE: Random() has the bad property that the first random number returned after RandomSeed() is called is proportional to the seed value! To help solve this, call RandomSeed() a few times inside seed. This doesn't ruin the repeatability of Random().

DON'T USE Random(), RandomSeed(), GetSeed(), Gaussian() THIS IS STATIC SO THIS IS PRONE TO ERRORS (SPECIALLY FOR REGRESSION TESTS) THIS IS HERE FOR BACKWARD COMPATIBILITY ONLY. Instead, for a sequence of random numbers with a uniform distribution create a vtkMinimalStandardRandomSequence object. For a sequence of random numbers with a gaussian/normal distribution create a vtkBoxMuellerRandomSequence object.

◆ GetSeed()

static int vtkMath::GetSeed ( )
static

Return the current seed used by the random number generator.

DON'T USE Random(), RandomSeed(), GetSeed(), Gaussian() THIS IS STATIC SO THIS IS PRONE TO ERRORS (SPECIALLY FOR REGRESSION TESTS) THIS IS HERE FOR BACKWARD COMPATIBILITY ONLY. Instead, for a sequence of random numbers with a uniform distribution create a vtkMinimalStandardRandomSequence object. For a sequence of random numbers with a gaussian/normal distribution create a vtkBoxMuellerRandomSequence object.

◆ Random() [1/2]

static double vtkMath::Random ( )
static

Generate pseudo-random numbers distributed according to the uniform distribution between 0.0 and 1.0.

This is used to provide portability across different systems.

DON'T USE Random(), RandomSeed(), GetSeed(), Gaussian() THIS IS STATIC SO THIS IS PRONE TO ERRORS (SPECIALLY FOR REGRESSION TESTS) THIS IS HERE FOR BACKWARD COMPATIBILITY ONLY. Instead, for a sequence of random numbers with a uniform distribution create a vtkMinimalStandardRandomSequence object. For a sequence of random numbers with a gaussian/normal distribution create a vtkBoxMuellerRandomSequence object.

◆ Random() [2/2]

static double vtkMath::Random ( double  min,
double  max 
)
static

Generate pseudo-random numbers distributed according to the uniform distribution between min and max.

DON'T USE Random(), RandomSeed(), GetSeed(), Gaussian() THIS IS STATIC SO THIS IS PRONE TO ERRORS (SPECIALLY FOR REGRESSION TESTS) THIS IS HERE FOR BACKWARD COMPATIBILITY ONLY. Instead, for a sequence of random numbers with a uniform distribution create a vtkMinimalStandardRandomSequence object. For a sequence of random numbers with a gaussian/normal distribution create a vtkBoxMuellerRandomSequence object.

◆ Gaussian() [1/2]

static double vtkMath::Gaussian ( )
static

Generate pseudo-random numbers distributed according to the standard normal distribution.

DON'T USE Random(), RandomSeed(), GetSeed(), Gaussian() THIS IS STATIC SO THIS IS PRONE TO ERRORS (SPECIALLY FOR REGRESSION TESTS) THIS IS HERE FOR BACKWARD COMPATIBILITY ONLY. Instead, for a sequence of random numbers with a uniform distribution create a vtkMinimalStandardRandomSequence object. For a sequence of random numbers with a gaussian/normal distribution create a vtkBoxMuellerRandomSequence object.

◆ Gaussian() [2/2]

static double vtkMath::Gaussian ( double  mean,
double  std 
)
static

Generate pseudo-random numbers distributed according to the Gaussian distribution with mean mean and standard deviation std.

DON'T USE Random(), RandomSeed(), GetSeed(), Gaussian() THIS IS STATIC SO THIS IS PRONE TO ERRORS (SPECIALLY FOR REGRESSION TESTS) THIS IS HERE FOR BACKWARD COMPATIBILITY ONLY. Instead, for a sequence of random numbers with a uniform distribution create a vtkMinimalStandardRandomSequence object. For a sequence of random numbers with a gaussian/normal distribution create a vtkBoxMuellerRandomSequence object.

◆ Assign() [1/2]

template<class VectorT1 , class VectorT2 >
static void vtkMath::Assign ( const VectorT1 &  a,
VectorT2 &&  b 
)
inlinestatic

Assign values to a 3-vector (templated version).

Result is stored in b according to b = a. Each parameter must implement operator[].

Definition at line 447 of file vtkMath.h.

◆ Assign() [2/2]

static void vtkMath::Assign ( const double  a[3],
double  b[3] 
)
inlinestatic

Assign values to a 3-vector (double version).

Result is stored in b according to b = a.

Definition at line 457 of file vtkMath.h.

◆ Add() [1/3]

static void vtkMath::Add ( const float  a[3],
const float  b[3],
float  c[3] 
)
inlinestatic

Addition of two 3-vectors (float version).

Result is stored in c according to c = a + b.

Definition at line 462 of file vtkMath.h.

◆ Add() [2/3]

static void vtkMath::Add ( const double  a[3],
const double  b[3],
double  c[3] 
)
inlinestatic

Addition of two 3-vectors (double version).

Result is stored in c according to c = a + b.

Definition at line 473 of file vtkMath.h.

◆ Add() [3/3]

template<class VectorT1 , class VectorT2 , class VectorT3 >
static void vtkMath::Add ( VectorT1 &&  a,
VectorT2 &&  b,
VectorT3 &  c 
)
inlinestatic

Addition of two 3-vectors (double version).

Result is stored in c according to c = a + b.

Each parameter needs to implement operator[]

Definition at line 487 of file vtkMath.h.

◆ Subtract() [1/3]

static void vtkMath::Subtract ( const float  a[3],
const float  b[3],
float  c[3] 
)
inlinestatic

Subtraction of two 3-vectors (float version).

Result is stored in c according to c = a - b.

Definition at line 498 of file vtkMath.h.

◆ Subtract() [2/3]

static void vtkMath::Subtract ( const double  a[3],
const double  b[3],
double  c[3] 
)
inlinestatic

Subtraction of two 3-vectors (double version).

Result is stored in c according to c = a - b.

Definition at line 509 of file vtkMath.h.

◆ Subtract() [3/3]

template<class VectorT1 , class VectorT2 , class VectorT3 >
static void vtkMath::Subtract ( const VectorT1 &  a,
const VectorT2 &  b,
VectorT3 &&  c 
)
inlinestatic

Subtraction of two 3-vectors (templated version).

Result is stored in c according to c = a - b.

Each parameter needs to implement operator[].

Definition at line 523 of file vtkMath.h.

◆ MultiplyScalar() [1/2]

static void vtkMath::MultiplyScalar ( float  a[3],
float  s 
)
inlinestatic

Multiplies a 3-vector by a scalar (float version).

This modifies the input 3-vector.

Definition at line 534 of file vtkMath.h.

◆ MultiplyScalar2D() [1/2]

static void vtkMath::MultiplyScalar2D ( float  a[2],
float  s 
)
inlinestatic

Multiplies a 2-vector by a scalar (float version).

This modifies the input 2-vector.

Definition at line 546 of file vtkMath.h.

◆ MultiplyScalar() [2/2]

static void vtkMath::MultiplyScalar ( double  a[3],
double  s 
)
inlinestatic

Multiplies a 3-vector by a scalar (double version).

This modifies the input 3-vector.

Definition at line 558 of file vtkMath.h.

◆ MultiplyScalar2D() [2/2]

static void vtkMath::MultiplyScalar2D ( double  a[2],
double  s 
)
inlinestatic

Multiplies a 2-vector by a scalar (double version).

This modifies the input 2-vector.

Definition at line 570 of file vtkMath.h.

◆ Dot() [1/6]

static float vtkMath::Dot ( const float  a[3],
const float  b[3] 
)
inlinestatic

Dot product of two 3-vectors (float version).

Definition at line 581 of file vtkMath.h.

◆ Dot() [2/6]

static double vtkMath::Dot ( const double  a[3],
const double  b[3] 
)
inlinestatic

Dot product of two 3-vectors (double version).

Definition at line 589 of file vtkMath.h.

◆ Dot() [3/6]

template<typename ReturnTypeT = double, typename TupleRangeT1 , typename TupleRangeT2 , typename EnableT = typename std::conditional<!std::is_pointer<TupleRangeT1>::value && !std::is_array<TupleRangeT1>::value, TupleRangeT1, TupleRangeT2>::type::value_type>
static ReturnTypeT vtkMath::Dot ( const TupleRangeT1 &  a,
const TupleRangeT2 &  b 
)
inlinestatic

Compute dot product between two points p1 and p2.

This version allows for custom range and iterator types to be used. These types must implement operator[], and at least one of them must have a value_type typedef.

The first template parameter ReturnTypeT sets the return type of this method. By default, it is set to double, but it can be overridden.

The EnableT template parameter is used to make sure that this version doesn't capture the float*, float[], double*, double[] as those should go to the other Distance2BetweenPoints functions.

Warning
This method assumes that both parameters have 3 components.

Definition at line 613 of file vtkMath.h.

◆ Outer() [1/2]

static void vtkMath::Outer ( const float  a[3],
const float  b[3],
float  c[3][3] 
)
inlinestatic

Outer product of two 3-vectors (float version).

Definition at line 621 of file vtkMath.h.

◆ Outer() [2/2]

static void vtkMath::Outer ( const double  a[3],
const double  b[3],
double  c[3][3] 
)
inlinestatic

Outer product of two 3-vectors (double version).

Definition at line 635 of file vtkMath.h.

◆ Cross() [1/3]

template<class VectorT1 , class VectorT2 , class VectorT3 >
void vtkMath::Cross ( VectorT1 &&  a,
VectorT2 &&  b,
VectorT3 &  c 
)
static

Cross product of two 3-vectors.

Result (a x b) is stored in c.

Input vectors need to implement operator[]

Definition at line 2016 of file vtkMath.h.

◆ Cross() [2/3]

void vtkMath::Cross ( const float  a[3],
const float  b[3],
float  c[3] 
)
inlinestatic

Cross product of two 3-vectors.

Result (a x b) is stored in c. (float version)

Definition at line 2025 of file vtkMath.h.

◆ Cross() [3/3]

void vtkMath::Cross ( const double  a[3],
const double  b[3],
double  c[3] 
)
inlinestatic

Cross product of two 3-vectors.

Result (a x b) is stored in c. (double version)

Definition at line 2037 of file vtkMath.h.

◆ Norm() [1/4]

static float vtkMath::Norm ( const float *  x,
int  n 
)
static

Compute the norm of n-vector.

x is the vector, n is its length.

◆ Norm() [2/4]

static double vtkMath::Norm ( const double *  x,
int  n 
)
static

Compute the norm of n-vector.

x is the vector, n is its length.

◆ Norm() [3/4]

static float vtkMath::Norm ( const float  v[3])
inlinestatic

Compute the norm of 3-vector (float version).

Definition at line 677 of file vtkMath.h.

◆ Norm() [4/4]

static double vtkMath::Norm ( const double  v[3])
inlinestatic

Compute the norm of 3-vector (double version).

Definition at line 682 of file vtkMath.h.

◆ SquaredNorm() [1/2]

template<typename ReturnTypeT = double, typename TupleRangeT >
static ReturnTypeT vtkMath::SquaredNorm ( const TupleRangeT &  v)
inlinestatic

Compute the squared norm of a 3-vector.

The first template parameter ReturnTypeT sets the return type of this method. By default, it is set to double, but it can be overridden.

The parameter of this function must be a container, and array, or a range of 3 components implementing operator[].

Definition at line 697 of file vtkMath.h.

◆ Normalize() [1/2]

float vtkMath::Normalize ( float  v[3])
inlinestatic

Normalize (in place) a 3-vector.

Returns norm of vector. (float version)

Definition at line 1915 of file vtkMath.h.

◆ Normalize() [2/2]

double vtkMath::Normalize ( double  v[3])
inlinestatic

Normalize (in place) a 3-vector.

Returns norm of vector (double version).

Definition at line 1929 of file vtkMath.h.

◆ Perpendiculars() [1/2]

static void vtkMath::Perpendiculars ( const double  v1[3],
double  v2[3],
double  v3[3],
double  theta 
)
static

Given a unit vector v1, find two unit vectors v2 and v3 such that v1 cross v2 = v3 (i.e.

the vectors are perpendicular to each other). There is an infinite number of such vectors, specify an angle theta to choose one set. If you want only one perpendicular vector, specify nullptr for v3.

◆ Perpendiculars() [2/2]

static void vtkMath::Perpendiculars ( const float  v1[3],
float  v2[3],
float  v3[3],
double  theta 
)
static

Given a unit vector v1, find two unit vectors v2 and v3 such that v1 cross v2 = v3 (i.e.

the vectors are perpendicular to each other). There is an infinite number of such vectors, specify an angle theta to choose one set. If you want only one perpendicular vector, specify nullptr for v3.

◆ ProjectVector() [1/2]

static bool vtkMath::ProjectVector ( const float  a[3],
const float  b[3],
float  projection[3] 
)
static

Compute the projection of vector a on vector b and return it in projection[3].

If b is a zero vector, the function returns false and 'projection' is invalid. Otherwise, it returns true.

◆ ProjectVector() [2/2]

static bool vtkMath::ProjectVector ( const double  a[3],
const double  b[3],
double  projection[3] 
)
static

Compute the projection of vector a on vector b and return it in projection[3].

If b is a zero vector, the function returns false and 'projection' is invalid. Otherwise, it returns true.

◆ ProjectVector2D() [1/2]

static bool vtkMath::ProjectVector2D ( const float  a[2],
const float  b[2],
float  projection[2] 
)
static

Compute the projection of 2D vector a on 2D vector b and returns the result in projection[2].

If b is a zero vector, the function returns false and 'projection' is invalid. Otherwise, it returns true.

◆ ProjectVector2D() [2/2]

static bool vtkMath::ProjectVector2D ( const double  a[2],
const double  b[2],
double  projection[2] 
)
static

Compute the projection of 2D vector a on 2D vector b and returns the result in projection[2].

If b is a zero vector, the function returns false and 'projection' is invalid. Otherwise, it returns true.

◆ Distance2BetweenPoints() [1/3]

template<typename ReturnTypeT , typename TupleRangeT1 , typename TupleRangeT2 , typename EnableT >
ReturnTypeT vtkMath::Distance2BetweenPoints ( const TupleRangeT1 &  p1,
const TupleRangeT2 &  p2 
)
inlinestatic

Compute distance squared between two points p1 and p2.

This version allows for custom range and iterator types to be used. These types must implement operator[], and at least one of them must have a value_type typedef.

The first template parameter ReturnTypeT sets the return type of this method. By default, it is set to double, but it can be overridden.

The EnableT template parameter is used to make sure that this version doesn't capture the float*, float[], double*, double[] as those should go to the other Distance2BetweenPoints functions.

Warning
This method assumes that both parameters have 3 components.

Definition at line 2008 of file vtkMath.h.

◆ Distance2BetweenPoints() [2/3]

float vtkMath::Distance2BetweenPoints ( const float  p1[3],
const float  p2[3] 
)
inlinestatic

Compute distance squared between two points p1 and p2.

(float version).

Definition at line 1993 of file vtkMath.h.

◆ Distance2BetweenPoints() [3/3]

double vtkMath::Distance2BetweenPoints ( const double  p1[3],
const double  p2[3] 
)
inlinestatic

Compute distance squared between two points p1 and p2.

(double version).

Definition at line 2000 of file vtkMath.h.

◆ AngleBetweenVectors()

static double vtkMath::AngleBetweenVectors ( const double  v1[3],
const double  v2[3] 
)
static

Compute angle in radians between two vectors.

◆ SignedAngleBetweenVectors()

static double vtkMath::SignedAngleBetweenVectors ( const double  v1[3],
const double  v2[3],
const double  vn[3] 
)
static

Compute signed angle in radians between two vectors with regard to a third orthogonal vector.

◆ GaussianAmplitude() [1/2]

static double vtkMath::GaussianAmplitude ( double  variance,
double  distanceFromMean 
)
static

Compute the amplitude of a Gaussian function with mean=0 and specified variance.

That is, 1./(std::sqrt(2 Pi * variance)) * exp(-distanceFromMean^2/(2.*variance)).

◆ GaussianAmplitude() [2/2]

static double vtkMath::GaussianAmplitude ( double  mean,
double  variance,
double  position 
)
static

Compute the amplitude of a Gaussian function with specified mean and variance.

That is, 1./(std::sqrt(2 Pi * variance)) * exp(-(position - mean)^2/(2.*variance)).

◆ GaussianWeight() [1/2]

static double vtkMath::GaussianWeight ( double  variance,
double  distanceFromMean 
)
static

Compute the amplitude of an unnormalized Gaussian function with mean=0 and specified variance.

That is, exp(-distanceFromMean^2/(2.*variance)). When distanceFromMean = 0, this function returns 1.

◆ GaussianWeight() [2/2]

static double vtkMath::GaussianWeight ( double  mean,
double  variance,
double  position 
)
static

Compute the amplitude of an unnormalized Gaussian function with specified mean and variance.

That is, exp(-(position - mean)^2/(2.*variance)). When the distance from 'position' to 'mean' is 0, this function returns 1.

◆ Dot2D() [1/2]

static float vtkMath::Dot2D ( const float  x[2],
const float  y[2] 
)
inlinestatic

Dot product of two 2-vectors.

(float version).

Definition at line 820 of file vtkMath.h.

◆ Dot2D() [2/2]

static double vtkMath::Dot2D ( const double  x[2],
const double  y[2] 
)
inlinestatic

Dot product of two 2-vectors.

(double version).

Definition at line 825 of file vtkMath.h.

◆ Outer2D() [1/2]

static void vtkMath::Outer2D ( const float  x[2],
const float  y[2],
float  A[2][2] 
)
inlinestatic

Outer product of two 2-vectors (float version).

Definition at line 830 of file vtkMath.h.

◆ Outer2D() [2/2]

static void vtkMath::Outer2D ( const double  x[2],
const double  y[2],
double  A[2][2] 
)
inlinestatic

Outer product of two 2-vectors (double version).

Definition at line 844 of file vtkMath.h.

◆ Norm2D() [1/2]

static float vtkMath::Norm2D ( const float  x[2])
inlinestatic

Compute the norm of a 2-vector.

(float version).

Definition at line 859 of file vtkMath.h.

◆ Norm2D() [2/2]

static double vtkMath::Norm2D ( const double  x[2])
inlinestatic

Compute the norm of a 2-vector.

(double version).

Definition at line 865 of file vtkMath.h.

◆ Normalize2D() [1/2]

float vtkMath::Normalize2D ( float  v[2])
inlinestatic

Normalize (in place) a 2-vector.

Returns norm of vector. (float version).

Definition at line 1943 of file vtkMath.h.

◆ Normalize2D() [2/2]

double vtkMath::Normalize2D ( double  v[2])
inlinestatic

Normalize (in place) a 2-vector.

Returns norm of vector. (double version).

Definition at line 1957 of file vtkMath.h.

◆ Determinant2x2() [1/3]

static float vtkMath::Determinant2x2 ( const float  c1[2],
const float  c2[2] 
)
inlinestatic

Compute determinant of 2x2 matrix.

Two columns of matrix are input.

Definition at line 882 of file vtkMath.h.

◆ Determinant2x2() [2/3]

static double vtkMath::Determinant2x2 ( double  a,
double  b,
double  c,
double  d 
)
inlinestatic

Calculate the determinant of a 2x2 matrix: | a b | | c d |.

Definition at line 891 of file vtkMath.h.

◆ Determinant2x2() [3/3]

static double vtkMath::Determinant2x2 ( const double  c1[2],
const double  c2[2] 
)
inlinestatic

Calculate the determinant of a 2x2 matrix: | a b | | c d |.

Definition at line 892 of file vtkMath.h.

◆ LUFactor3x3() [1/2]

static void vtkMath::LUFactor3x3 ( float  A[3][3],
int  index[3] 
)
static

LU Factorization of a 3x3 matrix.

◆ LUFactor3x3() [2/2]

static void vtkMath::LUFactor3x3 ( double  A[3][3],
int  index[3] 
)
static

LU Factorization of a 3x3 matrix.

◆ LUSolve3x3() [1/2]

static void vtkMath::LUSolve3x3 ( const float  A[3][3],
const int  index[3],
float  x[3] 
)
static

LU back substitution for a 3x3 matrix.

◆ LUSolve3x3() [2/2]

static void vtkMath::LUSolve3x3 ( const double  A[3][3],
const int  index[3],
double  x[3] 
)
static

LU back substitution for a 3x3 matrix.

◆ LinearSolve3x3() [1/2]

static void vtkMath::LinearSolve3x3 ( const float  A[3][3],
const float  x[3],
float  y[3] 
)
static

Solve Ay = x for y and place the result in y.

The matrix A is destroyed in the process.

◆ LinearSolve3x3() [2/2]

static void vtkMath::LinearSolve3x3 ( const double  A[3][3],
const double  x[3],
double  y[3] 
)
static

Solve Ay = x for y and place the result in y.

The matrix A is destroyed in the process.

◆ Multiply3x3() [1/4]

static void vtkMath::Multiply3x3 ( const float  A[3][3],
const float  v[3],
float  u[3] 
)
static

Multiply a vector by a 3x3 matrix.

The result is placed in out.

◆ Multiply3x3() [2/4]

static void vtkMath::Multiply3x3 ( const double  A[3][3],
const double  v[3],
double  u[3] 
)
static

Multiply a vector by a 3x3 matrix.

The result is placed in out.

◆ Multiply3x3() [3/4]

static void vtkMath::Multiply3x3 ( const float  A[3][3],
const float  B[3][3],
float  C[3][3] 
)
static

Multiply one 3x3 matrix by another according to C = AB.

◆ Multiply3x3() [4/4]

static void vtkMath::Multiply3x3 ( const double  A[3][3],
const double  B[3][3],
double  C[3][3] 
)
static

Multiply one 3x3 matrix by another according to C = AB.

◆ MultiplyMatrix() [1/2]

template<int RowsT, int MidDimT, int ColsT, class LayoutT1 = vtkMatrixUtilities::Layout::Identity, class LayoutT2 = vtkMatrixUtilities::Layout::Identity, class MatrixT1 , class MatrixT2 , class MatrixT3 >
static void vtkMath::MultiplyMatrix ( MatrixT1 &&  M1,
MatrixT2 &&  M2,
MatrixT3 &&  M3 
)
inlinestatic

Multiply matrices such that M3 = M1 x M2.

M3 must already be allocated.

LayoutT1 (resp. LayoutT2) allow to perform basic matrix reindexing for M1 (resp. M2). It should be set to a component of MatrixLayout.

Matrices are assumed to be a 1D array implementing operator[]. The matrices are indexed row by row. Let us develop the effect of LayoutT1 on M1 (the same is true for LayoutT2 on M2). If LayoutT1 == vtkMatrixUtilities::Layout::Identity (default), then M1 indexing is untouched. If LayoutT1 == vtkMatrixUtilities::Layout::Transpose, then M1 is read column-wise. If LayoutT1 == vtkMatrixUtilities::Layout::Diag, then M1 is considered to be composed of non zero elements of a diagonal matrix.

Note
M3 components indexing can be entirely controlled by swapping M1, M2, and turning on or off the appropriate transposition flag. Remember that M3^T = (M1 x M2)^T = M2^T x M1^T
Warning
If both M1 and M2 are used with both layout being diagonal, then M3 will be diagonal as well (i.e. there won't be allocated memory for elements outsize of the diagonal).

Definition at line 966 of file vtkMath.h.

◆ MultiplyMatrixWithVector()

template<int RowsT, int ColsT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT , class VectorT1 , class VectorT2 >
static void vtkMath::MultiplyMatrixWithVector ( MatrixT &&  M,
VectorT1 &&  X,
VectorT2 &&  Y 
)
inlinestatic

Multiply matrix M with vector Y such that Y = M x X.

Y must be allocated.

LayoutT allow to perform basic matrix reindexing. It should be set to a component of MatrixLayout.

Matrix M is assumed to be a 1D array implementing operator[]. The matrix is indexed row by row. If the input array is indexed columns by columns. If LayoutT == vtkMatrixUtilities::Layout::Identity (default), then M indexing is untouched. If LayoutT == vtkMatrixUtilities::Layout::Transpose, then M is read column-wise. If LayoutT == vtkMatrixUtilities::Layout::Diag, then M is considered to be composed of non zero elements of a diagonal matrix.

VectorT1 and VectorT2 are arrays of size RowsT, and must implement operator[].

Warning
In the particular case where M1 and M2 BOTH have layout vtkMatrixUtilities::Layout::Diag, RowsT, MidDimT and ColsT MUST match.

Definition at line 994 of file vtkMath.h.

◆ Dot() [4/6]

template<class ScalarT , int SizeT, class VectorT1 , class VectorT2 , class = typename std::enable_if<SizeT != DYNAMIC_VECTOR_SIZE()>::type>
static ScalarT vtkMath::Dot ( VectorT1 &&  x,
VectorT2 &&  y 
)
inlinestatic

Computes the dot product between 2 vectors x and y.

VectorT1 and VectorT2 are arrays of size SizeT, and must implement operator[].

Definition at line 1007 of file vtkMath.h.

◆ Dot() [5/6]

template<class ScalarT , int SizeT, class VectorT1 , class VectorT2 , class = typename std::enable_if<SizeT == DYNAMIC_VECTOR_SIZE()>::type, class = EnableIfVectorImplementsSize<VectorT1>>
static ScalarT vtkMath::Dot ( VectorT1 &&  x,
VectorT2 &&  y 
)
inlinestatic

Computes the dot product between 2 vectors x and y.

This function is solely invoked when SizeT == DYNAMIC_VECTOR_SIZE(). VectorT1 and VectorT2 are arrays of dynamic size, and must implement operator[] and size().

Definition at line 1024 of file vtkMath.h.

◆ SquaredNorm() [2/2]

template<int SizeT, class VectorT >
static vtkMatrixUtilities::ScalarTypeExtractor<VectorT>::value_type vtkMath::SquaredNorm ( VectorT &&  x)
inlinestatic

Computes the dot product between 2 vectors x and y.

VectorT1 and VectorT2 are arrays of size SizeT, and must implement operator[].

If SizeT == DYNAMIC_VECTOR_SIZE(), then x must implement the method size().

Definition at line 1043 of file vtkMath.h.

◆ Determinant()

template<int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT >
static vtkMatrixUtilities::ScalarTypeExtractor<MatrixT>::value_type vtkMath::Determinant ( MatrixT &&  M)
inlinestatic

Computes the determinant of input square SizeT x SizeT matrix M.

The return type is the same as the underlying scalar type of MatrixT.

LayoutT allow to perform basic matrix reindexing. It should be set to a component of MatrixLayout.

Matrix M is assumed to be a 1D array implementing operator[]. The matrix is indexed row by row. If the input array is indexed columns by columns. If LayoutT == vtkMatrixUtilities::Layout::Identity (default), then M indexing is untouched. If LayoutT == vtkMatrixUtilities::Layout::Transpose, then M is read column-wise. If LayoutT == vtkMatrixUtilities::Layout::Diag, then M is considered to be composed of non zero elements of a diagonal matrix.

This method is currently implemented for SizeT lower or equal to 3.

Definition at line 1067 of file vtkMath.h.

◆ InvertMatrix() [1/3]

template<int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT1 , class MatrixT2 >
static void vtkMath::InvertMatrix ( MatrixT1 &&  M1,
MatrixT2 &&  M2 
)
inlinestatic

Computes the inverse of input matrix M1 into M2.

LayoutT allow to perform basic matrix reindexing of M1. It should be set to a component of MatrixLayout.

Matrix M is assumed to be a 1D array implementing operator[]. The matrix is indexed row by row. If the input array is indexed columns by columns. If LayoutT == vtkMatrixUtilities::Layout::Identity (default), then M indexing is untouched. If LayoutT == vtkMatrixUtilities::Layout::Transpose, then M is read column-wise. If LayoutT == vtkMatrixUtilities::Layout::Diag, then M is considered to be composed of non zero elements of a diagonal matrix.

This method is currently implemented for SizeT lower or equal to 3.

Definition at line 1090 of file vtkMath.h.

◆ LinearSolve()

template<int RowsT, int ColsT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class MatrixT , class VectorT1 , class VectorT2 >
static void vtkMath::LinearSolve ( MatrixT &&  M,
VectorT1 &&  x,
VectorT2 &&  y 
)
inlinestatic

This method solves linear systems M * x = y.

LayoutT allow to perform basic matrix reindexing of M1. It should be set to a component of MatrixLayout.

Matrix M is assumed to be a 1D array implementing operator[]. The matrix is indexed row by row. If the input array is indexed columns by columns. If LayoutT == vtkMatrixUtilities::Layout::Identity (default), then M indexing is untouched. If LayoutT == vtkMatrixUtilities::Layout::Transpose, then M is read column-wise. If LayoutT == vtkMatrixUtilities::Layout::Diag, then M is considered to be composed of non zero elements of a diagonal matrix.

Definition at line 1111 of file vtkMath.h.

◆ Dot() [6/6]

template<class ScalarT , int SizeT, class LayoutT = vtkMatrixUtilities::Layout::Identity, class VectorT1 , class MatrixT , class VectorT2 , class = typename std::enable_if<SizeT != DYNAMIC_VECTOR_SIZE()>::type>
static ScalarT vtkMath::Dot ( VectorT1 &&  x,
MatrixT &&  M,
VectorT2 &&  y 
)
inlinestatic

Computes the dot product x^T M y, where x and y are vectors and M is a metric matrix.

VectorT1 and VectorT2 are arrays of size SizeT, and must implement operator[].

Matrix M is assumed to be a 1D array implementing operator[]. The matrix is indexed row by row. If the input array is indexed columns by columns. If LayoutT == vtkMatrixUtilities::Layout::Identity (default), then M indexing is untouched. If LayoutT == vtkMatrixUtilities::Layout::Transpose, then M is read column-wise. If LayoutT == vtkMatrixUtilities::Layout::Diag, then M is considered to be composed of non zero elements of a diagonal matrix.

Definition at line 1134 of file vtkMath.h.

◆ MultiplyMatrix() [2/2]

static void vtkMath::MultiplyMatrix ( const double *const *  A,
const double *const *  B,
unsigned int  rowA,
unsigned int  colA,
unsigned int  rowB,
unsigned int  colB,
double **  C 
)
static

General matrix multiplication.

You must allocate output storage. colA == rowB and matrix C is rowA x colB

◆ Transpose3x3() [1/2]

static void vtkMath::Transpose3x3 ( const float  A[3][3],
float  AT[3][3] 
)
static

Transpose a 3x3 matrix.

The input matrix is A. The output is stored in AT.

◆ Transpose3x3() [2/2]

static void vtkMath::Transpose3x3 ( const double  A[3][3],
double  AT[3][3] 
)
static

Transpose a 3x3 matrix.

The input matrix is A. The output is stored in AT.

◆ Invert3x3() [1/2]

static void vtkMath::Invert3x3 ( const float  A[3][3],
float  AI[3][3] 
)
static

Invert a 3x3 matrix.

The input matrix is A. The output is stored in AI.

◆ Invert3x3() [2/2]

static void vtkMath::Invert3x3 ( const double  A[3][3],
double  AI[3][3] 
)
static

Invert a 3x3 matrix.

The input matrix is A. The output is stored in AI.

◆ Identity3x3() [1/2]

static void vtkMath::Identity3x3 ( float  A[3][3])
static

Set A to the identity matrix.

◆ Identity3x3() [2/2]

static void vtkMath::Identity3x3 ( double  A[3][3])
static

Set A to the identity matrix.

◆ Determinant3x3() [1/5]

double vtkMath::Determinant3x3 ( const float  A[3][3])
inlinestatic

Return the determinant of a 3x3 matrix.

Definition at line 2056 of file vtkMath.h.

◆ Determinant3x3() [2/5]

double vtkMath::Determinant3x3 ( const double  A[3][3])
inlinestatic

Return the determinant of a 3x3 matrix.

Definition at line 2062 of file vtkMath.h.

◆ Determinant3x3() [3/5]

float vtkMath::Determinant3x3 ( const float  c1[3],
const float  c2[3],
const float  c3[3] 
)
inlinestatic

Compute determinant of 3x3 matrix.

Three columns of matrix are input.

Definition at line 1971 of file vtkMath.h.

◆ Determinant3x3() [4/5]

double vtkMath::Determinant3x3 ( const double  c1[3],
const double  c2[3],
const double  c3[3] 
)
inlinestatic

Compute determinant of 3x3 matrix.

Three columns of matrix are input.

Definition at line 1978 of file vtkMath.h.

◆ Determinant3x3() [5/5]

double vtkMath::Determinant3x3 ( double  a1,
double  a2,
double  a3,
double  b1,
double  b2,
double  b3,
double  c1,
double  c2,
double  c3 
)
inlinestatic

Calculate the determinant of a 3x3 matrix in the form: | a1, b1, c1 | | a2, b2, c2 | | a3, b3, c3 |.

Definition at line 1985 of file vtkMath.h.

◆ QuaternionToMatrix3x3() [1/3]

void vtkMath::QuaternionToMatrix3x3 ( const float  quat[4],
float  A[3][3] 
)
inlinestatic

Convert a quaternion to a 3x3 rotation matrix.

The quaternion does not have to be normalized beforehand. The quaternion must be in the form [w, x, y, z].

See also
Matrix3x3ToQuaternion() MultiplyQuaternion()
vtkQuaternion

Definition at line 2200 of file vtkMath.h.

◆ QuaternionToMatrix3x3() [2/3]

void vtkMath::QuaternionToMatrix3x3 ( const double  quat[4],
double  A[3][3] 
)
inlinestatic

Convert a quaternion to a 3x3 rotation matrix.

The quaternion does not have to be normalized beforehand. The quaternion must be in the form [w, x, y, z].

See also
Matrix3x3ToQuaternion() MultiplyQuaternion()
vtkQuaternion

Definition at line 2206 of file vtkMath.h.

◆ QuaternionToMatrix3x3() [3/3]

template<class QuaternionT , class MatrixT , class EnableT >
void vtkMath::QuaternionToMatrix3x3 ( QuaternionT &&  q,
MatrixT &&  A 
)
inlinestatic

Convert a quaternion to a 3x3 rotation matrix.

The quaternion does not have to be normalized beforehand. The quaternion must be in the form [w, x, y, z].

See also
Matrix3x3ToQuaternion() MultiplyQuaternion()
vtkQuaternion

Definition at line 2213 of file vtkMath.h.

◆ Matrix3x3ToQuaternion() [1/3]

void vtkMath::Matrix3x3ToQuaternion ( const float  A[3][3],
float  quat[4] 
)
inlinestatic

Convert a 3x3 matrix into a quaternion.

This will provide the best possible answer even if the matrix is not a pure rotation matrix. The quaternion is in the form [w, x, y, z]. The method used is that of B.K.P. Horn. See: https://people.csail.mit.edu/bkph/articles/Quaternions.pdf

See also
QuaternionToMatrix3x3() MultiplyQuaternion()
vtkQuaternion

Definition at line 2286 of file vtkMath.h.

◆ Matrix3x3ToQuaternion() [2/3]

void vtkMath::Matrix3x3ToQuaternion ( const double  A[3][3],
double  quat[4] 
)
inlinestatic

Convert a 3x3 matrix into a quaternion.

This will provide the best possible answer even if the matrix is not a pure rotation matrix. The quaternion is in the form [w, x, y, z]. The method used is that of B.K.P. Horn. See: https://people.csail.mit.edu/bkph/articles/Quaternions.pdf

See also
QuaternionToMatrix3x3() MultiplyQuaternion()
vtkQuaternion

Definition at line 2292 of file vtkMath.h.

◆ Matrix3x3ToQuaternion() [3/3]

template<class MatrixT , class QuaternionT , class EnableT >
void vtkMath::Matrix3x3ToQuaternion ( MatrixT &&  A,
QuaternionT &&  q 
)
inlinestatic

Convert a 3x3 matrix into a quaternion.

This will provide the best possible answer even if the matrix is not a pure rotation matrix. The quaternion is in the form [w, x, y, z]. The method used is that of B.K.P. Horn. See: https://people.csail.mit.edu/bkph/articles/Quaternions.pdf

See also
QuaternionToMatrix3x3() MultiplyQuaternion()
vtkQuaternion

Definition at line 2299 of file vtkMath.h.

◆ MultiplyQuaternion() [1/2]

static void vtkMath::MultiplyQuaternion ( const float  q1[4],
const float  q2[4],
float  q[4] 
)
static

Multiply two quaternions.

This is used to concatenate rotations. Quaternions are in the form [w, x, y, z].

See also
Matrix3x3ToQuaternion() QuaternionToMatrix3x3()
vtkQuaternion

◆ MultiplyQuaternion() [2/2]

static void vtkMath::MultiplyQuaternion ( const double  q1[4],
const double  q2[4],
double  q[4] 
)
static

Multiply two quaternions.

This is used to concatenate rotations. Quaternions are in the form [w, x, y, z].

See also
Matrix3x3ToQuaternion() QuaternionToMatrix3x3()
vtkQuaternion

◆ RotateVectorByNormalizedQuaternion() [1/2]

static void vtkMath::RotateVectorByNormalizedQuaternion ( const float  v[3],
const float  q[4],
float  r[3] 
)
static

rotate a vector by a normalized quaternion using // https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula

◆ RotateVectorByNormalizedQuaternion() [2/2]

static void vtkMath::RotateVectorByNormalizedQuaternion ( const double  v[3],
const double  q[4],
double  r[3] 
)
static

rotate a vector by a normalized quaternion using // https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula

◆ RotateVectorByWXYZ() [1/2]

static void vtkMath::RotateVectorByWXYZ ( const float  v[3],
const float  q[4],
float  r[3] 
)
static

◆ RotateVectorByWXYZ() [2/2]

static void vtkMath::RotateVectorByWXYZ ( const double  v[3],
const double  q[4],
double  r[3] 
)
static

◆ Orthogonalize3x3() [1/2]

static void vtkMath::Orthogonalize3x3 ( const float  A[3][3],
float  B[3][3] 
)
static

Orthogonalize a 3x3 matrix and put the result in B.

If matrix A has a negative determinant, then B will be a rotation plus a flip i.e. it will have a determinant of -1.

◆ Orthogonalize3x3() [2/2]

static void vtkMath::Orthogonalize3x3 ( const double  A[3][3],
double  B[3][3] 
)
static

Orthogonalize a 3x3 matrix and put the result in B.

If matrix A has a negative determinant, then B will be a rotation plus a flip i.e. it will have a determinant of -1.

◆ Diagonalize3x3() [1/2]

static void vtkMath::Diagonalize3x3 ( const float  A[3][3],
float  w[3],
float  V[3][3] 
)
static

Diagonalize a symmetric 3x3 matrix and return the eigenvalues in w and the eigenvectors in the columns of V.

The matrix V will have a positive determinant, and the three eigenvectors will be aligned as closely as possible with the x, y, and z axes.

◆ Diagonalize3x3() [2/2]

static void vtkMath::Diagonalize3x3 ( const double  A[3][3],
double  w[3],
double  V[3][3] 
)
static

Diagonalize a symmetric 3x3 matrix and return the eigenvalues in w and the eigenvectors in the columns of V.

The matrix V will have a positive determinant, and the three eigenvectors will be aligned as closely as possible with the x, y, and z axes.

◆ SingularValueDecomposition3x3() [1/2]

static void vtkMath::SingularValueDecomposition3x3 ( const float  A[3][3],
float  U[3][3],
float  w[3],
float  VT[3][3] 
)
static

Perform singular value decomposition on a 3x3 matrix.

This is not done using a conventional SVD algorithm, instead it is done using Orthogonalize3x3 and Diagonalize3x3. Both output matrices U and VT will have positive determinants, and the w values will be arranged such that the three rows of VT are aligned as closely as possible with the x, y, and z axes respectively. If the determinant of A is negative, then the three w values will be negative.

◆ SingularValueDecomposition3x3() [2/2]

static void vtkMath::SingularValueDecomposition3x3 ( const double  A[3][3],
double  U[3][3],
double  w[3],
double  VT[3][3] 
)
static

Perform singular value decomposition on a 3x3 matrix.

This is not done using a conventional SVD algorithm, instead it is done using Orthogonalize3x3 and Diagonalize3x3. Both output matrices U and VT will have positive determinants, and the w values will be arranged such that the three rows of VT are aligned as closely as possible with the x, y, and z axes respectively. If the determinant of A is negative, then the three w values will be negative.

◆ SolveLinearSystemGEPP2x2()

static vtkTypeBool vtkMath::SolveLinearSystemGEPP2x2 ( double  a00,
double  a01,
double  a10,
double  a11,
double  b0,
double  b1,
double &  x0,
double &  x1 
)
static

Solve linear equation Ax = b using Gaussian Elimination with Partial Pivoting for a 2x2 system.

If the matrix is found to be singular within a small numerical tolerance close to machine precision then 0 is returned. Note: Even if method succeeded the matrix A could be close to singular. The solution should be checked against relevant tolerance criteria.

◆ SolveLinearSystem()

static vtkTypeBool vtkMath::SolveLinearSystem ( double **  A,
double *  x,
int  size 
)
static

Solve linear equations Ax = b using Crout's method.

Input is square matrix A and load vector b. Solution x is written over load vector. The dimension of the matrix is specified in size. If error is found, method returns a 0. Note: Even if method succeeded the matrix A could be close to singular. The solution should be checked against relevant tolerance criteria.

◆ InvertMatrix() [2/3]

static vtkTypeBool vtkMath::InvertMatrix ( double **  A,
double **  AI,
int  size 
)
static

Invert input square matrix A into matrix AI.

Note that A is modified during the inversion. The size variable is the dimension of the matrix. Returns 0 if inverse not computed.

◆ InvertMatrix() [3/3]

static vtkTypeBool vtkMath::InvertMatrix ( double **  A,
double **  AI,
int  size,
int *  tmp1Size,
double *  tmp2Size 
)
static

Thread safe version of InvertMatrix method.

Working memory arrays tmp1SIze and tmp2Size of length size must be passed in.

◆ LUFactorLinearSystem() [1/2]

static vtkTypeBool vtkMath::LUFactorLinearSystem ( double **  A,
int *  index,
int  size 
)
static

Factor linear equations Ax = b using LU decomposition into the form A = LU where L is a unit lower triangular matrix and U is upper triangular matrix.

The input is a square matrix A, an integer array of pivot indices index[0->n-1], and the size, n, of the square matrix. The output is provided by overwriting the input A with a matrix of the same size as A containing all of the information about L and U. If the output matrix is \( A* = \left( \begin{array}{cc} a & b \\ c & d \end{array} \right)\) then L and U can be obtained as: \( L = \left( \begin{array}{cc} 1 & 0 \\ c & 1 \end{array} \right)\) \( U = \left( \begin{array}{cc} a & b \\ 0 & d \end{array} \right)\)

That is, the diagonal of the resulting A* is the diagonal of U. The upper right triangle of A is the upper right triangle of U. The lower left triangle of A is the lower left triangle of L (and since L is unit lower triangular, the diagonal of L is all 1's). If an error is found, the function returns 0.

◆ LUFactorLinearSystem() [2/2]

static vtkTypeBool vtkMath::LUFactorLinearSystem ( double **  A,
int *  index,
int  size,
double *  tmpSize 
)
static

Thread safe version of LUFactorLinearSystem method.

Working memory array tmpSize of length size must be passed in.

◆ LUSolveLinearSystem()

static void vtkMath::LUSolveLinearSystem ( double **  A,
int *  index,
double *  x,
int  size 
)
static

Solve linear equations Ax = b using LU decomposition A = LU where L is lower triangular matrix and U is upper triangular matrix.

Input is factored matrix A=LU, integer array of pivot indices index[0->n-1], load vector x[0->n-1], and size of square matrix n. Note that A=LU and index[] are generated from method LUFactorLinearSystem). Also, solution vector is written directly over input load vector.

◆ EstimateMatrixCondition()

static double vtkMath::EstimateMatrixCondition ( const double *const *  A,
int  size 
)
static

Estimate the condition number of a LU factored matrix.

Used to judge the accuracy of the solution. The matrix A must have been previously factored using the method LUFactorLinearSystem. The condition number is the ratio of the infinity matrix norm (i.e., maximum value of matrix component) divided by the minimum diagonal value. (This works for triangular matrices only: see Conte and de Boor, Elementary Numerical Analysis.)

◆ Jacobi() [1/2]

static vtkTypeBool vtkMath::Jacobi ( float **  a,
float *  w,
float **  v 
)
static

Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix.

Square 3x3 matrix a; output eigenvalues in w; and output eigenvectors in v arranged column-wise. Resulting eigenvalues/vectors are sorted in decreasing order; the most positive eigenvectors are selected for consistency; eigenvectors are normalized. NOTE: the input matrix a is modified during the solution

◆ Jacobi() [2/2]

static vtkTypeBool vtkMath::Jacobi ( double **  a,
double *  w,
double **  v 
)
static

Jacobi iteration for the solution of eigenvectors/eigenvalues of a 3x3 real symmetric matrix.

Square 3x3 matrix a; output eigenvalues in w; and output eigenvectors in v arranged column-wise. Resulting eigenvalues/vectors are sorted in decreasing order; the most positive eigenvectors are selected for consistency; eigenvectors are normalized. NOTE: the input matrix a is modified during the solution

◆ JacobiN() [1/2]

static vtkTypeBool vtkMath::JacobiN ( float **  a,
int  n,
float *  w,
float **  v 
)
static

JacobiN iteration for the solution of eigenvectors/eigenvalues of a nxn real symmetric matrix.

Square nxn matrix a; size of matrix in n; output eigenvalues in w; and output eigenvectors in v arranged column-wise. Resulting eigenvalues/vectors are sorted in decreasing order; the most positive eigenvectors are selected for consistency; and eigenvectors are normalized. w and v need to be allocated previously. NOTE: the input matrix a is modified during the solution

◆ JacobiN() [2/2]

static vtkTypeBool vtkMath::JacobiN ( double **  a,
int  n,
double *  w,
double **  v 
)
static

JacobiN iteration for the solution of eigenvectors/eigenvalues of a nxn real symmetric matrix.

Square nxn matrix a; size of matrix in n; output eigenvalues in w; and output eigenvectors in v arranged column-wise. Resulting eigenvalues/vectors are sorted in decreasing order; the most positive eigenvectors are selected for consistency; and eigenvectors are normalized. w and v need to be allocated previously. NOTE: the input matrix a is modified during the solution

◆ SolveHomogeneousLeastSquares()

static vtkTypeBool vtkMath::SolveHomogeneousLeastSquares ( int  numberOfSamples,
double **  xt,
int  xOrder,
double **  mt 
)
static

Solves for the least squares best fit matrix for the homogeneous equation X'M' = 0'.

Uses the method described on pages 40-41 of Computer Vision by Forsyth and Ponce, which is that the solution is the eigenvector associated with the minimum eigenvalue of T(X)X, where T(X) is the transpose of X. The inputs and output are transposed matrices. Dimensions: X' is numberOfSamples by xOrder, M' dimension is xOrder by yOrder. M' should be pre-allocated. All matrices are row major. The resultant matrix M' should be pre-multiplied to X' to get 0', or transposed and then post multiplied to X to get 0

◆ SolveLeastSquares()

static vtkTypeBool vtkMath::SolveLeastSquares ( int  numberOfSamples,
double **  xt,
int  xOrder,
double **  yt,
int  yOrder,
double **  mt,
int  checkHomogeneous = 1 
)
static

Solves for the least squares best fit matrix for the equation X'M' = Y'.

Uses pseudoinverse to get the ordinary least squares. The inputs and output are transposed matrices. Dimensions: X' is numberOfSamples by xOrder, Y' is numberOfSamples by yOrder, M' dimension is xOrder by yOrder. M' should be pre-allocated. All matrices are row major. The resultant matrix M' should be pre-multiplied to X' to get Y', or transposed and then post multiplied to X to get Y By default, this method checks for the homogeneous condition where Y==0, and if so, invokes SolveHomogeneousLeastSquares. For better performance when the system is known not to be homogeneous, invoke with checkHomogeneous=0.

◆ RGBToHSV() [1/4]

static void vtkMath::RGBToHSV ( const float  rgb[3],
float  hsv[3] 
)
inlinestatic

Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).

The input color is not modified. The input RGB must be float values in the range [0, 1]. The output ranges are hue [0, 1], saturation [0, 1], and value [0, 1].

Definition at line 1458 of file vtkMath.h.

◆ RGBToHSV() [2/4]

static void vtkMath::RGBToHSV ( float  r,
float  g,
float  b,
float *  h,
float *  s,
float *  v 
)
static

Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).

The input color is not modified. The input RGB must be float values in the range [0, 1]. The output ranges are hue [0, 1], saturation [0, 1], and value [0, 1].

◆ RGBToHSV() [3/4]

static void vtkMath::RGBToHSV ( const double  rgb[3],
double  hsv[3] 
)
inlinestatic

Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).

The input color is not modified. The input RGB must be float values in the range [0, 1]. The output ranges are hue [0, 1], saturation [0, 1], and value [0, 1].

Definition at line 1463 of file vtkMath.h.

◆ RGBToHSV() [4/4]

static void vtkMath::RGBToHSV ( double  r,
double  g,
double  b,
double *  h,
double *  s,
double *  v 
)
static

Convert color in RGB format (Red, Green, Blue) to HSV format (Hue, Saturation, Value).

The input color is not modified. The input RGB must be float values in the range [0, 1]. The output ranges are hue [0, 1], saturation [0, 1], and value [0, 1].

◆ HSVToRGB() [1/4]

static void vtkMath::HSVToRGB ( const float  hsv[3],
float  rgb[3] 
)
inlinestatic

Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).

The input color is not modified. The input 'hsv' must be float values in the range [0, 1]. The elements of each component of the output 'rgb' are in the range [0, 1].

Definition at line 1478 of file vtkMath.h.

◆ HSVToRGB() [2/4]

static void vtkMath::HSVToRGB ( float  h,
float  s,
float  v,
float *  r,
float *  g,
float *  b 
)
static

Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).

The input color is not modified. The input 'hsv' must be float values in the range [0, 1]. The elements of each component of the output 'rgb' are in the range [0, 1].

◆ HSVToRGB() [3/4]

static void vtkMath::HSVToRGB ( const double  hsv[3],
double  rgb[3] 
)
inlinestatic

Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).

The input color is not modified. The input 'hsv' must be float values in the range [0, 1]. The elements of each component of the output 'rgb' are in the range [0, 1].

Definition at line 1483 of file vtkMath.h.

◆ HSVToRGB() [4/4]

static void vtkMath::HSVToRGB ( double  h,
double  s,
double  v,
double *  r,
double *  g,
double *  b 
)
static

Convert color in HSV format (Hue, Saturation, Value) to RGB format (Red, Green, Blue).

The input color is not modified. The input 'hsv' must be float values in the range [0, 1]. The elements of each component of the output 'rgb' are in the range [0, 1].

◆ LabToXYZ() [1/2]

static void vtkMath::LabToXYZ ( const double  lab[3],
double  xyz[3] 
)
inlinestatic

Convert color from the CIE-L*ab system to CIE XYZ.

Definition at line 1494 of file vtkMath.h.

◆ LabToXYZ() [2/2]

static void vtkMath::LabToXYZ ( double  L,
double  a,
double  b,
double *  x,
double *  y,
double *  z 
)
static

Convert color from the CIE-L*ab system to CIE XYZ.

◆ XYZToLab() [1/2]

static void vtkMath::XYZToLab ( const double  xyz[3],
double  lab[3] 
)
inlinestatic

Convert Color from the CIE XYZ system to CIE-L*ab.

Definition at line 1505 of file vtkMath.h.

◆ XYZToLab() [2/2]

static void vtkMath::XYZToLab ( double  x,
double  y,
double  z,
double *  L,
double *  a,
double *  b 
)
static

Convert Color from the CIE XYZ system to CIE-L*ab.

◆ XYZToRGB() [1/2]

static void vtkMath::XYZToRGB ( const double  xyz[3],
double  rgb[3] 
)
inlinestatic

Convert color from the CIE XYZ system to RGB.

Definition at line 1516 of file vtkMath.h.

◆ XYZToRGB() [2/2]

static void vtkMath::XYZToRGB ( double  x,
double  y,
double  z,
double *  r,
double *  g,
double *  b 
)
static

Convert color from the CIE XYZ system to RGB.

◆ RGBToXYZ() [1/2]

static void vtkMath::RGBToXYZ ( const double  rgb[3],
double  xyz[3] 
)
inlinestatic

Convert color from the RGB system to CIE XYZ.

Definition at line 1527 of file vtkMath.h.

◆ RGBToXYZ() [2/2]

static void vtkMath::RGBToXYZ ( double  r,
double  g,
double  b,
double *  x,
double *  y,
double *  z 
)
static

Convert color from the RGB system to CIE XYZ.

◆ RGBToLab() [1/2]

static void vtkMath::RGBToLab ( const double  rgb[3],
double  lab[3] 
)
inlinestatic

Convert color from the RGB system to CIE-L*ab.

The input RGB must be values in the range [0, 1]. The output ranges of 'L' is [0, 100]. The output range of 'a' and 'b' are approximately [-110, 110].

Definition at line 1541 of file vtkMath.h.

◆ RGBToLab() [2/2]

static void vtkMath::RGBToLab ( double  red,
double  green,
double  blue,
double *  L,
double *  a,
double *  b 
)
static

Convert color from the RGB system to CIE-L*ab.

The input RGB must be values in the range [0, 1]. The output ranges of 'L' is [0, 100]. The output range of 'a' and 'b' are approximately [-110, 110].

◆ LabToRGB() [1/2]

static void vtkMath::LabToRGB ( const double  lab[3],
double  rgb[3] 
)
inlinestatic

Convert color from the CIE-L*ab system to RGB.

Definition at line 1552 of file vtkMath.h.

◆ LabToRGB() [2/2]

static void vtkMath::LabToRGB ( double  L,
double  a,
double  b,
double *  red,
double *  green,
double *  blue 
)
static

Convert color from the CIE-L*ab system to RGB.

◆ UninitializeBounds()

static void vtkMath::UninitializeBounds ( double  bounds[6])
inlinestatic

Set the bounds to an uninitialized state.

Definition at line 1563 of file vtkMath.h.

◆ AreBoundsInitialized()

static vtkTypeBool vtkMath::AreBoundsInitialized ( const double  bounds[6])
inlinestatic

Are the bounds initialized?

Definition at line 1578 of file vtkMath.h.

◆ ClampValue() [1/3]

template<class T >
T vtkMath::ClampValue ( const T &  value,
const T &  min,
const T &  max 
)
inlinestatic

Clamp some value against a range, return the result.

min must be less than or equal to max. Semantics the same as std::clamp.

Definition at line 2069 of file vtkMath.h.

◆ ClampValue() [2/3]

void vtkMath::ClampValue ( double *  value,
const double  range[2] 
)
inlinestatic

Clamp some values against a range The method without 'clamped_values' will perform in-place clamping.

Definition at line 2084 of file vtkMath.h.

◆ ClampValue() [3/3]

void vtkMath::ClampValue ( double  value,
const double  range[2],
double *  clamped_value 
)
inlinestatic

Clamp some values against a range The method without 'clamped_values' will perform in-place clamping.

Definition at line 2095 of file vtkMath.h.

◆ ClampValues() [1/2]

static void vtkMath::ClampValues ( double *  values,
int  nb_values,
const double  range[2] 
)
static

Clamp some values against a range The method without 'clamped_values' will perform in-place clamping.

◆ ClampValues() [2/2]

static void vtkMath::ClampValues ( const double *  values,
int  nb_values,
const double  range[2],
double *  clamped_values 
)
static

Clamp some values against a range The method without 'clamped_values' will perform in-place clamping.

◆ ClampAndNormalizeValue()

double vtkMath::ClampAndNormalizeValue ( double  value,
const double  range[2] 
)
inlinestatic

Clamp a value against a range and then normalize it between 0 and 1.

If range[0]==range[1], the result is 0.

Precondition
valid_range: range[0]<=range[1]
Postcondition
valid_result: result>=0.0 && result<=1.0

Definition at line 2106 of file vtkMath.h.

◆ TensorFromSymmetricTensor() [1/3]

template<class T1 , class T2 >
static void vtkMath::TensorFromSymmetricTensor ( const T1  symmTensor[6],
T2  tensor[9] 
)
static

Convert a 6-Component symmetric tensor into a 9-Component tensor, no allocation performed.

Symmetric tensor is expected to have the following order : XX, YY, ZZ, XY, YZ, XZ

◆ TensorFromSymmetricTensor() [2/3]

template<class T >
void vtkMath::TensorFromSymmetricTensor ( tensor[9])
inlinestatic

Convert a 6-Component symmetric tensor into a 9-Component tensor, overwriting the tensor input.

Symmetric tensor is expected to have the following order : XX, YY, ZZ, XY, YZ, XZ

Definition at line 2144 of file vtkMath.h.

◆ GetScalarTypeFittingRange()

static int vtkMath::GetScalarTypeFittingRange ( double  range_min,
double  range_max,
double  scale = 1.0,
double  shift = 0.0 
)
static

Return the scalar type that is most likely to have enough precision to store a given range of data once it has been scaled and shifted (i.e.

[range_min * scale + shift, range_max * scale + shift]. If any one of the parameters is not an integer number (decimal part != 0), the search will default to float types only (float or double) Return -1 on error or no scalar type found.

◆ GetAdjustedScalarRange()

static vtkTypeBool vtkMath::GetAdjustedScalarRange ( vtkDataArray array,
int  comp,
double  range[2] 
)
static

Get a vtkDataArray's scalar range for a given component.

If the vtkDataArray's data type is unsigned char (VTK_UNSIGNED_CHAR) the range is adjusted to the whole data type range [0, 255.0]. Same goes for unsigned short (VTK_UNSIGNED_SHORT) but the upper bound is also adjusted down to 4095.0 if was between ]255, 4095.0]. Return 1 on success, 0 otherwise.

◆ ExtentIsWithinOtherExtent()

static vtkTypeBool vtkMath::ExtentIsWithinOtherExtent ( const int  extent1[6],
const int  extent2[6] 
)
static

Return true if first 3D extent is within second 3D extent Extent is x-min, x-max, y-min, y-max, z-min, z-max.

◆ BoundsIsWithinOtherBounds()

static vtkTypeBool vtkMath::BoundsIsWithinOtherBounds ( const double  bounds1[6],
const double  bounds2[6],
const double  delta[3] 
)
static

Return true if first 3D bounds is within the second 3D bounds Bounds is x-min, x-max, y-min, y-max, z-min, z-max Delta is the error margin along each axis (usually a small number)

◆ PointIsWithinBounds()

static vtkTypeBool vtkMath::PointIsWithinBounds ( const double  point[3],
const double  bounds[6],
const double  delta[3] 
)
static

Return true if point is within the given 3D bounds Bounds is x-min, x-max, y-min, y-max, z-min, z-max Delta is the error margin along each axis (usually a small number)

◆ PlaneIntersectsAABB()

static int vtkMath::PlaneIntersectsAABB ( const double  bounds[6],
const double  normal[3],
const double  point[3] 
)
static

Implements Plane / Axis-Aligned Bounding-Box intersection as described in Graphics Gems IV, Ned Greene; pp.

75-76. Variable names are based on the description in the book. This function returns +1 if the box lies fully in the positive side of the plane (by convention, the side to which the plane's normal points to), -1 if the box fully lies in the negative side and 0 if the plane intersects the box. -2 is returned if any of the arguments is invalid.

◆ Solve3PointCircle()

static double vtkMath::Solve3PointCircle ( const double  p1[3],
const double  p2[3],
const double  p3[3],
double  center[3] 
)
static

In Euclidean space, there is a unique circle passing through any given three non-collinear points P1, P2, and P3.

Using Cartesian coordinates to represent these points as spatial vectors, it is possible to use the dot product and cross product to calculate the radius and center of the circle. See: http://en.wikipedia.org/wiki/Circumscribed_circle and more specifically the section Barycentric coordinates from cross- and dot-products

◆ Inf()

static double vtkMath::Inf ( )
static

Special IEEE-754 number used to represent positive infinity.

◆ NegInf()

static double vtkMath::NegInf ( )
static

Special IEEE-754 number used to represent negative infinity.

◆ Nan()

static double vtkMath::Nan ( )
static

Special IEEE-754 number used to represent Not-A-Number (Nan).

◆ IsInf()

static vtkTypeBool vtkMath::IsInf ( double  x)
static

Test if a number is equal to the special floating point value infinity.

◆ IsNan()

static vtkTypeBool vtkMath::IsNan ( double  x)
static

Test if a number is equal to the special floating point value Not-A-Number (Nan).

◆ IsFinite()

static bool vtkMath::IsFinite ( double  x)
static

Test if a number has finite value i.e.

it is normal, subnormal or zero, but not infinite or Nan.

◆ QuadraticRoot()

static int vtkMath::QuadraticRoot ( double  a,
double  b,
double  c,
double  min,
double  max,
double *  u 
)
static

find roots of ax^2+bx+c=0 in the interval min,max.

place the roots in u[2] and return how many roots found

◆ ComputeGCD()

static vtkIdType vtkMath::ComputeGCD ( vtkIdType  m,
vtkIdType  n 
)
inlinestatic

Compute the greatest common divisor (GCD) of two positive integers m and n.

If the computed GCD==1, then the two integers are coprime to one another. This is a simple, recursive implementation.

Definition at line 1739 of file vtkMath.h.

◆ Convolve1D()

template<class Iter1 , class Iter2 , class Iter3 >
static void vtkMath::Convolve1D ( Iter1  beginSample,
Iter1  endSample,
Iter2  beginKernel,
Iter2  endKernel,
Iter3  beginOut,
Iter3  endOut,
ConvolutionMode  mode = ConvolutionMode::FULL 
)
inlinestatic

Compute the convolution of a sampled 1D signal by a given kernel.

There are 3 different modes available:

The "full" mode (default), returning the convolution at each point of overlap between the sample and the kernel. The output size is equal to sampleSize + kernelSize + 1.

The "same" mode, where the convolution is computed only if the center of the kernel overlaps with the sample. The output size is equal to the sampleSize.

The "valid" mode, where the convolution is computed only if the kernel overlaps completely with the sample. The output size is equal to the sampleSize - kernelSize + 1.

Note
By convention, here the kernel refers to the smallest input signal of the two, but it doesn't matter if it's passed as the first or the second parameter (the convolution is commutative).
The function does nothing if iteratorBegin >= iteratorEnd (for each couple of iterators)
The output signal is padded with zeros if its size (endOut - beginOut) is bigger than the number of generated values. If its size is smaller, the result is truncated from the end.

Definition at line 1774 of file vtkMath.h.

◆ GetPointAlongLine()

static void vtkMath::GetPointAlongLine ( double  result[3],
double  p1[3],
double  p2[3],
const double  offset 
)
inlinestatic

Get the coordinates of a point along a line defined by p1 and p2, at a specified offset relative to p2.

Definition at line 1819 of file vtkMath.h.

◆ TensorFromSymmetricTensor() [3/3]

template<class T1 , class T2 >
void vtkMath::TensorFromSymmetricTensor ( const T1  symmTensor[9],
T2  tensor[9] 
)
inline

Definition at line 2131 of file vtkMath.h.

Member Data Documentation

◆ Internal

vtkSmartPointer<vtkMathInternal> vtkMath::Internal
staticprotected

Definition at line 1832 of file vtkMath.h.


The documentation for this class was generated from the following file: