Atan2 in patch editor

Hi, I always struggle with 3d transformation vector so I need some help to figure this out.
how to make atan2 operation in patch editor? I know we have that operation in script but I want this operation to be available in patch editor so I could make some patch asset with it.

My reference
I tried to create this atan2 patch based on this description from wikipedia:

and also from this video

The patch that I’m trying to create is a patch to make an object to always rotate/facing the forward direction based on the input position.
I get the direction vector by subtracting the current position by the previous frame position.
But now I need to use the atan2 to get the radian that will be converted to degree and pass it to the rotation transform of that object. (forward vector = Z positive, Up vector = Y positive, Right vector = X positive.)

My attempt:
I connected the conditional logic/rules to an option switch that drives the option slot for an option picker that picks the corresponding solution/calculation for each quadrant/conditional logics. Then the result goes to a radian to degree conversion to get the orientation but it didn’t work.

what confuses me is that i can’t tell whether i put the wrong formula, or it’s some inverted coordinate system thingy in spark that makes it failed. Can someone help me figure this thing out?

Atan2 already exists in patches, but it’s called Arctangent for some reason. It does accept 2 arguments, which is the main requirement.

Screen Shot 2022-07-28 at 10.51.48 AM

In most engines, all of this math this is abstracted by a method called lookAt() or something similar. It would be great if we had this in patches, but at least it’s available in script.

It might be hard to accomplish this in patches without quaternions, but I’m not sure. I think it’s more work than it’s worth. I’d say just use script to accomplish this for now, and submit a feature request :slight_smile:

1 Like