18#ifndef BIMHOMEBASE_MATRIX_H
19#define BIMHOMEBASE_MATRIX_H
69 Matrix4D(
float a11,
float a12,
float a13,
float a14,
70 float a21,
float a22,
float a23,
float a24,
71 float a31,
float a32,
float a33,
float a34,
72 float a41,
float a42,
float a43,
float a44);
79 Matrix4D(
double a11,
double a12,
double a13,
double a14,
80 double a21,
double a22,
double a23,
double a24,
81 double a31,
double a32,
double a33,
double a34,
82 double a41,
double a42,
double a43,
double a44);
140 inline Vector3d getRow(
unsigned short usNdx)
const;
148 inline Vector3d getCol(
unsigned short usNdx)
const;
163 inline void setRow(
unsigned short usNdx,
const Vector3d& v);
171 inline void setCol(
unsigned short usNdx,
const Vector3d& v);
178 inline void setTrace(
const Vector3d& v);
302 void move(
float x,
float y,
float z)
314 void move(
double x,
double y,
double z)
340 void scale(
float x,
float y,
float z)
352 void scale(
double x,
double y,
double z)
378 scale(
Vector3f(scalexyz, scalexyz, scalexyz));
388 scale(
Vector3d(scalexyz, scalexyz, scalexyz));
607 inline Matrix4D operator * (
double scalar)
const;
615 inline Matrix4D& operator *= (
double scalar);
623 inline bool operator != (
const Matrix4D& rclMtrx)
const;
631 inline bool operator == (
const Matrix4D& rclMtrx)
const;
647 inline double* operator [] (
unsigned short usNdx);
655 inline const double* operator[] (
unsigned short usNdx)
const;
658 double dMtrx4D[4][4];
664 unsigned short iz, is;
666 for (iz = 0; iz < 4; iz++)
668 for (is = 0; is < 4; is++)
679 unsigned short iz, is;
681 for (iz = 0; iz < 4; iz++)
683 for (is = 0; is < 4; is++)
685 dMtrx4D[iz][is] += rclMtrx[iz][is];
695 unsigned short iz, is;
697 for (iz = 0; iz < 4; iz++)
699 for (is = 0; is < 4; is++)
710 unsigned short iz, is;
712 for (iz = 0; iz < 4; iz++)
714 for (is = 0; is < 4; is++)
716 dMtrx4D[iz][is] -= rclMtrx[iz][is];
726 unsigned short ie, iz, is;
728 for (iz = 0; iz < 4; iz++)
729 for (is = 0; is < 4; is++)
732 for (ie = 0; ie < 4; ie++)
745 unsigned short ie, iz, is;
747 for (iz = 0; iz < 4; iz++)
748 for (is = 0; is < 4; is++)
751 for (ie = 0; ie < 4; ie++)
761 unsigned short iz, is;
763 for (iz = 0; iz < 4; iz++)
765 for (is = 0; is < 4; is++)
776 double x =
static_cast<double>(rclVct.
x);
777 double y =
static_cast<double>(rclVct.
y);
778 double z =
static_cast<double>(rclVct.
z);
812 double sx =
static_cast<double>(src.
x);
813 double sy =
static_cast<double>(src.
y);
814 double sz =
static_cast<double>(src.
z);
822 dst.
Set(
static_cast<float>(x),
823 static_cast<float>(y),
824 static_cast<float>(z));
830 for (
unsigned short i = 0; i < 4; i++)
832 for (
unsigned short j = 0; j < 4; j++)
843 for (
unsigned short i = 0; i < 4; i++)
845 for (
unsigned short j = 0; j < 4; j++)
855 unsigned short iz, is;
857 for (iz = 0; iz < 4; iz++)
859 for (is = 0; is < 4; is++)
871 return !((*this) == rclMtrx);
877 rclVect = rclMtrx * rclVect;
~Matrix4D()
析构函数
Definition Matrix.h:113
Matrix4D operator-(const Matrix4D &rclMtrx) const
矩阵减法运算符重载
Definition Matrix.h:692
Matrix4D(float a11, float a12, float a13, float a14, float a21, float a22, float a23, float a24, float a31, float a32, float a33, float a34, float a41, float a42, float a43, float a44)
构造函数,创建一个 4x4 矩阵
unsigned long getMemSpace()
获取矩阵占用的内存空间大小
double * operator[](unsigned short usNdx)
提供对矩阵行的直接访问
Definition Matrix.h:881
Vector3d trace() const
计算矩阵主对角线上的元素
Definition Matrix.h:901
std::string toString() const
将矩阵转换为字符串
float_traits< double > traits_type
定义了矩阵元素的数值类型特性
Definition Matrix.h:54
void scale(float scalexyz)
均匀缩放矩阵
Definition Matrix.h:376
void scale(const Vector3f &rclVct)
缩放矩阵
bool operator!=(const Matrix4D &rclMtrx) const
矩阵不等运算符重载
Definition Matrix.h:869
void multVec(const Vector3d &src, Vector3d &dst) const
将矩阵与一个三维向量相乘
Definition Matrix.h:799
void rotLine(const Vector3d &rclVct, double fAngle)
绕任意轴旋转
void move(float x, float y, float z)
沿 x、y、z 轴移动矩阵
Definition Matrix.h:302
Matrix4D operator*(const Matrix4D &rclMtrx) const
矩阵乘法运算符重载
Definition Matrix.h:742
Matrix4D & operator-=(const Matrix4D &rclMtrx)
矩阵减法赋值运算符重载
Definition Matrix.h:708
bool toAxisAngle(Vector3d &rclBase, Vector3d &rclDir, double &fAngle, double &fTranslation) const
将矩阵转换为轴角表示
void move(const Vector3f &rclVct)
沿指定向量移动矩阵
double determinant() const
计算矩阵的行列式
void getMatrix(double dMtrx[16]) const
将矩阵数据复制到一维数组中
void transform(const Vector3d &rclVct, const Matrix4D &rclMtrx)
围绕一个点进行变换
Matrix4D & Outer(const Vector3d &rV1, const Vector3d &rV2)
创建一个由两个三维向量的外积构成的矩阵
std::string analyse() const
分析矩阵的类型和特性
void rotLine(const Vector3f &rclBase, const Vector3f &rclDir, float fAngle)
绕任意轴旋转
Matrix4D()
默认构造函数,初始化为单位矩阵
Matrix4D & Hat(const Vector3f &rV)
将一个三维向量转换为斜对称矩阵
Matrix4D & operator*=(const Matrix4D &rclMtrx)
矩阵乘法赋值运算符重载
Definition Matrix.h:723
Matrix4D & operator=(const Matrix4D &rclMtrx)
矩阵赋值运算符重载
Definition Matrix.h:759
void setGLMatrix(const double dMtrx[16])
设置 OpenGL 风格的矩阵
void scale(const Vector3d &rclVct)
缩放矩阵
void setRow(unsigned short usNdx, const Vector3d &v)
设置矩阵的指定行
Definition Matrix.h:906
Matrix4D & Outer(const Vector3f &rV1, const Vector3f &rV2)
创建一个由两个三维向量的外积构成的矩阵
Matrix4D(const Matrix4D &rclMtrx)
复制构造函数
bool toAxisAngle(Vector3f &rclBase, Vector3f &rclDir, float &fAngle, float &fTranslation) const
将矩阵转换为轴角表示
bool isUnity() const
检查矩阵是否为单位矩阵
Matrix4D(const Vector3d &rclBase, const Vector3d &rclDir, double fAngle)
构造函数,创建一个围绕特定轴旋转特定角度的变换矩阵
double determinant3() const
计算 3x3 子矩阵的行列式
void setCol(unsigned short usNdx, const Vector3d &v)
设置矩阵的指定列
Definition Matrix.h:913
void move(const Vector3d &rclVct)
沿指定向量移动矩阵
void setMatrix(const double dMtrx[16])
将一维数组中的矩阵数据复制到矩阵对象中
void inverseGauss()
通过高斯-约当消元法计算矩阵的逆
bool isNull() const
检查矩阵是否为零矩阵
void scale(double x, double y, double z)
缩放矩阵
Definition Matrix.h:352
bool operator==(const Matrix4D &rclMtrx) const
矩阵等运算符重载
Definition Matrix.h:853
void inverseOrthogonal()
求取正交变换矩阵的逆矩阵
void getGLMatrix(double dMtrx[16]) const
获取 OpenGL 风格的矩阵
ScaleType hasScale(double tol=0.0) const
检查矩阵是否包含缩放成分
Vector3d getRow(unsigned short usNdx) const
获取矩阵的指定行
Definition Matrix.h:891
void transform(const Vector3f &rclVct, const Matrix4D &rclMtrx)
围绕一个点进行变换
void fromString(const std::string &str)
从字符串中读取矩阵
Matrix4D operator+(const Matrix4D &rclMtrx) const
矩阵加法运算符重载
Definition Matrix.h:661
void scale(float x, float y, float z)
缩放矩阵
Definition Matrix.h:340
void setToUnity()
设置矩阵为单位矩阵
void Print() const
打印矩阵的每一行
void rotY(double fAngle)
绕 Y 轴旋转
Matrix4D(double a11, double a12, double a13, double a14, double a21, double a22, double a23, double a24, double a31, double a32, double a33, double a34, double a41, double a42, double a43, double a44)
构造函数,创建一个 4x4 矩阵
void rotZ(double fAngle)
绕 Z 轴旋转
void scale(double scalexyz)
均匀缩放矩阵
Definition Matrix.h:386
void rotLine(const Vector3f &rclVct, float fAngle)
绕任意轴旋转
Matrix4D & Hat(const Vector3d &rV)
将一个三维向量 rV 转换成一个 4x4 旋转矩阵的斜对称矩阵
void move(double x, double y, double z)
沿 x、y、z 轴移动矩阵
Definition Matrix.h:314
double dMtrx4D[4][4]
矩阵数据
Definition Matrix.h:658
void rotLine(const Vector3d &rclBase, const Vector3d &rclDir, double fAngle)
绕任意轴旋转
void setTrace(const Vector3d &v)
设置矩阵的主对角线元素
Definition Matrix.h:920
Matrix4D & operator+=(const Matrix4D &rclMtrx)
矩阵加法赋值运算符重载
Definition Matrix.h:677
Vector3d getCol(unsigned short usNdx) const
获取矩阵的指定列
Definition Matrix.h:896
void rotX(double fAngle)
绕 X 轴旋转
Matrix4D(const Vector3f &rclBase, const Vector3f &rclDir, float fAngle)
构造函数,创建一个围绕特定轴旋转特定角度的变换矩阵
Matrix4D 类,表示一个 4x4 矩阵
Definition Matrix.h:53
void Set(_Precision fX, _Precision fY, _Precision fZ)
设置向量的 x, y, 和 z 分量为给定的值 fX, fY, 和 fZ
_Precision x
x-coordinate
Definition Vector3D.h:714
_Precision z
z-coordinate
Definition Vector3D.h:716
_Precision y
y-coordinate
Definition Vector3D.h:715
Vector3 类,表示三维空间中的向量
Definition Vector3D.h:149
Vector3< double > Vector3d
定义一个基于 double 的三维向量类型
Definition Vector3D.h:909
Vector3f & operator*=(Vector3f &rclVect, const Matrix4D &rclMtrx)
Definition Matrix.h:874
ScaleType
ScaleType 用于区分矩阵是否包含缩放成分,以及缩放的类型
Definition Matrix.h:40
Vector3< float > Vector3f
定义一个基于 float 的三维向量类型
Definition Vector3D.h:904
Definition BaseFigureFactory.h:24
static float_type epsilon()
提供双精度浮点数精度的最小值
Definition Vector3D.h:127
提供浮点数类型的特性
Definition Vector3D.h:60