Thingiverse
Quaternions for OpenScad
door WilliamAAdams
57
Downloads
60
Likes
0
Makes
Having some basic Matrix math operations available in OpenScad has been a wonderful thing. I found my life to be somewhat lacking though because rotations are a royal pain in the...
This thing adds Quaternion support to OpenScad
Besides sounding like a cool name for an 80s rock band, or a futuristic diabolical planetary leader, quaternions are a math construct that make doing rotations a fairly painless task.
basically: myquat = quat(axis, angle);
So, to do a 30 degree rotation around the z-axis for example, would look like this:
rotz = quat([0,0,1], 30);
Now, that's not going to do you much good in OpenScad by itself, so you need to turn it into a matrix that OpenScad can easily consume and apply as a transform, so you do this:
rotzmatrix = quat_to_mat4(rotz);
Once you have this, you can use it with multmatrix()
multmatrix(rotzmatrix);
or
multmatrix(quat_to_mat4(quat([0,0,1],30)));
Ok, so wow, big deal!!
OK. So, combinations can be done like t
This thing adds Quaternion support to OpenScad
Besides sounding like a cool name for an 80s rock band, or a futuristic diabolical planetary leader, quaternions are a math construct that make doing rotations a fairly painless task.
basically: myquat = quat(axis, angle);
So, to do a 30 degree rotation around the z-axis for example, would look like this:
rotz = quat([0,0,1], 30);
Now, that's not going to do you much good in OpenScad by itself, so you need to turn it into a matrix that OpenScad can easily consume and apply as a transform, so you do this:
rotzmatrix = quat_to_mat4(rotz);
Once you have this, you can use it with multmatrix()
multmatrix(rotzmatrix);
or
multmatrix(quat_to_mat4(quat([0,0,1],30)));
Ok, so wow, big deal!!
OK. So, combinations can be done like t
Heb je dit model geprint? Inloggen en deel je make!
Log in om een reactie achter te laten
InloggenNog geen reacties – wees de eerste!