Vec2UnaryCondition
Check if a 2D vector is zero or unit length
- a
- BOOL
Two specific questions come up a lot once you're working with 2D vectors as values: is this vector empty (a common "nothing happened yet" sentinel), and is this vector already normalized (unit length, ready to use as a pure direction)? Vec2UnaryCondition 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 vector is already zero or already a unit direction, instead of assuming and finding out you were wrong three nodes later.
How it works
Pick an op from four choices - IsZero, IsNotZero, IsNormalized, IsNotNormalized - and feed it a, your VEC2 (default [0, 0]). IsZero/IsNotZero check whether the vector is exactly [0, 0], useful for treating a zero vector as a sentinel default or an "unset" value. IsNormalized/IsNotNormalized check whether the vector's length is 1 - that is, whether it's already a pure direction rather than a direction-plus-magnitude.
The two pairs are complementary but not opposites of each other: a vector can be neither zero nor normalized (say, [3, 4], which has length 5), 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(VEC2, default[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_Vec2UnaryOperation 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 Vec2 nodes at all. Most generation workflows never touch them - they matter in graphs doing your own direction/offset/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. Vec2/Vec3 is the least-used, least-changed corner of ComfyMath, so treat it as small and stable rather than actively developed.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| op | COMBO | 4 options: IsZero, IsNotZero, IsNormalized, IsNotNormalized | |
| a | VEC2 | 0,0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOL | BOOL | — |