ComfyUI Node

Pt Atan

Arctan, the angle from a ratio

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pt Atan
  • tens_a
  • TENSOR

Pt Atan is the inverse tangent: give it a ratio and it returns the angle in radians. Of the three arc-trig functions in ComfyUI-Pt-Wrapper, atan is the one you're most likely to actually want, because it's the one that works on ratios - and ratios are everywhere. If something is "twice as much in x as in y," arctan tells you the angle that relationship implies.

It's part of the trig shelf in HowToSD's 200-node PyTorch pack (the spin-off of ComfyUI-Data-Analysis), alongside Acos and Asin. Where does atan earn its keep in tensor land? Converting slope ratios into angles (phase estimation, gradient direction - literally the direction of a gradient vector is atan(dy/dx)), angular error metrics, and feature-space work where you want a bounded, continuous angle from two quantities. It also pairs naturally with Acos/Asin for converting between representations.

How it works. One input, tens_a; one output, TENSOR. Element-wise atan(), radians out, same shape, no settings.

The two things worth knowing - and one is a pleasant surprise. First, the domain: unlike arcsin/arccos, which explode into NaN outside [−1, 1], arctan is defined for every real number. Any input is valid, and the output is always bounded to (−π/2, π/2). That makes it the robust one of the family - you can pipe noisy, unclamped data through it and always get a sane-looking angle. The second thing is what it doesn't do: Pt Atan takes a single ratio value, so it can't distinguish which quadrant a vector is in (is that 45° up-right or 45° down-left? Atan says 45° either way). If you need quadrant-aware angles - genuinely the usual case when you have separate x and y components - you want a two-argument arctangent, the atan2(y, x) that Python and PyTorch both provide. This node is the single-argument version, so you must fold the ratio yourself: atan(y/x) instead of atan2(y, x), accepting the lost quadrant information. For most workflows, that's a real reason to compute the angle a different way.

Also: radians out, not degrees - multiply by 180/π if that's your language.

Install: ComfyUI Manager → "ComfyUI-Pt-Wrapper", or:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper

then restart. No model downloads; the pack's heavy requirements.txt is the only install cost.

Troubleshooting: angles come out between −90° and +90° in a way that "loses half the circle" - that's the single-argument atan's quadrant blindness; use the two-argument form if the pack or PyTorch exposes one. Radians/degrees confusion - scale it. "Wrong direction" - remember atan is atan(y/x), so feeding it x/y inverts your angle. And if inputs are extreme (huge ratios), the output just hugs ±π/2 - that's correct, not a bug.

CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
tens_aTENSOR

Outputs (1)

NameTypeDescription
TENSORTENSOR