Maya sine function

As we all know, Maya still does not have a built in node for a sine function, or any other kind of trig. The closest it has, as far as I know, is the sine Deformer, or just putting a locator in a rotating transform - both of these methods require the answer to be found physically in the scene.
This CANNOT be the best way to do things, so I’d like your help to find it. Out of these, which will be the most efficient, when hundreds are used in the scene:
-Previous spatial methods
-Writing a simple sine expression
-Coding your own
-Using an animcurve as a lookup table to approximate sine values

As I understand it, the animcurve is the only one which does not actually calculate the value, it just looks it up (assuming the curve itself does not change) - would that be the best way?

Thanks

I don’t know the best way. I’m not against reading the rotation of a transform if it works.

I just wanted to let you know that remapValue nodes look up the value along a range too, rather than using an animCurve. And you can animate or drive the positions and values of the curves.

For example, the attributes in a PyMEL example, where the 0 and 1 indeces are the points of the curve. You can can connect and drive them and get some pretty cool effects.

remapNode = pm.createNode('remapValue')
remapNode.value[0].value_Position
remapNode.value[0].value_FloatValue
remapNode.value[0].value_Interp

remapNode.value[1].value_Position
remapNode.value[1].value_FloatValue
remapNode.value[1].value_Interp
1 Like

FWIW an expression with a single float input and output is the simplest way – there’s an incremental speed loss compared to a C++ node, but the likelihood that actually affects your seen on a modern machine is very slim.

1 Like

I would say an expression is probably best choice, without knowing the exact specifics of the setup in question.

If you can deploy custom nodes I would suggest my library:

1 Like

Also node “eulerToQuat” can be used to calculate a sine result. Angle input to node “eulerToQuat” should be pre-multiplied by 2, then result is the same as sin(Angle).

5 Likes

That’s amazing! It’s exactly what I need, I can’t believe more people don’t know about this. Thanks!

Your welcome! It’s just maths, but yeah finding way to apply it in Maya can be tricky sometimes :slight_smile:
One more thing to note is that to get exact sine of angle using “eulerToQuat” node, better to use no more that one input to “inputRotate”, while keeping other inputs set to 0 (or ℤ*720, where ℤ is any of Intergers).

Also has the handy characteristic of giving both sine and cosine as outputsX and W for a single input angleX.

2 Likes

Amazing hot tip right here, thanks Karolis!

I can’t locate this node in maya 2017… I’m using createNode method but get an unknown node instead.

Make sure to load the “quatNodes” plugin.