tan
The trig node that knows when it's undefined
- angle
- FLOAT
Tangent is sine divided by cosine - and because cosine hits zero at 90°, 270°, and every 180° after that, tangent is undefined at those angles. Most math nodes would just let that blow up into a cryptic division-by-zero. The tan node from Basic data handling actually catches it and tells you, in plain words, "Tangent is undefined at this angle (division by zero)." It's a small thing, but it's the difference between a readable error and an hour of debugging.
For what it's worth, that's the kind of attention to edge cases that makes this pack pleasant to use - it was clearly written by someone who hit these errors themselves.
How it works
Like sin, the node wraps Python's math.tan() and adds a unit dropdown:
angle- FLOAT or INT, default0.unit-radiansordegrees(defaultdegrees). Pick degrees and it converts internally before computing.
Output is a single FLOAT. Unlike sine and cosine, tangent has no fixed range - it runs from -∞ to +∞ and passes through 0 at every multiple of 180°.
The one real gotcha: the vertical asymptotes
tan(90°) and tan(270°) (and -90°, 450°, ...) don't exist. The node raises a ValueError for exactly those angles - it checks whether cosine is effectively zero and refuses rather than returning a nonsense float. Two practical consequences:
- Don't feed a schedule that lands on 90°. If your angle counter can hit
90or270exactly, the node will throw. Nudge the range, or clamp it slightly off the asymptote. - Tiny angles near the asymptote are fine but huge.
tan(89.9°)is around 573. That's mathematically correct, but it means a small wobble in your input produces enormous output swings. If you're using tangent for a smooth wave,sinorcosis usually the saner choice - tangent is better for ratios and slopes than for oscillation.
Where you'd reach for it
Tangent is the ratio of opposite to adjacent - so it's the natural fit for computing slopes, angles from aspect ratios (atan is the inverse for that), or any geometry where you have two sides and want the angle or the pitch.
Installing it
Basic data handling is a zero-dependency pack: no models, no pip installs. ComfyUI Manager → search "Basic data handling" → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart, and tan is under Basic/maths next to sin and cos.
The take
You'll use sin and cos more, full stop. But when tangent is the right tool, this is the version that fails helpfully instead of cryptically - and that alone justifies the node existing.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| angle | FLOAT,INT | 0 | — |
| unit | COMBO | degrees | 2 options: radians, degrees |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | — |