matrix math help : aligning 2 vectors using dihedral

   1212   3   1
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
i have 2 line segments ( with multiple points ) . i want to match the shape of line1(source) to line2(target).

so i calculate the vector between pt1 and pt0 and use a dihedral to rotate the source line to match the target.

it works in a test about the origin.... but when they are out in world space it doesnt quite work.

ps : new to matrices in houdini.

here is a simple test


ps2: what i eventually want to do is match target's shape to source, segment by segment so the illusion of unrolling

Attachments:
dihedral_rotation.hipnc (108.6 KB)

User Avatar
Member
406 posts
Joined: April 2017
Offline
When you're doing anything involving rotations, you need to keep the pivot in mind. If you're just multiplying points by a 3x3 matrix, the assumption is that you're rotating about the origin. If that's not what you want, what you need to do is subtract some value from P so that the point you want to rotate around is at the origin, then multiply by your matrix, then add that same value you subtracted back to P.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
Hi Toadstorm !

that makes a lot of sense.. that the mat3 rotation is about the origin.

in my case..i guess i have to convert mat3 to matrix(4) and pass on the pivot to rotate ? is that right ? or is it even possible ?

ps: thanks for the reply !
User Avatar
Member
406 posts
Joined: April 2017
Offline
You could go about it that way if you wanted, but really it's probably easier to just subtract some value V from P so that your pivot lies at the origin, then multiply P by your 3x3, then add V back to P and you're done. The exact value for V depends on what you want to rotate around.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
  • Quick Links