Struct CanvasVector
- Namespace
- FlowGraph.Core.Coordinates
- Assembly
- FlowGraph.Core.dll
A vector/delta in canvas coordinate space.
Canvas vectors represent movements, offsets, and distances in canvas space. Unlike canvas points, vectors are relative (they represent the difference between two points, not an absolute position).
When to use:
- Drag distances in canvas space
- Node movement offsets
- Snap offsets
- Collision avoidance adjustments
public readonly record struct CanvasVector : IEquatable<CanvasVector>
- Implements
- Inherited Members
- Extension Methods
Constructors
CanvasVector(double, double)
A vector/delta in canvas coordinate space.
Canvas vectors represent movements, offsets, and distances in canvas space. Unlike canvas points, vectors are relative (they represent the difference between two points, not an absolute position).
When to use:
- Drag distances in canvas space
- Node movement offsets
- Snap offsets
- Collision avoidance adjustments
public CanvasVector(double DX, double DY)
Parameters
Properties
DX
public double DX { get; init; }
Property Value
DY
public double DY { get; init; }
Property Value
Length
The length (magnitude) of this vector.
public double Length { get; }
Property Value
LengthSquared
The squared length of this vector (faster than Length).
public double LengthSquared { get; }
Property Value
Zero
A zero-length vector.
public static CanvasVector Zero { get; }
Property Value
Methods
FromCore(Point)
Creates a vector from a core Point (treating it as a delta).
public static CanvasVector FromCore(Point delta)
Parameters
deltaPoint
Returns
Normalized()
Returns a normalized (unit length) version of this vector. Returns Zero if this vector has zero length.
public CanvasVector Normalized()
Returns
ToCore()
Converts to a core Point (for APIs that expect Point as delta).
public Point ToCore()
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator +(CanvasVector, CanvasVector)
Adds two vectors.
public static CanvasVector operator +(CanvasVector a, CanvasVector b)
Parameters
Returns
operator /(CanvasVector, double)
Divides this vector by a scalar value.
public static CanvasVector operator /(CanvasVector vector, double scalar)
Parameters
vectorCanvasVectorscalardouble
Returns
operator *(CanvasVector, double)
Scales this vector by a scalar value.
public static CanvasVector operator *(CanvasVector vector, double scalar)
Parameters
vectorCanvasVectorscalardouble
Returns
operator *(double, CanvasVector)
Scales this vector by a scalar value.
public static CanvasVector operator *(double scalar, CanvasVector vector)
Parameters
scalardoublevectorCanvasVector
Returns
operator -(CanvasVector, CanvasVector)
Subtracts two vectors.
public static CanvasVector operator -(CanvasVector a, CanvasVector b)
Parameters
Returns
operator -(CanvasVector)
Negates this vector.
public static CanvasVector operator -(CanvasVector vector)
Parameters
vectorCanvasVector