acos
Given a ratio, get the angle
- value
- FLOAT
The angle whose cosine is your number
Cosine answers "given an angle, what's the ratio?" - acos (arc cosine) goes the other way: given a ratio, what's the angle? It's the trig function you reach for when you know a direction component and need the angle back out. In a ComfyUI workflow that's the kind of math you do when you're working out rotations, camera angles, or geometry for positioning - the situations where you don't want to crack open a calculator, you want a node.
This is one of the pack's math utilities, sitting under Basic/maths in the node browser. It's a thin wrapper around Python's math.acos() with a genuinely useful addition: you pick whether the answer comes back in degrees or radians.
How it works
The node computes acos(value) and, if you've selected degrees, converts the result with math.degrees() before handing it over. Default unit is degrees, which is what you want 95% of the time - radians are for when you're feeding the result straight into another math node that expects them.
The one rule that bites people: the input must be between -1 and 1. The cosine of any real angle is always in that range, so if you feed acos(2) you get a domain error - there is no real angle whose cosine is 2. Keep your inputs within [-1, 1] and you're safe. Output range is 0° to 180° (or 0 to π in radians).
Like the other math nodes here, the value field is a text input that takes an exact number (it's float()-parsed) - 0.7071 is fine, an expression like sqrt(2)/2 is not. For computed inputs, wire the result of another node into value rather than typing math.
Inputs and outputs
- value (FLOAT or INT, default
0) - a number between -1 and 1. - unit (enum, default
degrees) -radiansordegreesfor the output.
Output is a single FLOAT: the angle whose cosine is the input.
Installing it
Part of Basic data handling by StableLlama - the r/StableDiffusion regular known for deep model comparisons (Flux Klein 9B, RealVisXL) rather than code. The pack is featherweight: zero runtime dependencies, no model files, no GPU work.
Install via ComfyUI Manager (search "Basic data handling") or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI; it's under Basic/maths.
Troubleshooting
The domain error is the classic stumble: value outside [-1, 1] won't compute, and the error message is a bare Python math domain error, which reads like the pack is broken when it isn't. Clamp your input first if it might drift out of range. Second: if your downstream node works in radians but you left the unit on degrees, your angles will be off by a factor of ~57.3 - check the unit dropdown before you chase a phantom bug.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value | FLOAT,INT | 0 | — |
| unit | COMBO | degrees | 2 options: radians, degrees |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | — |