整理2021年发过的文章
前言
这是白玉无冰第三篇年度合集文章整理。
2020年一共发布了47
篇原创内容,2021年一共发布了16
篇原创内容,同比负增长65.96%
。总得来说,从每1.1周一更
进步到每3.3周一更
。
争取在2022年有新的进步!
开始
按时间顺序梳理,随白玉无冰一起遨游2021吧!
四元数与3D旋转实例
用几个实用的例子去理解四元数。
当时发这篇文章的时候,四元数的单词拼错了,正确的应该是 Quaternion
。
有时候,白玉无冰也会忘了怎么使用四元数,经常翻这篇文章回忆。
![73fc87c79a9dcf5f73a0e3a0f8b9597a.gif](https://img-blog.csdnimg.cn/img_convert/73fc87c79a9dcf5f73a0e3a0f8b9597a.gif)
其中,绕指定轴旋转四元数要特别注意是本地空间(局部坐标)的轴,还是世界空间下轴。
/**
* @en Sets the out quaternion to represent a radian rotation around a given rotation axis in world space
* @zh 绕世界空间下指定轴旋转四元数
* @param axis axis of rotation, normalized by default
* @param rad radius of rotation
*/
public static rotateAround<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, rot: Out, axis: VecLike, rad: number) {
// get inv-axis (local to rot)
Quat.invert(qt_1, rot);
Vec3.transformQuat(v3_1, axis, qt_1);
// rotate by inv-axis
Quat.fromAxisAngle(qt_1, v3_1, rad);
Quat.multiply(out, rot, qt_1);
return out;
}
/**
* @en Sets the out quaternion to represent a radian rotation around a given rotation axis in local space
* @zh 绕本地空间下指定轴旋转四元数
* @param axis axis of rotation
* @param rad radius of rotation
*/
public static rotateAroundLocal<Out extends IQuatLike, VecLike extends IVec3Like&g