Cosine
Cosine, Radians vs. Degrees, and the First Real Trap in the Math Pack
- angle
- result
UC_MathCos computes the cosine of an angle and hands it back as a float. On its own that reads like high school homework, but in ComfyUI it's one of the standard ingredients for anything that moves or breathes: camera pans, zoom curves, oscillation in animated workflows, smooth easing between states. Cosine is how you get "starts slow, peaks, comes back" out of a number generator.
Why you'd reach for it
Animated and parametric workflows are where trig earns its keep. A cosine output oscillates smoothly between 1 and -1, which makes it a natural waveform for anything you want to cycle - pan an image side to side, drive a strength up and down over frames, ease a value in and out instead of snapping it. If you're building LoRA-strength sweeps or multi-frame sequences (and the pack's schedulers already live in that neighborhood), cosine gives you the smooth curve that a raw slider can't.
How it works
The mechanism is a thin wrapper around math.cos. The part that actually matters is the unit dropdown: it defaults to Radians - that's the real trap. If you type 90 expecting 0 (because you're thinking in degrees), you'll get roughly -0.448, because Python is interpreting it as 90 radians. Flip the unit to Degrees and 90 correctly returns 0. The node converts degrees to radians internally when you select that option, so the only thing you need to get right is the dropdown.
The inputs that matter
angle- a number, int or float.unit- Radians (default) or Degrees.
Output is a float named result, which you can feed into any FLOAT socket or chain into more math.
Installing it
Part of ComfyUI-UtilsCollection. Install via ComfyUI Manager (search "ComfyUI-UtilsCollection"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
Restart after. No models, deps are just opencv-python and typing-extensions.
The honest caveat
Unless you're doing animated or parametric work, cosine is one you'll rarely touch - it's a specialist, not a daily driver. But when you need it, nothing else in the pack does it, and the sibling UC_MathSin shares the same radians/degrees dropdown and the same gotcha. If you're importing an old ComfyUI-LogicMath workflow, accept the replacement prompt and uninstall LogicMath so the trig nodes don't collide. And if your sine or cosine "returns the wrong value," check the unit dropdown before you check anything else - it's the unit, almost always.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| angle | COMFY_MATCHTYPE_V3 | — | |
| unit | COMBO | Radians | 2 options: Radians, Degrees |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | FLOAT | — |