AffineTrans _afTranslate, _afScale, _afRotate;
//平移的是世界坐标系下的dx, dy, dz,而不是局部坐标系
_afTranslate.m03 += dx; //translate x
_afTranslate.m13 += dy; //translate y
_afTranslate.m23 += dz; //translate z
_afScale.set(scaleX, 0, 0, 0, 0, scaleY, 0, 0, 0, 0, scaleZ, 0);
_afTranslate.mul(_afScale);
//旋转是按照自身局部坐标系下的旋转轴来进行的
_afRotate.setIdentity();
_afRotate.setRotationZ(degreeZ);
_afTranslate.mul(_afRotate);
_afRotate.setIdentity();
_afRotate.setRotationX(degreeX);
_afTranslate.mul(_afRotate);
_afRotate.setIdentity();
_afRotate.setRotationY(degreeY);
_afTranslate.mul(_afRotate);

layout.setAffineTrans(_afTranslate);
三维变换详解
本文详细介绍了三维空间中物体的平移、缩放及旋转操作,并通过具体的代码实现展示了如何使用矩阵来完成这些变换过程。平移操作是针对世界坐标系进行的,而旋转则基于局部坐标系。文章还涉及了如何设置变换矩阵以及最终应用到布局中。
91

被折叠的 条评论
为什么被折叠?



