Discussion:
[Opensg-users] OSG::Quaternion to OSG::Line ?
Gerlina Steffen
2014-07-26 17:35:39 UTC
Permalink
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>Hello.</div>

<div>I&#39;m new to OpenSG and have a question since i&#39;m working on the whole day without success :). I hope this is the right place to ask such a question, if not, please forgive me. I have searched a lot for for this but haven&#39;t found anything helping so far.</div>

<div><br/>
For my project I have the following things:</div>

<div>- A OSG::Quaternion which represents an input device (something similar to a Razer hydra)<br/>
- A OSG::Line to calculate intersections</div>

<div>&nbsp;</div>

<div>With the device I want to point onto things (something like a laser pointer) in my scene. Unfortunately, to calculate intersections OpenSG uses the OSG::Line class, so I need to translate my Quaternion into a Line. The position is no problem, but with the calculation from a rotation as a Quaternion to a direction as Vec3f I have problems.</div>

<div>To get my direction vector I use &quot;device.getEulerAngleRad(ray_direction)&quot;.</div>

<div>However the angles don&#39;t seem to be right. When I move my device left, my line goes &quot;up left&quot; for example. Somehow the transformation doesn&#39;t work completly. What am i missing? Or is there maybe even a better way to calculate intersections with my pointing device?</div>

<div>&nbsp;</div>

<div>Thank you.</div>

<div>Greetings,</div>

<div>Gekko</div>
</div></div></body></html>
Carsten Neumann
2014-07-27 07:55:59 UTC
Permalink
Hello,
Post by Gerlina Steffen
- A OSG::Quaternion which represents an input device (something similar
to a Razer hydra)
- A OSG::Line to calculate intersections
With the device I want to point onto things (something like a laser
pointer) in my scene. Unfortunately, to calculate intersections OpenSG
uses the OSG::Line class, so I need to translate my Quaternion into a
Line. The position is no problem, but with the calculation from a
rotation as a Quaternion to a direction as Vec3f I have problems.
To get my direction vector I use "device.getEulerAngleRad(ray_direction)".
I don't think that is the function you want, it decomposes the rotation
represented by the quaternion into euler angles and stores these angles
(in radians) in the vector.
You probably want something like Quaternion::multVec(src, dst), which
applies the rotation to the vector src and stores the transformed result
in dst.

Cheers,
Carsten

Loading...