[Interest] Rotating leaves
kshegunov at gmail.com
Sun Apr 1 11:48:12 CEST 2018
What Bin Chen wrote is probably the most painless way of achieving what you
want. If you are however interested in the math, here goes my stab:
If I understand you correctly, you know the leaf normal, and the branch
direction vector, then you're searching for the matrix that transforms the
former to the latter.
Basically you need to find the matrix that satisfies: b = A * n (b is the
branch direction, n is the leaf normal).
This equation however is underdetemined, meaning you can have several
rotations done in sequence that give you the same result, so you'd need to
do some "trickery". One of the usual ways to solve such a problem is to use
Euler angles, where the idea is to make elemental rotations with respect
to the principle axes of the (global) coordinate systems. To that end you'd
need to calculate the projections (i.e. dot products) of b and n to the
principal axes and extract the angles of rotation from there, then
construct each rotation matrix around a principal axis of the coordinate
system and finally multiply them to obtain the final transformation.
I hope that helps.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest