ComfyUI Node

Cosine

The smooth oscillator that makes animation actually feel alive

By silveroxides·Created 7 months ago·Updated 3 months ago· 3
Cosine
  • angle
  • result
unitRadians

The cosine node is the least glamorous node in your graph right up until you're animating a camera drift or a strength envelope, and then it's the whole show. Feed it a frame number, get back a value that glides smoothly between 1 and -1 and back again, forever. That one trick is most of what "organic-looking motion" means in ComfyUI animation.

It comes from silveroxides/ComfyUI-LogicMath, a small math-and-logic pack whose README is literally one sentence: "Logic operators and Math nodes based on a PR that never got merged." Same author runs the Chroma-GGUF quant pack on HuggingFace, which tells you something about the pedigree. The PR-upstream framing is accurate: these are utility nodes core ComfyUI never accepted, so they ship as an extension - and they're written against ComfyUI's newer V3 extension API (comfy_api.latest), not the old NODE_CLASS_MAPPINGS system.

How it works

Under the hood MathCos is a thin wrapper around Python's math.cos(). You give it an angle and it hands back the cosine as a FLOAT. The one piece of real logic is the unit dropdown:

  • Radians (default) - the raw math.cos() behavior, good for feeding frame numbers or loop counters straight in.
  • Degrees - converts your angle to radians first, so cos(90) behaves like you expect from math class.

This is the trap. The default is Radians, and if you're used to degrees (and who isn't), you'll plug in cos(180) expecting -1 and get a number you don't recognize. Flip the dropdown or think in radians.

Inputs and outputs that matter

  • angle - accepts an int or a float. Wire in a frame counter, a progress value from 0 to 1, or any number from another math node.
  • unit - Radians or Degrees. Set it once and forget it, but notice it's there.
  • result (FLOAT) - the cosine of your angle, always between -1 and 1.

The cosine curve starts at 1 at zero, dips to -1 halfway through the cycle, and comes back. That's handy when you want a value that begins at full strength and eases off - like a fade-in that's already peaking on frame one. For motion that starts at zero and builds, you want the sibling MathSin node; cosine is the phase-shifted cousin.

Installing it

ComfyUI Manager is the easy path: Manager → Install Custom Nodes → search "ComfyUI-LogicMath". Or the manual way:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-LogicMath

Restart ComfyUI. There are no model downloads and no requirements.txt - the only dependency is comfy_api, which ships with modern ComfyUI. That also means the "why is it missing" question has one boring answer: if the nodes don't appear after install, your ComfyUI is too old. This pack has no legacy mappings, so older builds simply never register it. Update ComfyUI and reload.

Common gotchas

  • Radians vs Degrees - the #1 confusion. Default is Radians; remember to switch it if you're thinking in degrees.
  • It's not a random number generator. Cosine is deterministic and periodic. If your animation looks like it's "pulsing," that's normal - feed it frame / interval to stretch or compress the cycle.
  • Everything is a float. The output is always FLOAT, so if the node you're feeding demands an INT, run it through MathNumberConvert or MathRound first.

Cosine won't generate anything by itself - it's a tool for turning a boring linear counter into motion that reads as organic. Once you've used it to drift a camera or modulate a denoise strength over time, you'll see why animation workflows quietly depend on it.

Categoryutils/math/trigonometry

Inputs (2)

NameTypeDefaultDescription
angleCOMFY_MATCHTYPE_V3
unitCOMBORadians2 options: Radians, Degrees

Outputs (1)

NameTypeDescription
resultFLOAT