xmathdoc.html
来自「一个简单的数学库.但是很实用..大家可以下载过去研究一下.」· HTML 代码 · 共 385 行 · 第 1/2 页
HTML
385 行
<p><strong>成员</strong></p>
<table>
<tr><td><strong>T x</strong></td><td>绕x轴旋转的角度(弧度)</td></tr>
<tr><td><strong>T y</strong></td><td>绕y轴旋转的角度(弧度)</td></tr>
<tr><td><strong>T z</strong></td><td>绕z轴旋转的角度(弧度)</td></tr>
</table>
<p><a href="#content">返回目录</a></p><hr/>
<h3 id="CVector">template <class T, int D><br/>class CVector</h3>
<p><strong>描述</strong></p>
<p>模板类,表示N维向量(或点)。</p>
<p><strong>模板参数</strong></p>
<table>
<tr><td><strong>T</strong></td><td>数据类型</td></tr>
<tr><td><strong>D</strong></td><td>维数</td></tr>
</table>
<p><strong>成员</strong></p>
<table>
<tr><td><strong>T M[D]</strong></td><td>向量的D个坐标值</td></tr>
</table>
<p><strong>构造函数</strong></p>
<table>
<tr><td><strong>CVector()</strong></td><td>默认构造函数</td></tr>
<tr><td><strong>CVector(const CVector &v)</strong></td><td>复制参数v的值</td></tr>
</table>
<p><strong>操作</strong></p>
<table>
<tr><td><strong>int Dimension () const</strong></td><td>返回向量的维数</td></tr>
<tr><td><strong>void SetZero ()</strong></td><td>将所有的坐标值置0</td></tr>
<tr><td><strong>void SetVal (int i, T val)</strong></td><td>将第i个坐标值设为val,其中i应大于等于0并小于D-1。该函数是安全的,它会检查下标i的有效性。</td></tr>
<tr><td><strong>void SetVal (int i, T &val)</strong></td><td>获取第i个坐标值,保存在val中,其中i应大于等于0并小于D-1。该函数是安全的,它会检查下标i的有效性。</td></tr>
<tr><td><strong>CVector& Add (const CVector &v)</strong></td><td>向量加法,this=this+v</td></tr>
<tr><td><strong>CVector& Add (const CVector &v1, const CVector &v2)</strong></td><td>向量加法,this=v1+v2</td></tr>
<tr><td><strong>CVector& Sub (const CVector &v)</strong></td><td>向量减法,this=this-v</td></tr>
<tr><td><strong>CVector& Sub (const CVector &v1, const CVector &v2)</strong></td><td>向量减法,this=v1-v2</td></tr>
<tr><td><strong>CVector& Reverse ()</strong></td><td>将向量反向</td></tr>
<tr><td><strong>CVector& Scale (T val)</strong></td><td>标量乘法,this=this*val</td></tr>
<tr><td><strong>T Dot (const CVector &v) const</strong></td><td>向量点积,返回this*v的值</td></tr>
<tr><td><strong>CVector& Cross (const CVector &v1, const CVector &v2)</strong></td><td>向量叉积,this=v1*v2,只有3D向量(CVector<T,3>)有此操作。</td></tr>
<tr><td><strong>inline T CosOfAngle(const CVector &v) const</strong></td><td>计算并返回this与v的夹角的余弦值,只有2D和3D向量(CVector<T,2>和CVector<T,3>)有此操作。</td></tr>
<tr><td><strong>T Length () const</strong></td><td>计算并返回向量的长度</td></tr>
<tr><td><strong>T Length2 () const</strong></td><td>计算并返回向量长度的平方</td></tr>
<tr><td><strong>void Normalize ()</strong></td><td>将向量归一化为单位向量</td></tr>
</table>
<p><strong>运算符重载</strong></p>
<table>
<tr><td><strong>T operator () (int i) const</strong></td><td>获取第i个坐标值,对下标i不作任何检查。</td></tr>
<tr><td><strong>T& operator () (int i)</strong></td><td>获取第i个坐标的引用,对下标i不作任何检查。</td></tr>
<tr><td><strong>operator +</strong></td><td>二元加法,将两个向量相加</td></tr>
<tr><td><strong>operator -</strong></td><td>二元减法,将两个向量相减</td></tr>
<tr><td><strong>operator -</strong></td><td>一元减法,将向量取反</td></tr>
<tr><td><strong>operator *</strong></td><td>二元乘法,计算两个向量的点积</td></tr>
<tr><td><strong>operator *</strong></td><td>二元乘法,将向量乘以一个实数</td></tr>
<tr><td><strong>operator +=</strong></td><td>加上一个向量</td></tr>
<tr><td><strong>operator -=</strong></td><td>减去一个向量</td></tr>
<tr><td><strong>operator *=</strong></td><td>乘以一个实数,或者向量(点积)</td></tr>
</table>
<p><a href="#content">返回目录</a></p><hr/>
<h3 id="CHomoVector">template <class T><br/>class CHomoVector4D public: CVector <T,3></h3>
<p><strong>描述</strong></p>
<p>模板类,表示4D齐次向量(点)。</p>
<p><strong>模板参数</strong></p>
<table>
<tr><td><strong>T</strong></td><td>数据类型</td></tr>
</table>
<p><strong>成员</strong></p>
<table>
<tr><td><strong>T w</strong></td><td>齐次坐标</td></tr>
</table>
<p><strong>构造函数</strong></p>
<table>
<tr><td><strong>CHomoVector4D()</strong></td><td>默认构造函数</td></tr>
<tr><td><strong>CHomoVector4d(const CVector<T,3> &v)</strong></td><td>复制参数v的值,w设为1</td></tr>
</table>
<p><strong>操作</strong></p>
<table>
<tr><td><strong>void Transform()</strong></td><td>将坐标齐次化,即所有坐标值除以w</td></tr>
</table>
<p><strong>运算符重载</strong></p>
<table>
<tr><td><strong>CHomoVector4D& operator = (const CVector<T,3> &v)</strong></td><td>复制v的值,w设为1</td></tr>
</table>
<p><a href="#content">返回目录</a></p><hr/>
<h3 id="CMatrix">template <class T, int R, int C><br/>class CMatrix</h3>
<p><strong>描述</strong></p>
<p>模板类,表示R行C列的矩阵。</p>
<p><strong>模板参数</strong></p>
<table>
<tr><td><strong>T</strong></td><td>数据类型</td></tr>
<tr><td><strong>R</strong></td><td>行数</td></tr>
<tr><td><strong>C</strong></td><td>列数</td></tr>
</table>
<p><strong>成员</strong></p>
<table>
<tr><td><strong>T M[R][C]</strong></td><td>矩阵元素</td></tr>
</table>
<p><strong>构造函数</strong></p>
<table>
<tr><td><strong>CMatrix()</strong></td><td>默认构造函数</td></tr>
<tr><td><strong>CMatrix(const CMatrix<T,R,C> &m)</strong></td><td>复制矩阵m的值。</td></tr>
</table>
<p><strong>操作</strong></p>
<table>
<tr><td><strong>void SetIdentity ()</strong></td><td>设为单位矩阵,只有方阵才能调用该函数。</td></tr>
<tr><td><strong>void SetVal (int r, int c, T val)</strong></td><td>设置M[r][c]的值。该函数是安全的,它会检查下标的有效性。</td></tr>
<tr><td><strong>void GetVal (int r, int c, T &val)</strong></td><td>获取M[r][c]的值,并保存在val中。该函数是安全的,它会检查下标的有效性。</td></tr>
<tr><td><strong>int Row () const</strong></td><td>获取矩阵的行数。</td></tr>
<tr><td><strong>int Col () const</strong></td><td>获取矩阵的列数。</td></tr>
<tr><td><strong>bool IsSquare () const</strong></td><td>检测矩阵是否为方阵。</td></tr>
<tr><td><strong>CMatrix& Add (const CMatrix &m)</strong></td><td>矩阵加法,this=this+m。</td></tr>
<tr><td><strong>CMatrix& Add (const CMatrix &m1, const CMatrix &m2)</strong></td><td>矩阵加法,this=m1+m2。</td></tr>
<tr><td><strong>CMatrix& Sub (const CMatrix &m)</strong></td><td>矩阵减法,this=this-m。</td></tr>
<tr><td><strong>CMatrix& Sub (const CMatrix &m1, const CMatrix &m2)</strong></td><td>矩阵减法,this=m1-m2。</td></tr>
<tr><td><strong>CMatrix& Scale (T val)</strong></td><td>标量乘法,this=this*val。</td></tr>
<tr><td><strong>template<int I>CMatrix& Mul (const CMatrix<T,R,I> &m1, const CMatrix<T,I,C> &m2)</strong></td><td>矩阵乘法,this=m1*m2。</td></tr>
<tr><td><strong>CMatrix& Transpose (const CMatrix<T,C,R> &m)</strong></td><td>将m的转置保存在this中。</td></tr>
<tr><td><strong>T Det () const</strong></td><td>计算并返回行列式的值。只有方阵才能调用该函数。</td></tr>
<tr><td><strong>bool Inverse (const CMatrix &m)</strong></td><td>计算m的逆阵,并保存在this中。函数执行成功就返回true,否则false。</td></tr>
</table>
<p><strong>运算符重载</strong></p>
<table>
<tr><td><strong>T operator () (int r, int c) const</strong></td><td>获取M[r][c]的值,不对坐任何检查。</td></tr>
<tr><td><strong>T& operator () (int r, int c)</strong></td><td>获取M[r][c]的引用,不对坐任何检查。</td></tr>
<tr><td><strong>operator +=</strong></td><td>加上一个矩阵</td></tr>
<tr><td><strong>operator -=</strong></td><td>减去一个矩阵</td></tr>
<tr><td><strong>operator *=</strong></td><td>乘以一个实数</td></tr>
</table>
<p><a href="#content">返回目录</a></p><hr/>
<h3 id="CQuaternion">template <class T><br/>class CQuaternion</h3>
<p><strong>描述</strong></p>
<p>模板类,表示四元数。</p>
<p><strong>模板参数</strong></p>
<table>
<tr><td><strong>T</strong></td><td>数据类型</td></tr>
</table>
<p><strong>成员</strong></p>
<table>
<tr><td><strong>T qa</strong></td><td>四元数的实部</td></tr>
<tr><td><strong>CVector<T,3> qv</strong></td><td>四元数的虚部</td></tr>
</table>
<p><strong>构造函数</strong></p>
<table>
<tr><td><strong>CQuaternion()</strong></td><td>默认构造函数</td></tr>
<tr><td><strong>CQuaternion(const CQuaternion<T> &q)</strong></td><td>复制四元数q的值。</td></tr>
<tr><td><strong>CQuaternion(const CVector<T,3> &v)</strong></td><td>根据3D向量构造四元数,qv=v,qa=0。</td></tr>
<tr><td><strong>CQuaternion(const CVector<T,3> &v, T theta)</strong></td><td>构造四元数,以v为旋转轴,以theta为转角。</td></tr>
</table>
<p><strong>操作</strong></p>
<table>
<tr><td><strong>CQuaternion& Add (const CQuaternion &q)</strong></td><td>四元数加法,this=this+q。</td></tr>
<tr><td><strong>CQuaternion& Add (const CQuaternion &q1, const CQuaternion &q2)</strong></td><td>四元数加法,this=q1+q2。</td></tr>
<tr><td><strong>CQuaternion& Sub (const CQuaternion &q)</strong></td><td>四元数减法,this=this-q。</td></tr>
<tr><td><strong>CQuaternion& Sub (const CQuaternion &q1, const CQuaternion &q2)</strong></td><td>四元数减法,this=q1-q2。</td></tr>
<tr><td><strong>CQuaternion& Scale (T val)</strong></td><td>四元数标量乘法,this=this*val。</td></tr>
<tr><td><strong>T Dot (const CQuaternion &q)</strong></td><td>四元数点积,this=this*q。</td></tr>
<tr><td><strong>CQuaternion& Mul (const CQuaternion &q1, const CQuaternion &q2)</strong></td><td>四元数乘法,this=q1*q2。</td></tr>
<tr><td><strong>CQuaternion& Difference (const CQuaternion &q1, const CQuaternion &q2)</strong></td><td>四元数除法,this=q1/q2。其结果表示q1到q2的转换。</td></tr>
<tr><td><strong>T Magnitude () const</strong></td><td>四元数的值。</td></tr>
<tr><td><strong>T Magnitude2 () const</strong></td><td>四元数的值的平方。</td></tr>
<tr><td><strong>CQuaternion& Conjugate ()</strong></td><td>设置四元数为它的共轭。</td></tr>
<tr><td><strong>CQuaternion& Inverse ()</strong></td><td>设置四元数为它的逆。</td></tr>
<tr><td><strong>CQuaternion& InverseUnit()</strong></td><td>设置四元数为它的逆。它假设当前四元数为单位四元数,所以比<strong>Inverse</strong>要快。</td></tr>
<tr><td><strong>CQuaternion& Log (const CQuaternion &q)</strong></td><td>计算q的对数(以e为底),结果保存在this中。</td></tr>
<tr><td><strong>CQuaternion& Exp (const CQuaternion &q)</strong></td><td>计算q的e次方,结果保存在this中。</td></tr>
<tr><td><strong>CQuaternion& Power (T t)</strong></td><td>计算q的t次方,结果保存在this中。</td></tr>
<tr><td><strong>void FromVectorAngle (const CVector<T,3> &v, T angle, bool normalized = true)</strong></td><td>根据旋转轴v和旋转角angle构造四元数。如果normalized为false,v将首先被规整化为单位向量。</td></tr>
<tr><td><strong>void ToVectorAngle (CVector<T,3> &v, T &angle) const</strong></td><td>从四元数中提取旋转轴和旋转角,并分别保存在v和angle中。</td></tr>
</table>
<p><strong>运算符重载</strong></p>
<table>
<tr><td><strong>operator +</strong></td><td>二元加法,将两个四元数相加</td></tr>
<tr><td><strong>operator -</strong></td><td>二元减法,将两个四元数相减</td></tr>
<tr><td><strong>operator *</strong></td><td>二元乘法,将两个四元数相乘</td></tr>
<tr><td><strong>operator /</strong></td><td>二元除法,将两个四元数相除</td></tr>
</table>
<p><a href="#content">返回目录</a></p><hr/>
<h3 id="typedef">类型定义(typedef)</h3>
<table>
<tr><td><strong>VECTOR2Di</strong></td><td>CVector<int,2></td></tr>
<tr><td><strong>VECTOR2Df</strong></td><td>CVector<float,2></td></tr>
<tr><td><strong>VECTOR2Dd</strong></td><td>CVector<double,2></td></tr>
<tr><td><strong>VECTOR3Di</strong></td><td>CVector<int,3></td></tr>
<tr><td><strong>VECTOR3Df</strong></td><td>CVector<float,3></td></tr>
<tr><td><strong>VECTOR3Dd</strong></td><td>CVector<double,3></td></tr>
<tr><td><strong>VECTOR4Di</strong></td><td>CHomoVector4D<int></td></tr>
<tr><td><strong>VECTOR4Df</strong></td><td>CHomoVector4D<float></td></tr>
<tr><td><strong>VECTOR4Dd</strong></td><td>CHomoVector4D<double></td></tr>
</table>
<p><a href="#content">返回目录</a></p><hr/>
<h4>版本:V0.01</h4>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?