Skip to content

Vector2

public struct Vector2

A 2D vector of two floats. A pointer event from an interactivity zone hands logic one as a position in pixels from the top-left corner of the Circuit Designer viewport, and a shader vec2 uniform is read and written as one. The arithmetic lets logic derive drag deltas and angles (potentiometers, rotary encoders) from successive pointer positions.

public Vector2(float x, float y);

Creates a vector from its X and Y components.

public float X { get; set; }

The horizontal component. On a pointer position it is pixels from the left edge of the viewport.

public float Y { get; set; }

The vertical component. On a pointer position it is pixels from the top edge of the viewport, growing downward.

static

public static Vector2 Zero { get; }

The vector (0, 0).

public float Length();

Length (magnitude) of this vector, in the same units as its components.

public float DistanceTo(Vector2 other);

Distance from this position to other, in the same units as the components.

public float Angle();

Angle of this vector from the +X axis, in radians (-π to π). On pointer positions, where Y grows downward, the angle increases clockwise on screen.

public float AngleTo(Vector2 other);

Signed angle in radians (-π to π) that turns this vector’s direction onto the direction of other. Both are taken as directions from (0, 0); on pointer positions a positive result is clockwise on screen.

override

public override bool Equals(object obj);

True when obj is a Vector2 with exactly equal components.

override

public override int GetHashCode();

A hash of the components, so the vector can key a dictionary or a set.

override

public override string ToString();

The vector as text, for example Vector2(3, 4).

static

public static Vector2 operator +(Vector2 a, Vector2 b);

Adds two vectors component by component.

static

public static Vector2 operator -(Vector2 a, Vector2 b);

Subtracts b from a component by component. The difference of two pointer positions is the drag between them.

static

public static Vector2 operator *(Vector2 a, float s);

Multiplies every component of a by s.

static

public static Vector2 operator *(float s, Vector2 a);

Multiplies every component of a by s.

static

public static Vector2 operator /(Vector2 a, float s);

Divides every component of a by s. Dividing by zero gives infinite or NaN components, not an error.

static

public static bool operator ==(Vector2 a, Vector2 b);

True when both components are exactly equal. Computed positions rarely match exactly, so compare DistanceTo against a small tolerance instead.

static

public static bool operator !=(Vector2 a, Vector2 b);

True when either component differs, compared exactly.

Generated from the CRUMB source, commit fcec660d, 2026-10-29.