-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Quaternion nodes #2341
Add Quaternion nodes #2341
Conversation
5952e2c
to
3d6842c
Compare
As you notice.. I decided to make the Quaternion In node mode based (to switch input formats).. where the input given to the node to convert into a quaternion can have various formats (wxyz components, euler angels, axis+angle and matrix). It can be argued (based on recent conversations) that is preferred to have simpler nodes that do one, simple function, and thus perhaps make 4 “Quaternion In” nodes that generate quaternions based on different inputs. The second school of thought (which i prefer in this case) is to keep the number of nodes to a minimum by making one node with 4 modes (as proposed). If anybody feels strongly about this proposal feel free to comment, brainstorm etc. |
For the Quaternion Out node I decided to show all possible components that users may want to get out of a quaternion with all outputs visible. The components are calculated of course only for the connected outputs. An alternative implementation could provide a “mode” similar to the QIN node and have the user select the kind of output they desire to read (Matrix, Components, Axis-Angle, Euler, Magnitude etc). (though perhaps magnitude can be made part of the QMath node a separate function, similar to what the vector math does). With a mode option, the visible output nodes will only the ones corresponding to the selected mode. Personally I don’t see a huge benefit of hiding output socket, but if anybody feels strong against it I can cleanup the output interface by adding a mode. Thoughts ? |
What about using data structure of quatarnions from mathutils library without conversion to list, like we do with matrix now? |
@Durman I was going to ask about it :) it is beneficial to have it as mathutils Quaternions directly and I can certainly remove all the tuple()’s around the output. This would save having to convert back and forth from list to quaternions to do Q operations. The only reason why I didn’t do it was because a Quaternion is closer relative to a Vector than a Matrix (structure wise).. and for vertices we don’t have output as Vector(0,0,0). But to your point, maybe we should have vertices also output mathutils Vector instead of list? If the Stethoscope output becomes too verbose having the extra type displayed (Vector, Quaternion, Matrix etc) then perhaps the Stethoscope node could be smarter about it and have an option to not display the type but only the value. If nobody objects I’ll switch the output to mathutils Quaternion. |
e3b4527
to
5dfe245
Compare
51af93f
to
39528f9
Compare
Here’s the latest UI for Quaternion IN/OUT nodes. I added “mode” to QOUT node as well to cleanup the interface and make it similar to its QIN counterpart. Also now the QOUT node outputs Euler angles as well. Note: For the angle units in introduced an additional “UNI” mode, which is a 0-1 angle unit (1 = one cycle = 2pi = 360 degree angle). Useful for cases when the input angle is driven by evaluators (e.g. Frame Info node) and avoids having to multiply by 2pi or 360 to get the angle in correct units. |
Well.. this PR is pretty much done and ready to be merged. Speak now or forever... :) |
96418f5
to
a592193
Compare
- add 3 nodes: Quaternion In, Quaternion Out and Quaternion Math Quaternion In: Provides conversion from various quaternion components to quaternions (selectable via the mode option): - components wxyz - angle + axis - euler angles - matrix Quaternion Out: Provides conversion from quaterions to various quaternion components (selectable via the mode option): - components wxyz - angle + axis - euler angles - matrix Quaternion Math: Provides various quaternion arithmetic operations: ADD SUB MULTIPLY DIVIDE ROTATE DOT DISTANCE NEGATE CONJUGATE INVERT NORMALIZE SCALE MAGNITUDE Note: some operations take multiple quaternion inputs (input list grows as new sockets are connected), two quaternion inputs, single quaternion inputs, or quaternion + scalar input.
a592193
to
57106ac
Compare
ok, updated from github, find out this nodes, searched how to use quaternions, find book on market, bought it. This chain anyway not solving my understanding of quaternions. Also book is more as math history, not math itself. But i see, we can rotate anything anyhow now. |
@nortikin Sorry for your frustration :) It's not clear yet the real use of these nodes, but I suspect we'll learn as we go and discover if they were as useful as anticipated. What book on quaternions did you get, btw? Also, note that there is a whole subset of nodes currently missing that are needed to complete the quaternion (4D Vector) domain, such as the 4D Matrices (5x5) which are to operate on 4D vector (quaternions) space the same way as the 3D Matrices (4x4) operate on 3D vector space. Some I already started developing (emerged from the hypercube PR I started a while back) and still need some more developing before I can push them in a PR (the nodes marked with a green bullet). Perhaps once you can operate on 4D space with more power (4D Matrices) the quaternion nodes could become more useful. In the meantime, of course, since normalized quaternions map to 3D rotation matrices they can definitely be used to do 3D rotations (as well as SLERP in conjunction with the MixInput nodes). |
this book is Ian Stewart 'calculating the cosmos' and 'professor stewart's cabinet of math curiosities', not quaternions and ordered his 'symmetry' book |
To start with, this adds 3 nodes (quaternion in, quaternion out and quaternion math nodes).
Quaternion In:
Provides conversion to quaternion from various format inputs (selectable via the mode option):
Quaternion Out:
Provides various components (conversion) from quaternion to various components:
(w,x,y,z) components, matrix, axis + angle, Euler angle
Quaternion Math:
Provides the essential quaternion arithmetic operations:
ADD
SUB
MULTIPLY
DIVIDE
ROTATE
DOT
DISTANCE
INVERT
NORMALIZE
CONJUGATE
NEGATE
SCALE
MAGNITUDE
Note: some operations take multiple quaternion inputs (input list grows as new sockets are connected), as well as single quaternion inputs, or quaternion + scalar input.
All three nodes :
Quaternion IN node:
Quaternion OUT node:
Quaternion MATH node: