<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi, Igor, 
<div class=""><br class="">
</div>
<div class="">To get a rotation quaternion from a vector to the other, in your case, the leave normal(0,1,0) and the branch direction (-1, 0, 0), I would use </div>
<div class="">QQuaterion::rotationTo(QVector3D(0, 1, 0), QVector3D(-1, 0, 0)).</div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class=""><br class="">
</div>
<div class="">Bin</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 1 Apr 2018, at 2:45 am, Igor Mironchik <<a href="mailto:igor.mironchik@gmail.com" class="">igor.mironchik@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div text="#000000" bgcolor="#FFFFFF" class="">
<p class="">Vectors are normalized.<br class="">
</p>
<br class="">
<div class="moz-cite-prefix">On 31.03.2018 19:44, Igor Mironchik wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:8524cee9-25b6-1cbf-8dfd-e7e016d087ef@gmail.com" class="">
<p class="">Hi,</p>
<p class="">Sorry for the inaccuracy...</p>
<span id="cid:part1.DCF2957C.DC7C9B05@gmail.com"><20180331_194006.jpg></span><br class="">
<div class="moz-cite-prefix">On 31.03.2018 12:44, Igor Mironchik wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:ef3d47c5-12ba-1a66-81f3-1d016f3fbeb9@gmail.com" class="">
<p class="">Hi,</p>
<p class="">Not sure how, but I did:</p>
<p class="">static inline bool lessZero( const QVector3D & v )<br class="">
{<br class="">
    return ( v.x() < 0.0f || v.y() < 0.0f || v.z() < 0.0f );<br class="">
}</p>
<p class=""><br class="">
</p>
<p class="">... Sorry for skipped code, just hope that I'm clear.<br class="">
</p>
<p class=""><br class="">
</p>
<p class="">if( lessZero( branch ) )<br class="">
        plainAngle = -plainAngle;</p>
<p class=""><br class="">
</p>
<p class="">And seems that with inverting angle of rotation of leaf's plain to branch on less zero components in branch vector always set leaf perpendicularly to branch. Could anybody explain the math here, please?</p>
<p class="">Not sure in this solution but it works :)<br class="">
</p>
<br class="">
<div class="moz-cite-prefix">On 31.03.2018 11:00, Igor Mironchik wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:0dc52dc9-1213-74cf-5921-e5509b2e107f@gmail.com" class="">
<p class="">Hello,</p>
<p class="">The task is simple on one side and complicated on another. I need to rotate a leaf around a branch to make leaf perpendicular to branch.</p>
<p class="">In theory all is simple...</p>
<span id="cid:part2.C6FE7358.E36170C7@gmail.com"><20180331_104936.jpg></span><br class="">
<br class="">
Great. In the code I have...<br class="">
<br class="">
const QVector3D branch(...);<br class="">
const QVector3D leaf( 0.0f, 1.0f, 0.0f );<br class="">
const QVector3D axis = QVector3D::crossProduct( branch, leaf );<br class="">
const float cosPlainAngle = QVector3D::dotProduct( branch, leaf );<br class="">
const float plainAngle = qRadiansToDegrees( std::acos( cosPlainAngle ) );<br class="">
const QQuaternion quat = Qt3DCore::QTransform::fromAxisAndAngle( axis, plainAngle );<br class="">
m_transform->setRotation( quat );<br class="">
<br class="">
But it works correctly not in all situations. In some cases I need to increment plainAngle by 90.0 degrees.<br class="">
<br class="">
So my question is what should I care in the code to handle all situations correctly?<br class="">
<br class="">
Thank you.<br class="">
</blockquote>
<br class="">
</blockquote>
<br class="">
</blockquote>
<br class="">
</div>
_______________________________________________<br class="">
Interest mailing list<br class="">
<a href="mailto:Interest@qt-project.org" class="">Interest@qt-project.org</a><br class="">
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.qt-2Dproject.org_mailman_listinfo_interest&d=DwICAg&c=-0XTxx5JZxtPyuSXdvX8qQ&r=_JxpcpJpSMrVwuVMK05qMw&m=R-OlZxgObG558WAzim2UDFNCM-g-6GCfsB8tcwXf54s&s=YmBmeODv8jueT9scHHt5smTmtq-6765c2jqCxwK2ew8&e=<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then
 delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986.   ­­ 
</body>
</html>