D3DXMatrix旋转轴旋转错误的轴
D3DXMatrixRotationAxis rotate the wrong axis
我正在用directX编写简单的3D应用程序。我是一个新手,但我想我了解 D3DX 旋转的工作原理。 在创建碰撞检测功能时,我注意到球以错误的方向反弹。代码应更改"方向"矢量中给定的轴的方向。相反,它更改了其他 2 个:
speed = D3DXVECTOR3(1.0f, 2.0f, 3.0f);
direction = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
D3DXMATRIX temp;
D3DXMatrixRotationAxis(&temp, &direction, 3.14f);
D3DXVec3TransformCoord(&speed, &speed, &temp);
从断点我知道速度从 1、2、3 变为:
- _D3DVECTOR {x=0.999999762 y=-2.00477481 z=-2.99681091 } _D3DVECTOR
我在这里做错了什么?这个想法是反转方向矢量中指定的轴。
您已经创建了围绕 X 轴的 180 旋转变换。 在 (1,2,3( 上操作会产生 (1,-2,-3(,这是您指定的。
用具有法线 N 的平面"弹跳"您的"速度"S 向量:
angle = acos(S*N); // provided that * is an operator for D3DXVec3Dot
axis = S^N; // provided that ^ is an operator for D3DXVec3Cross
D3DXMatrixRotationAxis(&temp, &axis , angle*2); // angle is *2
D3DXVec3TransformCoord(&S, &S, &temp);
S=-S; // negate direction
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- 我的旋转数组代码给出了大数组大小的错误
- D3DXMatrix旋转轴旋转错误的轴
- 四元数旋转错误
- 旋转数组 - 错误
- 直接相机旋转的错误控制
- AVL树双重旋转错误
- GLM::旋转似乎会导致错误的旋转
- 有人能在我的代码中找到矩阵旋转的错误
- 旋转实现错误
- boost::几何多边形的 outer() 在多边形旋转后有错误的坐标