Math node
Direction to Rotation
Turns a direction vector into degrees in Grafit's rotation convention (positive = clockwise) — cable Distance's Direction or Delta straight into any Rotation port. Zero At: Up reads like a compass bearing ((0,1) → 0°, (1,0) → 90°), Right zeroes on +X. The input needn't be normalized — Length reports its magnitude, so Delta gives aim AND distance in one node. Pitch adds the 3D elevation (−90…90°). A zero vector holds the last rotation instead of snapping to 0.
Inputs
| Port | Type | Default |
|---|---|---|
| DirectionThe vector to aim by — Distance's Direction or Delta, a point, [x, y, z] numbers. It need NOT be normalized: only the proportions set the angle, and Length reports the magnitude. A zero vector HOLDS the last rotation instead of snapping to 0. | structure | — |
| Zero AtWhere 0° points. Up (default) reads like a compass bearing — (0,1) → 0°, (1,0) → 90°, (0,-1) → 180° — exactly what an arrow drawn pointing up needs. Right zeroes on +X. Both count clockwise, like every Grafit rotation. | int | 0 |
| RangeOutput wrap: 0–360 (always positive) or ±180 (signed, smallest turn from zero). Rotation ports accept both; ±180 is handier for math on the angle. | int | 0 |
| OffsetDegrees added before the wrap — align artwork whose natural orientation isn't the zero direction (an arrow drawn pointing right wants −90 with Zero At Up). | float | 0 |
Outputs
| Port | Type |
|---|---|
| Rotation | float |
| Radians | float |
| Pitch | float |
| Length | float |
How It Works
Direction to Rotation is the bridge from a vector to every Rotation port in Grafit. It reads a direction and returns degrees in the house convention — positive is clockwise — so the number can be cabled straight into any rotation knob without a Remap or a sign flip.
Zero At decides where zero points. Up reads like a compass bearing: (0, 1) is 0°, (1, 0) is 90°. That is exactly what an arrow drawn pointing up needs in order to aim along a direction, which is why the Points Visualize Arrow shape uses the same zero. Right zeroes on +X, the mathematical convention.
The input need not be normalized: Length reports its magnitude, so cabling Distance's Delta into one node yields the aim and the distance at once. Pitch adds the 3D elevation from −90° to 90°, and Radians is the same angle for anything that prefers them.
A zero vector holds the last rotation rather than snapping to 0 — coincident points must not spin the target.
Use Cases
- A field of aimed arrows — Direction per point into Points Visualize's Rotation array, with the Arrow shape: every dart points along whatever you measured.
- Look at the hand — Distance between a tracked hand and an object → Direction → this node → the object's Rotation.
- Velocity as heading — A particle's or a tracked point's velocity vector becomes the rotation of the sprite that rides it.
- A compass — Zero At: Up makes the output read as a bearing, ready for a Value Text caption.
- 3D aiming — Pitch and Rotation together aim a mesh, a light or a camera at a moving target.
Tips
- Grafit's rotation is clockwise-positive; that is already handled here, so do not negate the result.
- Use Length instead of adding a second Distance node — one cable from Delta gives both.
- The hold-on-zero behaviour means a target that momentarily coincides with the source will freeze the aim rather than snap it to zero. That is deliberate.
- For the reverse trip — degrees into a unit vector — use Math Expression with sin and cos, remembering the clockwise sign.
Open Direction to Rotation in the interactive catalog →
Direction to Rotation is one of 381 nodes in Grafit Pro.
Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.