| **Calculating angle from two points**
on Jun 4, 2017 at 8:19:10 pm |

As everyone knows, using the ol' Gradient Ramp effect gives you two point controls for the start and end of your ramp.

I need to use a different gradient effect that only has one point control and an angle control.

What would be an expression to derive an angle value based on the two point controls?

| **Re: Calculating angle from two points** on Jun 5, 2017 at 4:19:48 pm |

Math.atan2(y,x) is the function that you are looking for.

to get an angle from the ramp effect's start and end points, try this:

`L = thisComp.layer("Layer with Ramp Effect");`

p1 = L.effect("Gradient Ramp")("Start of Ramp");

p2 = L.effect("Gradient Ramp")("End of Ramp");

p = p2 - p1;

radiansToDegrees( Math.atan2( p[1], p[0] ) );

depending on where you want zero degrees to start, you may need to add or subtract 90 degrees (currently zero is pointing right)

Kevin Camp

Art Director

KCPQ, KZJO & KRCW