<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div><font color="#000000">Hi Sebastian,</font></div><div><font color="#000000"><br></font></div><font color="#000000">> </font>Usually you use an cosine-matrix for this. It allows to determine the quaternion which translates one coordinate frame <div>>(i.e. 3 independent vectors) into another, but I think osg doesn't have this.</div><div><font color="#000000"><br id="FontBreak"></font>Does anybody can confirm also that there is not a feature like that in osg? These 3 vectors may seem that they are independent </div><div>but actually they are dependant, because knowing any 2 of them you can always get the 3rd one with cross product of first two.</div><div>So any modifications on one of them affects others as well.</div><div><br></div><div>>I think you can use the makeRotate by applying the resulting quaternion to the vec3(0,0,1) and (1,0,0) </div><div>> and using the makeRotate with the results somehow to get the inverse. </div><div>I already tried that without succes, the glitch here is at the bare minimum I have to define 2 vectors (up/direction, up/right, direction/right </div><div>etcc combinaton) but I don't how to combine those two into a quaternion ? </div><div><br></div><div>I forgot to mention that I get plenty of following errorson console screen, when I assign direction vector, this happens when I try </div><div>to pan, move, zoom of whole scene. Could that be the source of discrepancy ? <span style="font-size: 12pt;"> </span></div><div><br></div><div>CullVisitor::apply(Geode&) detected NaN,</div><div> depth=nan, center=(0 -2.5 0),</div><div> matrix={</div><div> nan nan nan nan</div><div> nan nan nan nan</div><div> nan nan nan nan</div><div> 35 -35 0 1</div><div><span style="font-size: 12pt;">}</span><span style="font-size: 12pt;"> </span></div><div><br><div><hr id="stopSpelling">Date: Thu, 2 Jul 2015 19:25:34 +0200<br>From: sebastian.messerschmidt@gmx.de<br>To: osg-users@lists.openscenegraph.org<br>Subject: Re: [osg-users] Orientating model in 3D space with quaternions<br><br>
Hi Sonya, <br>
<br>
Usually you use an cosine-matrix for this. It allows to determine
the quaternion which translates one coordinate frame (i.e. 3
independent vectors) into another, but I think osg doesn't have
this.<br>
I think you can use the makeRotate by applying the resulting
quaternion to the vec3(0,0,1) and (1,0,0) and using the makeRotate
with the results somehow to get the inverse. <br>
<br>
Cheers<br>
Sebastian <br>
<blockquote cite="mid:DUB124-W52BBE6C1AEFC52F5E7E3A5C8970@phx.gbl">
<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}
.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}
--></style>
<div dir="ltr"><font size="2" color="#000000">Dear All,</font>
<div><font size="2" color="#000000"><br>
</font></div>
<div><font size="2" color="#000000">I load a model with the
following code in my program, p1 and p2 are osg::Vec3 type
variables and simply representing</font></div>
<div><font size="2" color="#000000">the each ends of object in
spatial space ( I also use them to find the direction
vector). What I want to achive is: to place </font></div>
<div><font size="2" color="#000000">that model </font><font size="2" color="#000000">up vector always aligned facing
upward ( this doesn't mean that it must coincidence/be
parallel with global </font></div>
<div><font size="2" color="#000000">Z axis) to achieve that If
I apply the quaternions then </font><span style="font-size:10pt;">object is positioned with correct direction vector
(calulated via </span></div>
<div><span style="font-size:10pt;">p1, p2) but rolled with
arbitrary angle along that direction </span><span style="font-size:10pt;">vector, which violates my
conditional goal.</span></div>
<div><span style="font-size:10pt;"><br>
</span></div>
<div><span style="font-size:10pt;">It also seems that it's not
a supprise that it produces that result bcoz nowhere I
specify the crucial right or up vector with </span></div>
<div><span style="font-size:10pt;">quaternion which is required
to position the object in 3D space. So </span><span style="font-size:10pt;">How am I supposed to correct that
effect either with </span></div>
<div><span style="font-size:10pt;">quaternions or matrices ? </span></div>
<div><font size="2" color="#000000"><br>
</font></div>
<div><font size="2" color="#000000">
<div> loadedModel =
osgDB::readNodeFile("quad.obj");</div>
<div> osg::Vec3Array* verlist=
static_cast<osg::Vec3Array*
>(rubber_line->getVertexArray());</div>
<div> osg::Vec3 p1 = (*verlist)[0];</div>
<div> osg::Vec3 p2 = (*verlist)[1];</div>
<div><br>
</div>
<div>
osg::ref_ptr<osg::PositionAttitudeTransform> Transf
= new osg::PositionAttitudeTransform;</div>
<div> Transf->setPosition( p1 );</div>
<div><br>
</div>
<div> osg::Quat quad;</div>
<div> osg::Matrix matrix, mat2;</div>
<div><br>
</div>
<div>
quad.makeRotate(osg::Vec3(0,1,0),p2-p1);</div>
<div><br>
</div>
<div><span style="font-size:10pt;">
Transf->setAttitude(quad);</span></div>
<div> Transf->addChild(loadedModel);</div>
<div> rootnode->addChild(Transf);</div>
<div><br>
</div>
<div><br>
</div>
</font></div>
</div>
<br>
<fieldset class="ecxmimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
osg-users mailing list
<a class="ecxmoz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
<a class="ecxmoz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a>
</pre>
</blockquote>
<br>
<br>_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</div></div> </div></body>
</html>