Confuse about hkQuaternion and hkRotation
2015-08-17 06:46
459 查看
Hi guys
I really have some confuse about the hkQuaternion and hkRotation
1.First, I have a quat like this
[/code]
Then, I want use a hkRotation to instead of this quat,
[/code]
But when I get the new hkQuaternion from this hkRotation
[/code]
The new hkQuaternion is not the same like my initial hkQuaternion
I think I make sth wrong with this, but not know where and why.
2.How can I get the hkRotation from an exist hkQuaternion?
RSSTop
2 posts / 0 new
Last post
Best Reply
For more complete information about compiler optimizations, see our Optimization Notice.
Log
In to post comments
havokchrisk
Mon, 09/13/2010 - 11:31
BEST REPLY
Hey duotemplar,
To answer your questions:
It looks like your math might be a bit off in converting a facing direction into an orothogonal rotation matrix (currently it doesn't look like any axis of your matrix aligns with your quaternion-rotated axis). You might
try something like the following in place of lines 12-15 above:
[/code]
To convert an hkQuaternion inito an hkRotation, you could do something like this:
[/code]
Also, please note that there can be multiple values of an hkQuaternion that correlate to the same hkMatrix3... so there may be times when you start with one quaternion, convert it to a rotation matrix, perform operations on it such that it ends up in its original
rotation, convert it back to a quaternion, and you get a different quaternion from which you began. So the best way to verify the 'equality' of two quaternions is by using them to rotate a vector and checking the basic equality of the resulting vectors.
Chris
Developer Support Engineer
Havok
www.havok.com
I really have some confuse about the hkQuaternion and hkRotation
1.First, I have a quat like this
[code]1 | hkQuaternion quat; |
2 | quat.setAxisAngle(hkVector4(0, 1, 0), HK_REAL_PI / 4.0f); |
Then, I want use a hkRotation to instead of this quat,
[code]01 | hkVector4 offset; offset. set (1,0,0); |
02 | offset.setRotatedDir( quat, offset); |
03 |
04 | hkRotation rotation; |
05 | hkVector4& col0 = rotation.getColumn(0); |
06 | hkVector4& col1 = rotation.getColumn(1); |
07 | hkVector4& col2 = rotation.getColumn(2); |
08 |
09 | hkVector4 surfaceNorm; |
10 | surfaceNorm = hkVector4(0,1,0); |
11 |
12 | col1 = surfaceNorm ; |
13 | col2.setCross( col1, offset); |
14 | col2.normalize3(); |
15 | col0.setCross( col1, col2 ); |
But when I get the new hkQuaternion from this hkRotation
[code]1 | hkQuaternion temp;temp. set (rotation); |
The new hkQuaternion is not the same like my initial hkQuaternion
I think I make sth wrong with this, but not know where and why.
2.How can I get the hkRotation from an exist hkQuaternion?
RSSTop
2 posts / 0 new
Last post
Best Reply
For more complete information about compiler optimizations, see our Optimization Notice.
Log
In to post comments
havokchrisk
Mon, 09/13/2010 - 11:31
BEST REPLY
Hey duotemplar,
To answer your questions:
It looks like your math might be a bit off in converting a facing direction into an orothogonal rotation matrix (currently it doesn't look like any axis of your matrix aligns with your quaternion-rotated axis). You might
try something like the following in place of lines 12-15 above:
[code]1 | col0 = offset; |
2 | col1 = surfaceNorm; |
3 | col2.setCross(col1, col0); |
4 | col2.normalize3(); |
5 | col1.setCross(col0, col2); |
To convert an hkQuaternion inito an hkRotation, you could do something like this:
[code]1 | hkQuaternion quat; |
2 | hkRotation rot; |
3 | rot. set (quat); |
Also, please note that there can be multiple values of an hkQuaternion that correlate to the same hkMatrix3... so there may be times when you start with one quaternion, convert it to a rotation matrix, perform operations on it such that it ends up in its original
rotation, convert it back to a quaternion, and you get a different quaternion from which you began. So the best way to verify the 'equality' of two quaternions is by using them to rotate a vector and checking the basic equality of the resulting vectors.
Chris
Developer Support Engineer
Havok
www.havok.com
相关文章推荐
- GPIO Interfaces
- 寻找志同道合的伙伴
- WeakReference与SoftReference
- CODEVS 1069关押罪犯
- CODEVS 1067 机器翻译
- jQuery基础----24jQuery扩展-noConflict
- jQuery基础----23jQuery扩展-jQuery扩展
- jQuery基础----22jQuery AJAX-加载片段
- java finalize方法
- jQuery基础----21jQuery AJAX-异步访问
- PS------裁剪工具的使用
- 用NAN简化Google V8 JS引擎的扩展
- 用NAN简化Google V8 JS引擎的扩展
- 【Django】上传图片之路径问题
- 关于Win 10的隐私保护政策
- C++容器vector的调用
- codeforces 520 B. Two Buttons (bfs)
- 第一次在spark环境下运行jar包
- android(4) 使用ViewPaper 以及这几年来的一些感悟
- Java IO: ByteArrayInputStream