Base: fix many lint warnings in Matrix class
This commit is contained in:
@@ -63,9 +63,9 @@ Matrix4D::Matrix4D (double a11, double a12, double a13, double a14,
|
||||
{
|
||||
}
|
||||
|
||||
Matrix4D::Matrix4D (const Matrix4D& rclMtrx) : Matrix4D()
|
||||
Matrix4D::Matrix4D (const Matrix4D& mat) : Matrix4D()
|
||||
{
|
||||
(*this) = rclMtrx;
|
||||
(*this) = mat;
|
||||
}
|
||||
|
||||
Matrix4D::Matrix4D (const Vector3f& rclBase, const Vector3f& rclDir, float fAngle)
|
||||
@@ -148,47 +148,48 @@ double Matrix4D::determinant() const
|
||||
|
||||
double Matrix4D::determinant3() const
|
||||
{
|
||||
double a = dMtrx4D[0][0] * dMtrx4D[1][1] * dMtrx4D[2][2];
|
||||
double b = dMtrx4D[0][1] * dMtrx4D[1][2] * dMtrx4D[2][0];
|
||||
double c = dMtrx4D[1][0] * dMtrx4D[2][1] * dMtrx4D[0][2];
|
||||
double d = dMtrx4D[0][2] * dMtrx4D[1][1] * dMtrx4D[2][0];
|
||||
double e = dMtrx4D[1][0] * dMtrx4D[0][1] * dMtrx4D[2][2];
|
||||
double f = dMtrx4D[0][0] * dMtrx4D[2][1] * dMtrx4D[1][2];
|
||||
double det = (a + b + c) - (d + e + f);
|
||||
double va = dMtrx4D[0][0] * dMtrx4D[1][1] * dMtrx4D[2][2];
|
||||
double vb = dMtrx4D[0][1] * dMtrx4D[1][2] * dMtrx4D[2][0];
|
||||
double vc = dMtrx4D[1][0] * dMtrx4D[2][1] * dMtrx4D[0][2];
|
||||
double vd = dMtrx4D[0][2] * dMtrx4D[1][1] * dMtrx4D[2][0];
|
||||
double ve = dMtrx4D[1][0] * dMtrx4D[0][1] * dMtrx4D[2][2];
|
||||
double vf = dMtrx4D[0][0] * dMtrx4D[2][1] * dMtrx4D[1][2];
|
||||
double det = (va + vb + vc) - (vd + ve + vf);
|
||||
return det;
|
||||
}
|
||||
|
||||
void Matrix4D::move (const Vector3f& rclVct)
|
||||
void Matrix4D::move (const Vector3f& vec)
|
||||
{
|
||||
move(convertTo<Vector3d>(rclVct));
|
||||
move(convertTo<Vector3d>(vec));
|
||||
}
|
||||
|
||||
void Matrix4D::move (const Vector3d& rclVct)
|
||||
void Matrix4D::move (const Vector3d& vec)
|
||||
{
|
||||
dMtrx4D[0][3] += rclVct.x;
|
||||
dMtrx4D[1][3] += rclVct.y;
|
||||
dMtrx4D[2][3] += rclVct.z;
|
||||
dMtrx4D[0][3] += vec.x;
|
||||
dMtrx4D[1][3] += vec.y;
|
||||
dMtrx4D[2][3] += vec.z;
|
||||
}
|
||||
|
||||
void Matrix4D::scale (const Vector3f& rclVct)
|
||||
void Matrix4D::scale (const Vector3f& vec)
|
||||
{
|
||||
scale(convertTo<Vector3d>(rclVct));
|
||||
scale(convertTo<Vector3d>(vec));
|
||||
}
|
||||
|
||||
void Matrix4D::scale (const Vector3d& rclVct)
|
||||
void Matrix4D::scale (const Vector3d& vec)
|
||||
{
|
||||
Matrix4D clMat;
|
||||
|
||||
clMat.dMtrx4D[0][0] = rclVct.x;
|
||||
clMat.dMtrx4D[1][1] = rclVct.y;
|
||||
clMat.dMtrx4D[2][2] = rclVct.z;
|
||||
clMat.dMtrx4D[0][0] = vec.x;
|
||||
clMat.dMtrx4D[1][1] = vec.y;
|
||||
clMat.dMtrx4D[2][2] = vec.z;
|
||||
(*this) = clMat * (*this);
|
||||
}
|
||||
|
||||
void Matrix4D::rotX (double fAngle)
|
||||
{
|
||||
Matrix4D clMat;
|
||||
double fsin{}, fcos{};
|
||||
double fsin{};
|
||||
double fcos{};
|
||||
|
||||
fsin = sin (fAngle);
|
||||
fcos = cos (fAngle);
|
||||
@@ -201,7 +202,8 @@ void Matrix4D::rotX (double fAngle)
|
||||
void Matrix4D::rotY (double fAngle)
|
||||
{
|
||||
Matrix4D clMat;
|
||||
double fsin{}, fcos{};
|
||||
double fsin{};
|
||||
double fcos{};
|
||||
|
||||
fsin = sin (fAngle);
|
||||
fcos = cos (fAngle);
|
||||
@@ -214,7 +216,8 @@ void Matrix4D::rotY (double fAngle)
|
||||
void Matrix4D::rotZ (double fAngle)
|
||||
{
|
||||
Matrix4D clMat;
|
||||
double fsin{}, fcos{};
|
||||
double fsin{};
|
||||
double fcos{};
|
||||
|
||||
fsin = sin (fAngle);
|
||||
fcos = cos (fAngle);
|
||||
@@ -224,17 +227,20 @@ void Matrix4D::rotZ (double fAngle)
|
||||
(*this) = clMat * (*this);
|
||||
}
|
||||
|
||||
void Matrix4D::rotLine(const Vector3d& rclVct, double fAngle)
|
||||
void Matrix4D::rotLine(const Vector3d& vec, double fAngle)
|
||||
{
|
||||
// **** algorithm was taken from a math book
|
||||
Matrix4D clMA, clMB, clMC, clMRot;
|
||||
Vector3d clRotAxis(rclVct);
|
||||
short iz{}, is{};
|
||||
double fcos{}, fsin{};
|
||||
Matrix4D clMA;
|
||||
Matrix4D clMB;
|
||||
Matrix4D clMC;
|
||||
Matrix4D clMRot;
|
||||
Vector3d clRotAxis(vec);
|
||||
double fcos{};
|
||||
double fsin{};
|
||||
|
||||
// set all entries to "0"
|
||||
for (iz = 0; iz < 4; iz++) {
|
||||
for (is = 0; is < 4; is++) {
|
||||
for (short iz = 0; iz < 4; iz++) {
|
||||
for (short is = 0; is < 4; is++) {
|
||||
clMA.dMtrx4D[iz][is] = 0;
|
||||
clMB.dMtrx4D[iz][is] = 0;
|
||||
clMC.dMtrx4D[iz][is] = 0;
|
||||
@@ -269,8 +275,8 @@ void Matrix4D::rotLine(const Vector3d& rclVct, double fAngle)
|
||||
clMC.dMtrx4D[2][0] = -fsin * clRotAxis.y;
|
||||
clMC.dMtrx4D[2][1] = fsin * clRotAxis.x;
|
||||
|
||||
for (iz = 0; iz < 3; iz++) {
|
||||
for (is = 0; is < 3; is++)
|
||||
for (short iz = 0; iz < 3; iz++) {
|
||||
for (short is = 0; is < 3; is++)
|
||||
clMRot.dMtrx4D[iz][is] = clMA.dMtrx4D[iz][is] +
|
||||
clMB.dMtrx4D[iz][is] +
|
||||
clMC.dMtrx4D[iz][is];
|
||||
@@ -279,9 +285,9 @@ void Matrix4D::rotLine(const Vector3d& rclVct, double fAngle)
|
||||
(*this) = clMRot * (*this);
|
||||
}
|
||||
|
||||
void Matrix4D::rotLine(const Vector3f& rclVct, float fAngle)
|
||||
void Matrix4D::rotLine(const Vector3f& vec, float fAngle)
|
||||
{
|
||||
Vector3d tmp = convertTo<Vector3d>(rclVct);
|
||||
Vector3d tmp = convertTo<Vector3d>(vec);
|
||||
rotLine(tmp, static_cast<double>(fAngle));
|
||||
}
|
||||
|
||||
@@ -455,35 +461,38 @@ bool Matrix4D::toAxisAngle (Vector3d& rclBase, Vector3d& rclDir, double& rfAngle
|
||||
return true;
|
||||
}
|
||||
|
||||
void Matrix4D::transform (const Vector3f& rclVct, const Matrix4D& rclMtrx)
|
||||
void Matrix4D::transform (const Vector3f& vec, const Matrix4D& mat)
|
||||
{
|
||||
move(-rclVct);
|
||||
(*this) = rclMtrx * (*this);
|
||||
move(rclVct);
|
||||
move(-vec);
|
||||
(*this) = mat * (*this);
|
||||
move(vec);
|
||||
}
|
||||
|
||||
void Matrix4D::transform (const Vector3d& rclVct, const Matrix4D& rclMtrx)
|
||||
void Matrix4D::transform (const Vector3d& vec, const Matrix4D& mat)
|
||||
{
|
||||
move(-rclVct);
|
||||
(*this) = rclMtrx * (*this);
|
||||
move(rclVct);
|
||||
move(-vec);
|
||||
(*this) = mat * (*this);
|
||||
move(vec);
|
||||
}
|
||||
|
||||
void Matrix4D::inverse ()
|
||||
{
|
||||
Matrix4D clInvTrlMat, clInvRotMat;
|
||||
short iz{}, is{};
|
||||
Matrix4D clInvTrlMat;
|
||||
Matrix4D clInvRotMat;
|
||||
|
||||
/**** Herausnehmen und Inversion der TranslationsMatrix
|
||||
aus der TransformationMatrix ****/
|
||||
for (iz = 0 ;iz < 3; iz++)
|
||||
for (short iz = 0 ;iz < 3; iz++) {
|
||||
clInvTrlMat.dMtrx4D[iz][3] = -dMtrx4D[iz][3];
|
||||
}
|
||||
|
||||
/**** Herausnehmen und Inversion der RotationsMatrix
|
||||
aus der TransformationMatrix ****/
|
||||
for (iz = 0 ;iz < 3; iz++)
|
||||
for (is = 0 ;is < 3; is++)
|
||||
for (short iz = 0 ;iz < 3; iz++) {
|
||||
for (short is = 0 ;is < 3; is++) {
|
||||
clInvRotMat.dMtrx4D[iz][is] = dMtrx4D[is][iz];
|
||||
}
|
||||
}
|
||||
|
||||
/**** inv(M) = inv(Mtrl * Mrot) = inv(Mrot) * inv(Mtrl) ****/
|
||||
(*this) = clInvRotMat * clInvTrlMat;
|
||||
@@ -563,12 +572,12 @@ void Matrix_gauss(Matrix a, Matrix b)
|
||||
|
||||
void Matrix4D::inverseOrthogonal()
|
||||
{
|
||||
Base::Vector3d c(dMtrx4D[0][3],dMtrx4D[1][3],dMtrx4D[2][3]);
|
||||
Base::Vector3d vec(dMtrx4D[0][3],dMtrx4D[1][3],dMtrx4D[2][3]);
|
||||
transpose();
|
||||
c = this->operator * (c);
|
||||
dMtrx4D[0][3] = -c.x; dMtrx4D[3][0] = 0;
|
||||
dMtrx4D[1][3] = -c.y; dMtrx4D[3][1] = 0;
|
||||
dMtrx4D[2][3] = -c.z; dMtrx4D[3][2] = 0;
|
||||
vec = this->operator * (vec);
|
||||
dMtrx4D[0][3] = -vec.x; dMtrx4D[3][0] = 0;
|
||||
dMtrx4D[1][3] = -vec.y; dMtrx4D[3][1] = 0;
|
||||
dMtrx4D[2][3] = -vec.z; dMtrx4D[3][2] = 0;
|
||||
}
|
||||
|
||||
void Matrix4D::inverseGauss ()
|
||||
@@ -767,8 +776,9 @@ std::string Matrix4D::analyse() const
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hastranslation)
|
||||
if (hastranslation) {
|
||||
text += " with Translation";
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
@@ -831,20 +841,26 @@ Matrix4D& Matrix4D::Hat(const Vector3d& rV)
|
||||
|
||||
ScaleType Matrix4D::hasScale(double tol) const
|
||||
{
|
||||
const double defaultTolerance = 1e-9;
|
||||
// check for uniform scaling
|
||||
//
|
||||
// For a scaled rotation matrix it matters whether
|
||||
// the scaling was applied from the left or right side.
|
||||
// Only in case of uniform scaling it doesn't make a difference.
|
||||
if (tol == 0.0)
|
||||
tol = 1e-9;
|
||||
if (tol == 0.0) {
|
||||
tol = defaultTolerance;
|
||||
}
|
||||
|
||||
// check if the absolute values are proportionally close or equal
|
||||
auto closeAbs = [&](double a, double b) {
|
||||
double c = fabs(a);
|
||||
double d = fabs(b);
|
||||
if (d>c) return (d-c)/d <= tol;
|
||||
else if (c>d) return (c-d)/c <= tol;
|
||||
auto closeAbs = [&](double val_a, double val_b) {
|
||||
double abs_a = fabs(val_a);
|
||||
double abs_b = fabs(val_b);
|
||||
if (abs_b > abs_a) {
|
||||
return (abs_b - abs_a)/abs_b <= tol;
|
||||
}
|
||||
if (abs_a > abs_b) {
|
||||
return (abs_a-abs_b)/abs_a <= tol;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
double a31, double a32, double a33, double a34,
|
||||
double a41, double a42, double a43, double a44 );
|
||||
/// Construction
|
||||
Matrix4D (const Matrix4D& rclMtrx);
|
||||
Matrix4D (const Matrix4D& mat);
|
||||
/// Construction with an Axis
|
||||
Matrix4D (const Vector3f& rclBase, const Vector3f& rclDir, float fAngle);
|
||||
Matrix4D (const Vector3d& rclBase, const Vector3d& rclDir, double fAngle);
|
||||
@@ -77,28 +77,28 @@ public:
|
||||
/** @name Operators */
|
||||
//@{
|
||||
/// Matrix addition
|
||||
inline Matrix4D operator + (const Matrix4D& rclMtrx) const;
|
||||
inline Matrix4D& operator += (const Matrix4D& rclMtrx);
|
||||
inline Matrix4D operator + (const Matrix4D& mat) const;
|
||||
inline Matrix4D& operator += (const Matrix4D& mat);
|
||||
/// Matrix subtraction
|
||||
inline Matrix4D operator - (const Matrix4D& rclMtrx) const;
|
||||
inline Matrix4D& operator -= (const Matrix4D& rclMtrx);
|
||||
inline Matrix4D operator - (const Matrix4D& mat) const;
|
||||
inline Matrix4D& operator -= (const Matrix4D& mat);
|
||||
/// Matrix multiplication
|
||||
inline Matrix4D& operator *= (const Matrix4D& rclMtrx);
|
||||
inline Matrix4D& operator *= (const Matrix4D& mat);
|
||||
/// Assignment
|
||||
inline Matrix4D& operator = (const Matrix4D& rclMtrx);
|
||||
inline Matrix4D& operator = (const Matrix4D& mat);
|
||||
/// Matrix multiplication
|
||||
inline Matrix4D operator * (const Matrix4D& rclMtrx) const;
|
||||
inline Matrix4D operator * (const Matrix4D& mat) const;
|
||||
/// Multiplication matrix with vector
|
||||
inline Vector3f operator * (const Vector3f& rclVct) const;
|
||||
inline Vector3d operator * (const Vector3d& rclVct) const;
|
||||
inline Vector3f operator * (const Vector3f& vec) const;
|
||||
inline Vector3d operator * (const Vector3d& vec) const;
|
||||
inline void multVec(const Vector3d & src, Vector3d & dst) const;
|
||||
inline void multVec(const Vector3f & src, Vector3f & dst) const;
|
||||
inline Matrix4D operator * (double) const;
|
||||
inline Matrix4D& operator *= (double);
|
||||
/// Comparison
|
||||
inline bool operator != (const Matrix4D& rclMtrx) const;
|
||||
inline bool operator != (const Matrix4D& mat) const;
|
||||
/// Comparison
|
||||
inline bool operator == (const Matrix4D& rclMtrx) const;
|
||||
inline bool operator == (const Matrix4D& mat) const;
|
||||
/// Index operator
|
||||
inline double* operator [] (unsigned short usNdx);
|
||||
/// Index operator
|
||||
@@ -154,16 +154,16 @@ public:
|
||||
void move (double x, double y, double z)
|
||||
{ move(Vector3d(x,y,z)); }
|
||||
/// moves the coordinatesystem for the vector
|
||||
void move (const Vector3f& rclVct);
|
||||
void move (const Vector3d& rclVct);
|
||||
void move (const Vector3f& vec);
|
||||
void move (const Vector3d& vec);
|
||||
/// scale for the vector
|
||||
void scale (float x, float y, float z)
|
||||
{ scale(Vector3f(x,y,z)); }
|
||||
void scale (double x, double y, double z)
|
||||
{ scale(Vector3d(x,y,z)); }
|
||||
/// scale for the x,y,z value
|
||||
void scale (const Vector3f& rclVct);
|
||||
void scale (const Vector3d& rclVct);
|
||||
void scale (const Vector3f& vec);
|
||||
void scale (const Vector3d& vec);
|
||||
/// uniform scale
|
||||
void scale (float scalexyz)
|
||||
{ scale(Vector3f(scalexyz, scalexyz, scalexyz)); }
|
||||
@@ -178,9 +178,9 @@ public:
|
||||
/// Rotate around the Z axis (in transformed space) for the given value in radians
|
||||
void rotZ (double fAngle);
|
||||
/// Rotate around an arbitrary axis passing the origin in radians
|
||||
void rotLine (const Vector3f& rclVct, float fAngle);
|
||||
void rotLine (const Vector3f& vec, float fAngle);
|
||||
/// Rotate around an arbitrary axis passing the origin in radians
|
||||
void rotLine (const Vector3d& rclVct, double fAngle);
|
||||
void rotLine (const Vector3d& vec, double fAngle);
|
||||
/// Rotate around an arbitrary axis that needn't necessarily pass the origin in radians
|
||||
void rotLine (const Vector3f& rclBase, const Vector3f& rclDir, float fAngle);
|
||||
/// Rotate around an arbitrary axis that needn't necessarily pass the origin in radians
|
||||
@@ -189,8 +189,8 @@ public:
|
||||
bool toAxisAngle (Vector3f& rclBase, Vector3f& rclDir, float& fAngle, float& fTranslation) const;
|
||||
bool toAxisAngle (Vector3d& rclBase, Vector3d& rclDir, double& fAngle, double& fTranslation) const;
|
||||
/// transform (move,scale,rotate) around a point
|
||||
void transform (const Vector3f& rclVct, const Matrix4D& rclMtrx);
|
||||
void transform (const Vector3d& rclVct, const Matrix4D& rclMtrx);
|
||||
void transform (const Vector3f& vec, const Matrix4D& mat);
|
||||
void transform (const Vector3d& vec, const Matrix4D& mat);
|
||||
/// Matrix is expected to have a 3x3 rotation submatrix.
|
||||
void inverse ();
|
||||
/// Matrix is expected to have a 3x3 rotation submatrix.
|
||||
@@ -210,55 +210,55 @@ private:
|
||||
double dMtrx4D[4][4];
|
||||
};
|
||||
|
||||
inline Matrix4D Matrix4D::operator + (const Matrix4D& rclMtrx) const
|
||||
inline Matrix4D Matrix4D::operator + (const Matrix4D& mat) const
|
||||
{
|
||||
Matrix4D clMat;
|
||||
|
||||
for (int iz = 0; iz < 4; iz++) {
|
||||
for (int is = 0; is < 4; is++) {
|
||||
clMat.dMtrx4D[iz][is] = dMtrx4D[iz][is] + rclMtrx[iz][is];
|
||||
clMat.dMtrx4D[iz][is] = dMtrx4D[iz][is] + mat[iz][is];
|
||||
}
|
||||
}
|
||||
|
||||
return clMat;
|
||||
}
|
||||
|
||||
inline Matrix4D& Matrix4D::operator += (const Matrix4D& rclMtrx)
|
||||
inline Matrix4D& Matrix4D::operator += (const Matrix4D& mat)
|
||||
{
|
||||
for (int iz = 0; iz < 4; iz++) {
|
||||
for (int is = 0; is < 4; is++) {
|
||||
dMtrx4D[iz][is] += rclMtrx[iz][is];
|
||||
dMtrx4D[iz][is] += mat[iz][is];
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Matrix4D Matrix4D::operator - (const Matrix4D& rclMtrx) const
|
||||
inline Matrix4D Matrix4D::operator - (const Matrix4D& mat) const
|
||||
{
|
||||
Matrix4D clMat;
|
||||
|
||||
for (int iz = 0; iz < 4; iz++) {
|
||||
for (int is = 0; is < 4; is++) {
|
||||
clMat.dMtrx4D[iz][is] = dMtrx4D[iz][is] - rclMtrx[iz][is];
|
||||
clMat.dMtrx4D[iz][is] = dMtrx4D[iz][is] - mat[iz][is];
|
||||
}
|
||||
}
|
||||
|
||||
return clMat;
|
||||
}
|
||||
|
||||
inline Matrix4D& Matrix4D::operator -= (const Matrix4D& rclMtrx)
|
||||
inline Matrix4D& Matrix4D::operator -= (const Matrix4D& mat)
|
||||
{
|
||||
for (int iz = 0; iz < 4; iz++) {
|
||||
for (int is = 0; is < 4; is++) {
|
||||
dMtrx4D[iz][is] -= rclMtrx[iz][is];
|
||||
dMtrx4D[iz][is] -= mat[iz][is];
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Matrix4D& Matrix4D::operator *= (const Matrix4D& rclMtrx)
|
||||
inline Matrix4D& Matrix4D::operator *= (const Matrix4D& mat)
|
||||
{
|
||||
Matrix4D clMat;
|
||||
|
||||
@@ -266,8 +266,7 @@ inline Matrix4D& Matrix4D::operator *= (const Matrix4D& rclMtrx)
|
||||
for (int is = 0; is < 4; is++) {
|
||||
clMat.dMtrx4D[iz][is] = 0;
|
||||
for (int ie = 0; ie < 4; ie++) {
|
||||
clMat.dMtrx4D[iz][is] += dMtrx4D[iz][ie] *
|
||||
rclMtrx.dMtrx4D[ie][is];
|
||||
clMat.dMtrx4D[iz][is] += dMtrx4D[iz][ie] * mat.dMtrx4D[ie][is];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,7 +276,7 @@ inline Matrix4D& Matrix4D::operator *= (const Matrix4D& rclMtrx)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Matrix4D Matrix4D::operator * (const Matrix4D& rclMtrx) const
|
||||
inline Matrix4D Matrix4D::operator * (const Matrix4D& mat) const
|
||||
{
|
||||
Matrix4D clMat;
|
||||
|
||||
@@ -285,8 +284,7 @@ inline Matrix4D Matrix4D::operator * (const Matrix4D& rclMtrx) const
|
||||
for (int is = 0; is < 4; is++) {
|
||||
clMat.dMtrx4D[iz][is] = 0;
|
||||
for (int ie = 0; ie < 4; ie++) {
|
||||
clMat.dMtrx4D[iz][is] += dMtrx4D[iz][ie] *
|
||||
rclMtrx.dMtrx4D[ie][is];
|
||||
clMat.dMtrx4D[iz][is] += dMtrx4D[iz][ie] * mat.dMtrx4D[ie][is];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,51 +292,51 @@ inline Matrix4D Matrix4D::operator * (const Matrix4D& rclMtrx) const
|
||||
return clMat;
|
||||
}
|
||||
|
||||
inline Matrix4D& Matrix4D::operator= (const Matrix4D& rclMtrx)
|
||||
inline Matrix4D& Matrix4D::operator= (const Matrix4D& mat)
|
||||
{
|
||||
for (int iz = 0; iz < 4; iz++) {
|
||||
for (int is = 0; is < 4; is++) {
|
||||
dMtrx4D[iz][is] = rclMtrx.dMtrx4D[iz][is];
|
||||
dMtrx4D[iz][is] = mat.dMtrx4D[iz][is];
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3f Matrix4D::operator* (const Vector3f& rclVct) const
|
||||
inline Vector3f Matrix4D::operator* (const Vector3f& vec) const
|
||||
{
|
||||
double x = static_cast<double>(rclVct.x);
|
||||
double y = static_cast<double>(rclVct.y);
|
||||
double z = static_cast<double>(rclVct.z);
|
||||
double sx = static_cast<double>(vec.x);
|
||||
double sy = static_cast<double>(vec.y);
|
||||
double sz = static_cast<double>(vec.z);
|
||||
return Vector3f(
|
||||
static_cast<float>(dMtrx4D[0][0]*x + dMtrx4D[0][1]*y +
|
||||
dMtrx4D[0][2]*z + dMtrx4D[0][3]),
|
||||
static_cast<float>(dMtrx4D[1][0]*x + dMtrx4D[1][1]*y +
|
||||
dMtrx4D[1][2]*z + dMtrx4D[1][3]),
|
||||
static_cast<float>(dMtrx4D[2][0]*x + dMtrx4D[2][1]*y +
|
||||
dMtrx4D[2][2]*z + dMtrx4D[2][3])
|
||||
static_cast<float>(dMtrx4D[0][0]*sx + dMtrx4D[0][1]*sy +
|
||||
dMtrx4D[0][2]*sz + dMtrx4D[0][3]),
|
||||
static_cast<float>(dMtrx4D[1][0]*sx + dMtrx4D[1][1]*sy +
|
||||
dMtrx4D[1][2]*sz + dMtrx4D[1][3]),
|
||||
static_cast<float>(dMtrx4D[2][0]*sx + dMtrx4D[2][1]*sy +
|
||||
dMtrx4D[2][2]*sz + dMtrx4D[2][3])
|
||||
);
|
||||
}
|
||||
|
||||
inline Vector3d Matrix4D::operator* (const Vector3d& rclVct) const
|
||||
inline Vector3d Matrix4D::operator* (const Vector3d& vec) const
|
||||
{
|
||||
return Vector3d((dMtrx4D[0][0]*rclVct.x + dMtrx4D[0][1]*rclVct.y +
|
||||
dMtrx4D[0][2]*rclVct.z + dMtrx4D[0][3]),
|
||||
(dMtrx4D[1][0]*rclVct.x + dMtrx4D[1][1]*rclVct.y +
|
||||
dMtrx4D[1][2]*rclVct.z + dMtrx4D[1][3]),
|
||||
(dMtrx4D[2][0]*rclVct.x + dMtrx4D[2][1]*rclVct.y +
|
||||
dMtrx4D[2][2]*rclVct.z + dMtrx4D[2][3]));
|
||||
return Vector3d((dMtrx4D[0][0]*vec.x + dMtrx4D[0][1]*vec.y +
|
||||
dMtrx4D[0][2]*vec.z + dMtrx4D[0][3]),
|
||||
(dMtrx4D[1][0]*vec.x + dMtrx4D[1][1]*vec.y +
|
||||
dMtrx4D[1][2]*vec.z + dMtrx4D[1][3]),
|
||||
(dMtrx4D[2][0]*vec.x + dMtrx4D[2][1]*vec.y +
|
||||
dMtrx4D[2][2]*vec.z + dMtrx4D[2][3]));
|
||||
}
|
||||
|
||||
inline void Matrix4D::multVec(const Vector3d & src, Vector3d & dst) const
|
||||
{
|
||||
double x = (dMtrx4D[0][0]*src.x + dMtrx4D[0][1]*src.y +
|
||||
dMtrx4D[0][2]*src.z + dMtrx4D[0][3]);
|
||||
double y = (dMtrx4D[1][0]*src.x + dMtrx4D[1][1]*src.y +
|
||||
dMtrx4D[1][2]*src.z + dMtrx4D[1][3]);
|
||||
double z = (dMtrx4D[2][0]*src.x + dMtrx4D[2][1]*src.y +
|
||||
dMtrx4D[2][2]*src.z + dMtrx4D[2][3]);
|
||||
dst.Set(x,y,z);
|
||||
double dx = (dMtrx4D[0][0]*src.x + dMtrx4D[0][1]*src.y +
|
||||
dMtrx4D[0][2]*src.z + dMtrx4D[0][3]);
|
||||
double dy = (dMtrx4D[1][0]*src.x + dMtrx4D[1][1]*src.y +
|
||||
dMtrx4D[1][2]*src.z + dMtrx4D[1][3]);
|
||||
double dz = (dMtrx4D[2][0]*src.x + dMtrx4D[2][1]*src.y +
|
||||
dMtrx4D[2][2]*src.z + dMtrx4D[2][3]);
|
||||
dst.Set(dx,dy,dz);
|
||||
}
|
||||
|
||||
inline void Matrix4D::multVec(const Vector3f & src, Vector3f & dst) const
|
||||
@@ -347,15 +345,15 @@ inline void Matrix4D::multVec(const Vector3f & src, Vector3f & dst) const
|
||||
double sy = static_cast<double>(src.y);
|
||||
double sz = static_cast<double>(src.z);
|
||||
|
||||
double x = (dMtrx4D[0][0]*sx + dMtrx4D[0][1]*sy +
|
||||
dMtrx4D[0][2]*sz + dMtrx4D[0][3]);
|
||||
double y = (dMtrx4D[1][0]*sx + dMtrx4D[1][1]*sy +
|
||||
dMtrx4D[1][2]*sz + dMtrx4D[1][3]);
|
||||
double z = (dMtrx4D[2][0]*sx + dMtrx4D[2][1]*sy +
|
||||
dMtrx4D[2][2]*sz + dMtrx4D[2][3]);
|
||||
dst.Set(static_cast<float>(x),
|
||||
static_cast<float>(y),
|
||||
static_cast<float>(z));
|
||||
double dx = (dMtrx4D[0][0]*sx + dMtrx4D[0][1]*sy +
|
||||
dMtrx4D[0][2]*sz + dMtrx4D[0][3]);
|
||||
double dy = (dMtrx4D[1][0]*sx + dMtrx4D[1][1]*sy +
|
||||
dMtrx4D[1][2]*sz + dMtrx4D[1][3]);
|
||||
double dz = (dMtrx4D[2][0]*sx + dMtrx4D[2][1]*sy +
|
||||
dMtrx4D[2][2]*sz + dMtrx4D[2][3]);
|
||||
dst.Set(static_cast<float>(dx),
|
||||
static_cast<float>(dy),
|
||||
static_cast<float>(dz));
|
||||
}
|
||||
|
||||
inline Matrix4D Matrix4D::operator * (double scalar) const
|
||||
@@ -382,11 +380,11 @@ inline Matrix4D& Matrix4D::operator *= (double scalar)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool Matrix4D::operator== (const Matrix4D& rclMtrx) const
|
||||
inline bool Matrix4D::operator== (const Matrix4D& mat) const
|
||||
{
|
||||
for (int iz = 0; iz < 4; iz++) {
|
||||
for (int is = 0; is < 4; is++) {
|
||||
if (fabs(dMtrx4D[iz][is] - rclMtrx.dMtrx4D[iz][is]) > traits_type::epsilon())
|
||||
if (fabs(dMtrx4D[iz][is] - mat.dMtrx4D[iz][is]) > traits_type::epsilon())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -394,16 +392,15 @@ inline bool Matrix4D::operator== (const Matrix4D& rclMtrx) const
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Matrix4D::operator!= (const Matrix4D& rclMtrx) const
|
||||
inline bool Matrix4D::operator!= (const Matrix4D& mat) const
|
||||
{
|
||||
return !( (*this) == rclMtrx );
|
||||
return !((*this) == mat);
|
||||
}
|
||||
|
||||
inline Vector3f& operator*= (Vector3f& rclVect,
|
||||
const Matrix4D& rclMtrx)
|
||||
inline Vector3f& operator*= (Vector3f& vec, const Matrix4D& mat)
|
||||
{
|
||||
rclVect = rclMtrx * rclVect;
|
||||
return rclVect;
|
||||
vec = mat * vec;
|
||||
return vec;
|
||||
}
|
||||
|
||||
inline double* Matrix4D::operator[] (unsigned short usNdx)
|
||||
@@ -431,25 +428,25 @@ inline Vector3d Matrix4D::trace() const
|
||||
return Vector3d(dMtrx4D[0][0], dMtrx4D[1][1], dMtrx4D[2][2]);
|
||||
}
|
||||
|
||||
inline void Matrix4D::setRow(unsigned short usNdx, const Vector3d& v)
|
||||
inline void Matrix4D::setRow(unsigned short usNdx, const Vector3d& vec)
|
||||
{
|
||||
dMtrx4D[usNdx][0] = v.x;
|
||||
dMtrx4D[usNdx][1] = v.y;
|
||||
dMtrx4D[usNdx][2] = v.z;
|
||||
dMtrx4D[usNdx][0] = vec.x;
|
||||
dMtrx4D[usNdx][1] = vec.y;
|
||||
dMtrx4D[usNdx][2] = vec.z;
|
||||
}
|
||||
|
||||
inline void Matrix4D::setCol(unsigned short usNdx, const Vector3d& v)
|
||||
inline void Matrix4D::setCol(unsigned short usNdx, const Vector3d& vec)
|
||||
{
|
||||
dMtrx4D[0][usNdx] = v.x;
|
||||
dMtrx4D[1][usNdx] = v.y;
|
||||
dMtrx4D[2][usNdx] = v.z;
|
||||
dMtrx4D[0][usNdx] = vec.x;
|
||||
dMtrx4D[1][usNdx] = vec.y;
|
||||
dMtrx4D[2][usNdx] = vec.z;
|
||||
}
|
||||
|
||||
inline void Matrix4D::setTrace(const Vector3d& v)
|
||||
inline void Matrix4D::setTrace(const Vector3d& vec)
|
||||
{
|
||||
dMtrx4D[0][0] = v.x;
|
||||
dMtrx4D[1][1] = v.y;
|
||||
dMtrx4D[2][2] = v.z;
|
||||
dMtrx4D[0][0] = vec.x;
|
||||
dMtrx4D[1][1] = vec.y;
|
||||
dMtrx4D[2][2] = vec.z;
|
||||
}
|
||||
|
||||
} // namespace Base
|
||||
|
||||
Reference in New Issue
Block a user