I have a vector A that continuously varies direction using simulation nodes. I try for vector B to always point antiparallel to A. My idea was to calculate the angle between vector A and B using the following formula:

enter image description here

To rotate B in the opposite direction, I thought to subtract the answer from 180 and then use this result as the rotation angle in a vector rotate node. However, I get stuck, because I don't know the correct settings of the vector rotate node.

I now have the following node tree:

enter image description here

Is it possible to use this method or should it be done in a different way? Thanks in advance :)

  • 2
    $\begingroup$ I can't understand what you are trying to achieve. What does it mean, antiparallel? To reverse vector in opposite direction, just multiply it by (-1,-1,-1) $\endgroup$
    – Crantisz
    Apr 13 at 19:46
  • $\begingroup$ It means pointing in opposite direction. I don't want te reverse vector A in opposite direction but rotate B in the opposite direction of A. $\endgroup$
    – EwSa
    Apr 13 at 19:54
  • $\begingroup$ @Crantisz perhaps EwSa wants a rotational motion towards the desired vector, rather then immediately switching there. Without a rotational motion all you need is to use a Mix node to lerp, but for rotational take current vector and target vector to produce a cross product. This cross product is the axis of rotation in the Vector Rotate node (custom axis). Then rotate by some small angle, but remember to clamp the angle to at most current angle difference to avoid oscillating around that vector. $\endgroup$ Apr 13 at 19:55
  • $\begingroup$ @MarkusvonBroady: tnx for your reply. To make it more clear: I have a velocity and a drag force. The drag force has to turn in the opposite direction of the velocity. The velocity could change direction so the drag force has to turn with it. I've tried the cross product of both vectors but this gives indeed the oscillating problem. Can you make clear what you mean with "clamp angle to at most current angle difference"? $\endgroup$
    – EwSa
    Apr 13 at 20:01
  • $\begingroup$ If you want it to behave physically with velocity etc. then you will get oscillation. The way oscillation is solved in simulations is just some kind of resistance usually simulated as simply multiplying the velocity by almost $1$ on each step, e.g. $0.99$ or $0.95$. This will still make an oscillation, just that the oscillation will die off. Otherwise you can base the resistance on the angle left, so with $1°$ left the multiplier would be $0.01$ $\endgroup$ Apr 13 at 20:06

1 Answer 1


the equation works. however, you are doing it wrong. (edit: looking back, you actually followed it correctly, except the fact that you converted it to degrees when you should of kept it as radians)

The equation

means A dot B, each divided by it's length, which is the same as normalizing them, so this is your equation: dot_product(normalize(A),normalize(B)), and then then take the arccosin, so: angle = arccosin(dot_product(normalize(A),normalize(B))). this will still leave you with the problem of no difference between negative and positive, so you compare the angles. so do something like this

I grabbed this image off discord since I'm not at pc; I hope it's good enough. instead of tangent use whatever axis you want (the axis is: around what axis are you measuring the angle around)

simple answer

in truth there is already a node that does this in all 3 directions, and it's called align Euler to vector. (you might have to do some extra steps to get it to work exactly as you want, though.)


Here is a simpler way (removing unnecessary operations and nodes) of the image above: ![![enter image description here and if you to compare the angle and rotate it around a specific axis do this: enter image description here

  • $\begingroup$ Tnx! This works like a charm :) $\endgroup$
    – EwSa
    Apr 20 at 18:39
  • $\begingroup$ And looks like a definitive reference for future questions like this one :) $\endgroup$
    – Robin Betts
    Apr 26 at 7:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .