### Merge topic 'vtkmath-args'

```97ec3aa2

vtkMath: don't use x/y/z as argument names to avoid ambiguity
Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Cory Quammen <cory.quammen@kitware.com>
Merge-request: !1508```
parents 053336b9 97ec3aa2
 ... ... @@ -280,36 +280,36 @@ void vtkMath::FreeCombination( int* r ) } //---------------------------------------------------------------------------- // Given a unit vector 'x', find two other unit vectors 'y' and 'z' which // Given a unit vector v1, find two other unit vectors v2 and v3 which // which form an orthonormal set. template inline void vtkMathPerpendiculars(const T1 x, T2 y, T3 z, inline void vtkMathPerpendiculars(const T1 v1, T2 v2, T3 v3, double theta) { int dx,dy,dz; int dv1,dv2,dv3; double x2 = x*x; double y2 = x*x; double z2 = x*x; double r = sqrt(x2 + y2 + z2); double v1sq = v1*v1; double v2sq = v1*v1; double v3sq = v1*v1; double r = sqrt(v1sq + v2sq + v3sq); // transpose the vector to avoid divide-by-zero error if (x2 > y2 && x2 > z2) if (v1sq > v2sq && v1sq > v3sq) { dx = 0; dy = 1; dz = 2; dv1 = 0; dv2 = 1; dv3 = 2; } else if (y2 > z2) else if (v2sq > v3sq) { dx = 1; dy = 2; dz = 0; dv1 = 1; dv2 = 2; dv3 = 0; } else { dx = 2; dy = 0; dz = 1; dv1 = 2; dv2 = 0; dv3 = 1; } double a = x[dx]/r; double b = x[dy]/r; double c = x[dz]/r; double a = v1[dv1]/r; double b = v1[dv2]/r; double c = v1[dv3]/r; double tmp = sqrt(a*a+c*c); ... ... @@ -318,48 +318,48 @@ inline void vtkMathPerpendiculars(const T1 x, T2 y, T3 z, double sintheta = sin(theta); double costheta = cos(theta); if (y) if (v2) { y[dx] = (c*costheta - a*b*sintheta)/tmp; y[dy] = sintheta*tmp; y[dz] = (-a*costheta - b*c*sintheta)/tmp; v2[dv1] = (c*costheta - a*b*sintheta)/tmp; v2[dv2] = sintheta*tmp; v2[dv3] = (-a*costheta - b*c*sintheta)/tmp; } if (z) if (v3) { z[dx] = (-c*sintheta - a*b*costheta)/tmp; z[dy] = costheta*tmp; z[dz] = (a*sintheta - b*c*costheta)/tmp; v3[dv1] = (-c*sintheta - a*b*costheta)/tmp; v3[dv2] = costheta*tmp; v3[dv3] = (a*sintheta - b*c*costheta)/tmp; } } else { if (y) if (v2) { y[dx] = c/tmp; y[dy] = 0; y[dz] = -a/tmp; v2[dv1] = c/tmp; v2[dv2] = 0; v2[dv3] = -a/tmp; } if (z) if (v3) { z[dx] = -a*b/tmp; z[dy] = tmp; z[dz] = -b*c/tmp; v3[dv1] = -a*b/tmp; v3[dv2] = tmp; v3[dv3] = -b*c/tmp; } } } void vtkMath::Perpendiculars(const double x, double y, double z, void vtkMath::Perpendiculars(const double v1, double v2, double v3, double theta) { vtkMathPerpendiculars(x, y, z, theta); vtkMathPerpendiculars(v1, v2, v3, theta); } void vtkMath::Perpendiculars(const float x, float y, float z, void vtkMath::Perpendiculars(const float v1, float v2, float v3, double theta) { vtkMathPerpendiculars(x, y, z, theta); vtkMathPerpendiculars(v1, v2, v3, theta); } #define VTK_SMALL_NUMBER 1.0e-12 ... ...
 ... ... @@ -334,37 +334,37 @@ public: // Description: // Dot product of two 3-vectors (float version). static float Dot(const float x, const float y) { return ( x * y + x * y + x * y );}; static float Dot(const float a, const float b) { return ( a * b + a * b + a * b );}; // Description: // Dot product of two 3-vectors (double-precision version). static double Dot(const double x, const double y) { return ( x * y + x * y + x * y );}; static double Dot(const double a, const double b) { return ( a * b + a * b + a * b );}; // Description: // Outer product of two 3-vectors (float version). static void Outer(const float x, const float y, float A) { static void Outer(const float a, const float b, float C) { for (int i=0; i < 3; i++) for (int j=0; j < 3; j++) A[i][j] = x[i] * y[j]; C[i][j] = a[i] * b[j]; } // Description: // Outer product of two 3-vectors (double-precision version). static void Outer(const double x, const double y, double A) { static void Outer(const double a, const double b, double C) { for (int i=0; i < 3; i++) for (int j=0; j < 3; j++) A[i][j] = x[i] * y[j]; C[i][j] = a[i] * b[j]; } // Description: // Cross product of two 3-vectors. Result (a x b) is stored in z. static void Cross(const float x, const float y, float z); // Cross product of two 3-vectors. Result (a x b) is stored in c. static void Cross(const float a, const float b, float c); // Description: // Cross product of two 3-vectors. Result (a x b) is stored in z. (double-precision // version) static void Cross(const double x, const double y, double z); // Cross product of two 3-vectors. Result (a x b) is stored in c. // (double-precision version) static void Cross(const double a, const double b, double c); // Description: // Compute the norm of n-vector. x is the vector, n is its length. ... ... @@ -373,32 +373,32 @@ public: // Description: // Compute the norm of 3-vector. static float Norm(const float x) { return static_cast (sqrt( x * x + x * x + x * x ) );}; static float Norm(const float v) { return static_cast (sqrt( v * v + v * v + v * v ) );}; // Description: // Compute the norm of 3-vector (double-precision version). static double Norm(const double x) { return sqrt( x * x + x * x + x * x );}; static double Norm(const double v) { return sqrt( v * v + v * v + v * v );}; // Description: // Normalize (in place) a 3-vector. Returns norm of vector. static float Normalize(float x); static float Normalize(float v); // Description: // Normalize (in place) a 3-vector. Returns norm of vector // (double-precision version). static double Normalize(double x); static double Normalize(double v); // Description: // Given a unit vector x, find two unit vectors y and z such that // x cross y = z (i.e. the vectors are perpendicular to each other). // 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 NULL for z. static void Perpendiculars(const double x, double y, double z, // specify NULL for v3. static void Perpendiculars(const double v1, double v2, double v3, double theta); static void Perpendiculars(const float x, float y, float z, static void Perpendiculars(const float v1, float v2, float v3, double theta); // Description: ... ... @@ -409,7 +409,7 @@ public: static bool ProjectVector(const double a, const double b, double projection); // Description: // Compute the projection of 2D vector 'a' on 2D vector 'b' and returns the result // Compute the projection of 2D vector a on 2D vector b and returns the result // in projection. // If b is a zero vector, the function returns false and 'projection' is invalid. // Otherwise, it returns true. ... ... @@ -417,12 +417,13 @@ public: static bool ProjectVector2D(const double a, const double b, double projection); // Description: // Compute distance squared between two points x and y. static float Distance2BetweenPoints(const float x, const float y); // Compute distance squared between two points p1 and p2. static float Distance2BetweenPoints(const float p1, const float p2); // Description: // Compute distance squared between two points x and y(double precision version). static double Distance2BetweenPoints(const double x, const double y); // Compute distance squared between two points p1 and p2 // (double precision version). static double Distance2BetweenPoints(const double p1, const double p2); // Description: // Compute angle in radians between two vectors. ... ... @@ -498,12 +499,12 @@ public: // Description: // Normalize (in place) a 2-vector. Returns norm of vector. static float Normalize2D(float x); static float Normalize2D(float v); // Description: // Normalize (in place) a 2-vector. Returns norm of vector. // (double-precision version). static double Normalize2D(double x); static double Normalize2D(double v); // Description: // Compute determinant of 2x2 matrix. Two columns of matrix are input. ... ... @@ -1071,56 +1072,56 @@ inline T vtkMath::Max(const T & a, const T & b) } //---------------------------------------------------------------------------- inline float vtkMath::Normalize(float x) inline float vtkMath::Normalize(float v) { float den = vtkMath::Norm( x ); float den = vtkMath::Norm( v ); if ( den != 0.0 ) { for (int i=0; i < 3; i++) { x[i] /= den; v[i] /= den; } } return den; } //---------------------------------------------------------------------------- inline double vtkMath::Normalize(double x) inline double vtkMath::Normalize(double v) { double den = vtkMath::Norm( x ); double den = vtkMath::Norm( v ); if ( den != 0.0 ) { for (int i=0; i < 3; i++) { x[i] /= den; v[i] /= den; } } return den; } //---------------------------------------------------------------------------- inline float vtkMath::Normalize2D(float x) inline float vtkMath::Normalize2D(float v) { float den = vtkMath::Norm2D( x ); float den = vtkMath::Norm2D( v ); if ( den != 0.0 ) { for (int i=0; i < 2; i++) { x[i] /= den; v[i] /= den; } } return den; } //---------------------------------------------------------------------------- inline double vtkMath::Normalize2D(double x) inline double vtkMath::Normalize2D(double v) { double den = vtkMath::Norm2D( x ); double den = vtkMath::Norm2D( v ); if ( den != 0.0 ) { for (int i=0; i < 2; i++) { x[i] /= den; v[i] /= den; } } return den; ... ... @@ -1155,41 +1156,41 @@ inline double vtkMath::Determinant3x3(double a1, double a2, double a3, } //---------------------------------------------------------------------------- inline float vtkMath::Distance2BetweenPoints(const float x, const float y) inline float vtkMath::Distance2BetweenPoints(const float p1, const float p2) { return ( ( x - y ) * ( x - y ) + ( x - y ) * ( x - y ) + ( x - y ) * ( x - y ) ); return ( ( p1 - p2 ) * ( p1 - p2 ) + ( p1 - p2 ) * ( p1 - p2 ) + ( p1 - p2 ) * ( p1 - p2 ) ); } //---------------------------------------------------------------------------- inline double vtkMath::Distance2BetweenPoints(const double x, const double y) inline double vtkMath::Distance2BetweenPoints(const double p1, const double p2) { return ( ( x - y ) * ( x - y ) + ( x - y ) * ( x - y ) + ( x - y ) * ( x - y ) ); return ( ( p1 - p2 ) * ( p1 - p2 ) + ( p1 - p2 ) * ( p1 - p2 ) + ( p1 - p2 ) * ( p1 - p2 ) ); } //---------------------------------------------------------------------------- // Cross product of two 3-vectors. Result (a x b) is stored in z. inline void vtkMath::Cross(const float x, const float y, float z) // Cross product of two 3-vectors. Result (a x b) is stored in c. inline void vtkMath::Cross(const float a, const float b, float c) { float Zx = x * y - x * y; float Zy = x * y - x * y; float Zz = x * y - x * y; z = Zx; z = Zy; z = Zz; float Cx = a * b - a * b; float Cy = a * b - a * b; float Cz = a * b - a * b; c = Cx; c = Cy; c = Cz; } //---------------------------------------------------------------------------- // Cross product of two 3-vectors. Result (a x b) is stored in z. inline void vtkMath::Cross(const double x, const double y, double z) // Cross product of two 3-vectors. Result (a x b) is stored in c. inline void vtkMath::Cross(const double a, const double b, double c) { double Zx = x * y - x * y; double Zy = x * y - x * y; double Zz = x * y - x * y; z = Zx; z = Zy; z = Zz; double Cx = a * b - a * b; double Cy = a * b - a * b; double Cz = a * b - a * b; c = Cx; c = Cy; c = Cz; } //---------------------------------------------------------------------------- ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!