Nodes/ComfyMath/Vec4UnaryCondition
ComfyUI Node

Vec4UnaryCondition

Check if a 4D vector is zero or unit length

By evanspearman·Created 3 years ago·Updated about a year ago· 192
Vec4UnaryCondition
  • a
  • BOOL
op

Two questions come up constantly once you're working with 4D vectors as values: is this vector empty (a common "nothing happened yet" sentinel), and is this vector already normalized (unit length)? Vec4UnaryCondition answers either and hands back a boolean.

It's part of ComfyMath, evanspearman's math/logic pack, and it's the natural gate to put in front of anything that assumes a VEC4 is already zero or already unit length - a rotation quaternion, in particular, is only meaningful when it's normalized, so this is the kind of check worth running before trusting one.

How it works

Pick an op from four choices - IsZero, IsNotZero, IsNormalized, IsNotNormalized - and feed it a, your VEC4 (default [0, 0, 0, 0]). IsZero/IsNotZero check whether the vector is exactly [0, 0, 0, 0], useful for treating a zero vector as a sentinel default or an "unset" state. IsNormalized/IsNotNormalized check whether the vector's length is 1.

The two pairs are complementary, not opposites of each other: a vector can be neither zero nor normalized, so don't assume IsNotZero implies IsNormalized or vice versa - they're independent checks answering different questions about the same value.

Inputs and outputs

  • op - IsZero, IsNotZero, IsNormalized, IsNotNormalized.
  • a (VEC4, default [0, 0, 0, 0]) - the vector being tested.
  • Output: BOOL - ComfyMath's own boolean type.

How to install it

Via ComfyUI Manager: search ComfyMath, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/evanspearman/ComfyMath.git

then restart ComfyUI. No dependencies, no models - plain Python arithmetic.

Common issues & troubleshooting

IsNormalized comes back false for a vector that "should" be unit length. Like float equality, this is an exact check on a computed length, and floating-point math rarely lands on exactly 1.0 even when a vector was deliberately normalized upstream - tiny rounding error is enough to flip this to false. If you're chaining a CM_Vec4UnaryOperation Normalize step into this check and it's failing when it shouldn't, that's the likely cause, not a bug in either node.

The BOOL output won't wire into a native switch node. This node outputs ComfyMath's own BOOL type, not ComfyUI's built-in BOOLEAN. Route it through logic that accepts BOOL, or use one of ComfyMath's BOOLEAN-outputting nodes elsewhere if a specific downstream node insists on the native type.

Missing node error loading a shared workflow. Install ComfyMath through Manager as above, then reload.

Not sure you need Vec4 nodes at all. Most generation workflows never touch them - they matter in graphs doing your own color, quaternion, or coordinate logic, not a standard checkpoint-to-image pipeline.

The pack looks unmaintained. A 2024 community thread noted the author had stepped back from active development. Vec3/Vec4 is the least-used, least-changed corner of ComfyMath, so treat it as small and stable rather than actively developed.

Categorymath/vec4

Inputs (2)

NameTypeDefaultDescription
opCOMBO4 options: IsZero, IsNotZero, IsNormalized, IsNotNormalized
aVEC40,0,0,0

Outputs (1)

NameTypeDescription
BOOLBOOL