Functions
| Function | What it does |
|---|---|
add(a, b), sub(a, b), mul(a, b), div(a, b) | Item-by-item arithmetic on numbers or arrays. |
dot(a, b) | Dot product. |
cross(a, b) | Cross product of two 3-item arrays. |
length(a) | Length of an array (or the absolute value of a number). |
length(a, b) | Distance between two points. |
normalize(a) | The array scaled to length 1. |
degreesToRadians(d), radiansToDegrees(r) | Angle conversion. |
Arrays also work with plain operators: [1, 2] * 3, position + [10, 0].
Examples
// distance to another layer drives opacity
var d = length(position, thisComp.layer("Target").transform.position);
linear(d, 0, 500, 100, 0)
// point toward a layer
var v = sub(thisComp.layer("Target").transform.position, position);
radiansToDegrees(Math.atan2(v[1], v[0]))