<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Am 03.07.2015 um 08:38 schrieb Sonya
      Blade:<br>
    </div>
    <blockquote cite="mid:DUB124-W35D1FB4B3665794C24012BC8960@phx.gbl"
      type="cite">
      <style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
      <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>
    </blockquote>
    Uhm, yes they are independent (a cross product actually produces an
    independent vector from two independent vectors ...), that what is
    called an orthonormal base.<br>
    And as there is more than one '3rd' vector forming an orthonormal
    base with the other two vectors, your roll is not well defined.<br>
    <blockquote cite="mid:DUB124-W35D1FB4B3665794C24012BC8960@phx.gbl"
      type="cite">
      <div dir="ltr">
        <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 ? <br>
        </div>
      </div>
    </blockquote>
    Simply multiply the resulting quaternions. <br>
    Or if you have the 3 orthonormal axes of your rotated model, use the
    direct cosine matrix. <br>
    See:<br>
    <a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/Direction_cosine">https://en.wikipedia.org/wiki/Direction_cosine</a><br>
    and <br>
<a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/Euclidean_vector#Multiple_Cartesian_bases">https://en.wikipedia.org/wiki/Euclidean_vector#Multiple_Cartesian_bases</a><br>
    <br>
    I'm using GMTL from <a class="moz-txt-link-freetext" href="http://ggt.sourceforge.net/">http://ggt.sourceforge.net/</a> for the math and
    convert it to osg, if this would be an option for you.<br>
    GMTL is header only, so it might be worth a try<br>
    <br>
    Cheers<br>
    Sebastian <br>
    <br>
    <blockquote cite="mid:DUB124-W35D1FB4B3665794C24012BC8960@phx.gbl"
      type="cite">
      <div dir="ltr">
        <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;">  <br>
          </span></div>
      </div>
    </blockquote>
    Seems like some dimension is calcuated to 0 or a division by zero
    happens. Hard to guess without debugging it. <br>
    <blockquote cite="mid:DUB124-W35D1FB4B3665794C24012BC8960@phx.gbl"
      type="cite">
      <div dir="ltr">
        <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: <a class="moz-txt-link-abbreviated" href="mailto:sebastian.messerschmidt@gmx.de">sebastian.messerschmidt@gmx.de</a><br>
            To: <a class="moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><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 color="#000000" size="2">Dear All,</font>
                <div><font color="#000000" size="2"><br>
                  </font></div>
                <div><font color="#000000" size="2">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 color="#000000" size="2">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 color="#000000" size="2">that model </font><font
                    color="#000000" size="2">up vector always aligned
                     facing upward ( this doesn't mean that it must
                    coincidence/be parallel with global </font></div>
                <div><font color="#000000" size="2">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 color="#000000" size="2"><br>
                  </font></div>
                <div><font color="#000000" size="2">
                    <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 moz-do-not-send="true" class="ecxmoz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
<a moz-do-not-send="true" 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
            <a class="moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a></div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
osg-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>