空间坐标变换(PythonC++实现)

📅 2026/7/15 14:14:01 👁️ 阅读次数 📝 编程学习
空间坐标变换(PythonC++实现)

空间坐标变换可看作坐标点乘以一个齐次矩阵,其中,齐次矩阵可表示为:

其中:
①区域的3×3矩阵产生三维图形的比例、对称、旋转、错切等基本变换;
②区域产生图形的透视变换;
③区域产生沿X、Y、Z三个轴的平移变换;
④区域产生图形的总比例变换。

平移变换

平移变换可表示为:
[xyz1][100001000010lmn1]=[x+ly+mz+n1] \begin{gathered} \quad \begin{bmatrix} x & y & z & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ l & m & n & 1 \end{bmatrix} = \begin{bmatrix} x+l & y+m & z+n & 1 \end{bmatrix} \end{gathered}[xyz1]100l010m001n0001=[x+ly+mz+n1]

绕X轴旋转

空间立体绕X轴旋转某个角度,实体上个点的X坐标不变,只有Y、Z坐标改变,可表示为:
[xyz1][10000cos(θ)sin(θ)00−sin(θ)cos(θ)00001]=[xy×cos(θ)−z×sin(θ)y×sin(θ)+z×cos(θ)1] \begin{gathered} \quad \begin{bmatrix} x & y & z & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & cos(\theta) & sin(\theta) & 0 \\ 0 & -sin(\theta) & cos(\theta) & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} = \begin{bmatrix} x & y \times cos(\theta) - z \times sin(\theta) & y \times sin(\theta) + z \times cos(\theta) & 1 \end{bmatrix} \end{gathered}[xyz1]10000cos(θ)sin(θ)00sin(θ)cos(θ)00001=[xy×cos(θ)z×sin(θ)y×