切变是坐标系的变换,非均匀的拉伸。切变时候,角度变化,但是面积或体积不变。也可以理解为坐标轴间的角度变化,造成的扭曲。

如下图,这是x坐标根据y坐标的切变,机器人的y坐标没有变化,只有x坐标变化了,变化后的坐标x`可以理解为将y坐标乘以切变因子s与原坐标x的和:x` = x + sy。如果是3D则增加z坐标的切变因子t: x` = x + sy,y` = y + tz

按角度构建切变矩阵_d3

切变因子通过切变角度计算。


按角度构建切变矩阵_d3_02


按角度构建切变矩阵_c++_03


那么构建根据y坐标切变x坐标的代码为:


float s = tan(D3DXToRadian(30));
D3DXMATRIX matShear(1.0f,0.0f,0.0f,0.0f,
s,1.0f,0.0f,0.0f,
0.0f,0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f,1.0f);
g_device->SetTransform(D3DTS_WORLD,&matShear);






作者:张东升