Table of Contents

Struct LengthVector2

Namespace
Thunder.UnitsNET.Vectors
Assembly
Thunder.UnitsNET.Vectors.dll

A 2D vector whose components represent a displacement or position, each expressed as a UnitsNet.Length (e.g. metres, feet, kilometres).

Use this type whenever you need to track where something is on a 2D plane, or how far it has moved. It is the central type in the kinematics chain: dividing by a UnitsNet.Duration gives a SpeedVector2; multiplying by a UnitsNet.Length gives an AreaVector2.

The positive X-axis points right and the positive Y-axis points up (standard mathematical convention). Both components always carry their unit, so there is no ambiguity about whether a value is in metres, feet, or any other length unit.

public readonly record struct LengthVector2 : IEquatable<LengthVector2>
Implements
Inherited Members
Extension Methods

Examples

// A position 3 metres right and 4 metres up from the origin
var position = new LengthVector2(Length.FromMeters(3), Length.FromMeters(4));

// Convenience factory — avoids repeating Length.FromMeters
var same = LengthVector2.FromMeters(3, 4);

Constructors

LengthVector2(Length, Length)

Constructs a LengthVector2 from two UnitsNet.Length components.

public LengthVector2(Length x, Length y)

Parameters

x Length

The X component.

y Length

The Y component.

Properties

Magnitude

Returns the Euclidean magnitude of this vector as a UnitsNet.Length. The result is expressed in the same unit as the X component.

public Length Magnitude { get; }

Property Value

Length

X

The X component.

public Length X { get; }

Property Value

Length

Y

The Y component.

public Length Y { get; }

Property Value

Length

Zero

A LengthVector2 with both components set to zero.

public static LengthVector2 Zero { get; }

Property Value

LengthVector2

Methods

Abs()

Returns a vector with each component replaced by its absolute value.

public LengthVector2 Abs()

Returns

LengthVector2

A LengthVector2 with non-negative components.

Add(LengthVector2)

Adds two vectors component-wise.

public LengthVector2 Add(LengthVector2 other)

Parameters

other LengthVector2

The vector to add.

Returns

LengthVector2

The component-wise sum.

AngleTo(LengthVector2)

Returns the signed angle from this vector to other, measured counter-clockwise around the implicit Z-axis.

The result is in the range (−π, π] radians (−180°, 180°]. It is:

  • Positive when other is counter-clockwise (CCW) from this vector.
  • Negative when other is clockwise (CW) from this vector.
  • Zero when both vectors point in the same direction.
  • ±π (±180°) when the vectors point in exactly opposite directions.

Computed via atan2(cross, dot), which handles all quadrants correctly.

public Angle AngleTo(LengthVector2 other)

Parameters

other LengthVector2

The target direction vector.

Returns

Angle

The signed angle from this vector to other.

Examples

var right = LengthVector2.FromMeters(1, 0);
var up    = LengthVector2.FromMeters(0, 1);
Angle a1 = right.AngleTo(up);  // +90° (up is CCW from right)
Angle a2 = up.AngleTo(right);  // −90° (right is CW from up)

ApproximatelyEquals(LengthVector2, Length)

Returns true if each component of this vector is within tolerance of the corresponding component of other.

public bool ApproximatelyEquals(LengthVector2 other, Length tolerance)

Parameters

other LengthVector2

The vector to compare against.

tolerance Length

The maximum allowed difference per component (inclusive).

Returns

bool

true when |X - other.X| <= tolerance and |Y - other.Y| <= tolerance.

As(LengthUnit)

Projects both components into the requested unit, returning a unit-less DoubleVector2.

public DoubleVector2 As(LengthUnit unit)

Parameters

unit LengthUnit

The target unit for each component.

Returns

DoubleVector2

A DoubleVector2 with components expressed in unit.

AsDefault()

Returns both components expressed in the SI base unit as a DoubleVector2.

public DoubleVector2 AsDefault()

Returns

DoubleVector2

A DoubleVector2 with components in the default SI unit.

Clamp(LengthVector2, LengthVector2)

Returns a vector with each component clamped to the range [min, max].

public LengthVector2 Clamp(LengthVector2 min, LengthVector2 max)

Parameters

min LengthVector2

The lower bound vector (inclusive, per component).

max LengthVector2

The upper bound vector (inclusive, per component).

Returns

LengthVector2

A LengthVector2 with each component in [min, max].

DistanceTo(LengthVector2)

Returns the straight-line Euclidean distance between this position and other.

Computed as √((Δx)² + (Δy)²) using the Pythagorean theorem. The result is always a non-negative UnitsNet.Length in the same unit as the components.

Use this when you need the scalar distance (e.g. for collision detection radius checks or pathfinding heuristics). If you only need to compare distances, prefer comparing the squared distance to avoid a square-root call.

public Length DistanceTo(LengthVector2 other)

Parameters

other LengthVector2

The target position.

Returns

Length

The straight-line distance between the two positions, always ≥ 0.

Examples

var a = LengthVector2.FromMeters(0, 0);
var b = LengthVector2.FromMeters(3, 4);
Length d = a.DistanceTo(b); // 5 m — classic 3-4-5 triangle

Divide(double)

Divides the vector by a scalar divisor.

public LengthVector2 Divide(double scalar)

Parameters

scalar double

The scalar divisor.

Returns

LengthVector2

The divided vector.

Dot(DoubleVector2)

Returns the scalar projection of this vector onto the unit direction vector direction (i.e. the dot product of a length vector with a dimensionless unit vector), expressed as UnitsNet.Length.

Use this when projecting a displacement onto a known unit direction — for example, finding how far along a line a point lies. projection = X * direction.X + Y * direction.Y

public Length Dot(DoubleVector2 direction)

Parameters

direction DoubleVector2

A dimensionless direction vector. Should be a unit vector (magnitude ≈ 1) for the result to represent a true scalar projection; the method does not normalise it.

Returns

Length

The scalar projection, in the same unit as this vector's X/Y components.

Examples

var displacement = new LengthVector2(Length.FromMeters(3), Length.FromMeters(4));
var right = new DoubleVector2(1, 0);
Length proj = displacement.Dot(right); // 3 m — the horizontal component

Dot(ForceVector2)

Returns the scalar work done by other along this displacement (W = d⃗ · F⃗), expressed as UnitsNet.Energy.

public Energy Dot(ForceVector2 other)

Parameters

other ForceVector2

The force vector.

Returns

Energy

The work done, in the natural unit for this displacement/force pair.

Dot(LengthVector2)

Returns the dot product of this displacement vector with other, expressed as UnitsNet.Area (A = x⃗ · x⃗).

public Area Dot(LengthVector2 other)

Parameters

other LengthVector2

The other displacement vector.

Returns

Area

The scalar area result, in the squared unit of this vector's components.

Equals(LengthVector2)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(LengthVector2 other)

Parameters

other LengthVector2

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Extend(Length)

Creates a LengthVector3 by appending a Z component to this vector.

The X and Y components — including their units — are preserved exactly. The unit of Z is taken from z and is independent of X and Y.

public LengthVector3 Extend(Length z)

Parameters

z Length

The Z component to add.

Returns

LengthVector3

A LengthVector3 with the same X, Y and the given Z.

Examples

var v2 = LengthVector2.FromMeters(3, 4);
LengthVector3 v3 = v2.Extend(Length.FromMeters(5)); // (3 m, 4 m, 5 m)

FromAngstroms(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromAngstroms(UnitsNet.QuantityValue).

public static LengthVector2 FromAngstroms(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromAstronomicalUnits(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromAstronomicalUnits(UnitsNet.QuantityValue).

public static LengthVector2 FromAstronomicalUnits(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromCentimeters(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromCentimeters(UnitsNet.QuantityValue).

public static LengthVector2 FromCentimeters(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromChains(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromChains(UnitsNet.QuantityValue).

public static LengthVector2 FromChains(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromDataMiles(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromDataMiles(UnitsNet.QuantityValue).

public static LengthVector2 FromDataMiles(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromDecameters(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromDecameters(UnitsNet.QuantityValue).

public static LengthVector2 FromDecameters(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromDecimeters(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromDecimeters(UnitsNet.QuantityValue).

public static LengthVector2 FromDecimeters(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromDtpPicas(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromDtpPicas(UnitsNet.QuantityValue).

public static LengthVector2 FromDtpPicas(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromDtpPoints(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromDtpPoints(UnitsNet.QuantityValue).

public static LengthVector2 FromDtpPoints(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromFathoms(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromFathoms(UnitsNet.QuantityValue).

public static LengthVector2 FromFathoms(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromFeet(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromFeet(UnitsNet.QuantityValue).

public static LengthVector2 FromFeet(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromFemtometers(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromFemtometers(UnitsNet.QuantityValue).

public static LengthVector2 FromFemtometers(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromGigameters(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromGigameters(UnitsNet.QuantityValue).

public static LengthVector2 FromGigameters(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromHands(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromHands(UnitsNet.QuantityValue).

public static LengthVector2 FromHands(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromHectometers(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromHectometers(UnitsNet.QuantityValue).

public static LengthVector2 FromHectometers(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromInches(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromInches(UnitsNet.QuantityValue).

public static LengthVector2 FromInches(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromKilofeet(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromKilofeet(UnitsNet.QuantityValue).

public static LengthVector2 FromKilofeet(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromKilolightYears(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromKilolightYears(UnitsNet.QuantityValue).

public static LengthVector2 FromKilolightYears(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromKilometers(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromKilometers(UnitsNet.QuantityValue).

public static LengthVector2 FromKilometers(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromKiloparsecs(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromKiloparsecs(UnitsNet.QuantityValue).

public static LengthVector2 FromKiloparsecs(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromKiloyards(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromKiloyards(UnitsNet.QuantityValue).

public static LengthVector2 FromKiloyards(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromLightYears(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromLightYears(UnitsNet.QuantityValue).

public static LengthVector2 FromLightYears(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMegalightYears(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMegalightYears(UnitsNet.QuantityValue).

public static LengthVector2 FromMegalightYears(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMegameters(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMegameters(UnitsNet.QuantityValue).

public static LengthVector2 FromMegameters(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMegaparsecs(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMegaparsecs(UnitsNet.QuantityValue).

public static LengthVector2 FromMegaparsecs(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMeters(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMeters(UnitsNet.QuantityValue).

public static LengthVector2 FromMeters(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMicroinches(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMicroinches(UnitsNet.QuantityValue).

public static LengthVector2 FromMicroinches(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMicrometers(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMicrometers(UnitsNet.QuantityValue).

public static LengthVector2 FromMicrometers(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMiles(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMiles(UnitsNet.QuantityValue).

public static LengthVector2 FromMiles(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMillimeters(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMillimeters(UnitsNet.QuantityValue).

public static LengthVector2 FromMillimeters(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromMils(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromMils(UnitsNet.QuantityValue).

public static LengthVector2 FromMils(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromNanometers(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromNanometers(UnitsNet.QuantityValue).

public static LengthVector2 FromNanometers(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromNauticalMiles(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromNauticalMiles(UnitsNet.QuantityValue).

public static LengthVector2 FromNauticalMiles(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromParsecs(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromParsecs(UnitsNet.QuantityValue).

public static LengthVector2 FromParsecs(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromPicometers(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromPicometers(UnitsNet.QuantityValue).

public static LengthVector2 FromPicometers(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromPolar(Length, Angle)

Creates a LengthVector2 from polar coordinates: a radial distance and a direction angle measured counter-clockwise from the positive X-axis.

The result has components: X = radius × cos(angle), Y = radius × sin(angle). The unit of both components is taken from radius, so a radius in feet produces a vector in feet.

public static LengthVector2 FromPolar(Length radius, Angle angle)

Parameters

radius Length

The radial distance (magnitude of the resulting vector). Must be non-negative for a conventional polar-to-Cartesian conversion; negative values are allowed and invert the direction.

angle Angle

The direction angle. 0° points along +X (right). 90° points along +Y (up). Counter-clockwise is positive.

Returns

LengthVector2

A LengthVector2 with magnitude equal to |radius|, pointing in the direction of angle.

Examples

// 5 m pointing right
var right = LengthVector2.FromPolar(Length.FromMeters(5), Angle.FromDegrees(0));

// 10 ft pointing up
var up = LengthVector2.FromPolar(Length.FromFeet(10), Angle.FromDegrees(90));

FromPrinterPicas(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromPrinterPicas(UnitsNet.QuantityValue).

public static LengthVector2 FromPrinterPicas(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromPrinterPoints(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromPrinterPoints(UnitsNet.QuantityValue).

public static LengthVector2 FromPrinterPoints(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromShackles(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromShackles(UnitsNet.QuantityValue).

public static LengthVector2 FromShackles(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromSolarRadiuses(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromSolarRadiuses(UnitsNet.QuantityValue).

public static LengthVector2 FromSolarRadiuses(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromTwips(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromTwips(UnitsNet.QuantityValue).

public static LengthVector2 FromTwips(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromUsSurveyFeet(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromUsSurveyFeet(UnitsNet.QuantityValue).

public static LengthVector2 FromUsSurveyFeet(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

FromYards(double, double)

Creates a LengthVector2 with both components created via UnitsNet.Length.FromYards(UnitsNet.QuantityValue).

public static LengthVector2 FromYards(double x, double y)

Parameters

x double

The X component value.

y double

The Y component value.

Returns

LengthVector2

A LengthVector2 with both components in the corresponding unit.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Lerp(LengthVector2, LengthVector2, double)

Linearly interpolates between two vectors.

The result at t = 0 is a; at t = 1 it is b. Values of t outside [0, 1] extrapolate beyond the endpoints — use LerpClamped(LengthVector2, LengthVector2, double) if you need the result bounded to the segment between a and b.

public static LengthVector2 Lerp(LengthVector2 a, LengthVector2 b, double t)

Parameters

a LengthVector2

The start vector (t = 0).

b LengthVector2

The end vector (t = 1).

t double

The interpolation parameter. Values outside [0, 1] extrapolate.

Returns

LengthVector2

The interpolated LengthVector2.

LerpClamped(LengthVector2, LengthVector2, double)

Linearly interpolates between two vectors, with t clamped to [0, 1].

public static LengthVector2 LerpClamped(LengthVector2 a, LengthVector2 b, double t)

Parameters

a LengthVector2

The start vector (t = 0).

b LengthVector2

The end vector (t = 1).

t double

The interpolation parameter, clamped to [0, 1].

Returns

LengthVector2

The interpolated LengthVector2, always between a and b.

Multiply(double)

Scales the vector by a scalar factor.

public LengthVector2 Multiply(double scalar)

Parameters

scalar double

The scalar factor.

Returns

LengthVector2

The scaled vector.

Negate()

Negates both components.

public LengthVector2 Negate()

Returns

LengthVector2

A vector with all components negated.

Normalize()

Returns a dimensionless unit vector pointing in the same direction. For a zero vector, Zero is returned.

public DoubleVector2 Normalize()

Returns

DoubleVector2

A unit-length DoubleVector2 in the same direction.

PerpendicularDot(DoubleVector2)

Returns the perpendicular scalar projection — the component of this vector that is perpendicular to direction — expressed as UnitsNet.Length.

Computes X * direction.Y − Y * direction.X. The sign follows the right-hand rule: positive when direction is counter-clockwise (CCW) from this vector, negative when clockwise. Useful for determining which side of a line a point is on, and for ray/line intersection parameter calculation.

public Length PerpendicularDot(DoubleVector2 direction)

Parameters

direction DoubleVector2

A dimensionless direction vector. Should be a unit vector for the result to represent a true perpendicular scalar projection.

Returns

Length

The signed perpendicular projection length, in the same unit as this vector's components. Positive means direction is CCW from this vector's direction.

Examples

var displacement = new LengthVector2(Length.FromMeters(3), Length.FromMeters(4));
var right = new DoubleVector2(1, 0);
Length perp = displacement.PerpendicularDot(right); // -4 m (right is CW from (3,4))

PerpendicularDot(LengthVector2)

Returns the perpendicular dot product (also called the 2D cross product) of this vector with other, expressed as UnitsNet.Area.

The perpendicular dot product computes X * other.Y − Y * other.X. It is the signed area of the parallelogram spanned by the two vectors: positive when other is counter-clockwise (CCW) from this vector, negative when clockwise (CW), and zero when they are parallel or anti-parallel.

public Area PerpendicularDot(LengthVector2 other)

Parameters

other LengthVector2

The second displacement vector.

Returns

Area

The signed area of the parallelogram spanned by the two vectors, in the natural area unit for this vector's length unit. Positive means other is CCW from this vector.

Examples

var right = new LengthVector2(Length.FromMeters(1), Length.FromMeters(0)); // (1, 0)
var up    = new LengthVector2(Length.FromMeters(0), Length.FromMeters(1)); // (0, 1)
Area cross = right.PerpendicularDot(up); // +1 m² — up is CCW from right

Subtract(LengthVector2)

Subtracts two vectors component-wise.

public LengthVector2 Subtract(LengthVector2 other)

Parameters

other LengthVector2

The vector to subtract.

Returns

LengthVector2

The component-wise difference.

ToPoint()

Converts this displacement vector to a LengthPoint2 with the same components.

This is an explicit escape hatch for cases where you genuinely need to treat a displacement as a position — for example, when constructing a point from raw component values. Prefer the typed algebra operators where possible.

public LengthPoint2 ToPoint()

Returns

LengthPoint2

A LengthPoint2 with the same X and Y values.

Examples

var vector = LengthVector2.FromMeters(3, 4);
var point  = vector.ToPoint(); // LengthPoint2(3 m, 4 m)

Operators

operator +(LengthVector2, LengthVector2)

Adds two vectors component-wise.

public static LengthVector2 operator +(LengthVector2 left, LengthVector2 right)

Parameters

left LengthVector2

The left operand.

right LengthVector2

The right operand.

Returns

LengthVector2

The component-wise sum.

operator /(LengthVector2, double)

Divides the vector by a scalar divisor.

public static LengthVector2 operator /(LengthVector2 left, double scalar)

Parameters

left LengthVector2

The vector to divide.

scalar double

The scalar divisor.

Returns

LengthVector2

The divided vector.

operator /(LengthVector2, Duration)

Divides a LengthVector2 by a UnitsNet.Duration to produce a SpeedVector2.

public static SpeedVector2 operator /(LengthVector2 left, Duration right)

Parameters

left LengthVector2

The left operand.

right Duration

The right operand.

Returns

SpeedVector2

A SpeedVector2.

operator *(double, LengthVector2)

Scales the vector by a scalar factor. Operands may be supplied in either order.

public static LengthVector2 operator *(double scalar, LengthVector2 right)

Parameters

scalar double

The scalar factor.

right LengthVector2

The vector to scale.

Returns

LengthVector2

The scaled vector.

operator *(LengthVector2, double)

Scales the vector by a scalar factor.

public static LengthVector2 operator *(LengthVector2 left, double scalar)

Parameters

left LengthVector2

The vector to scale.

scalar double

The scalar factor.

Returns

LengthVector2

The scaled vector.

operator *(LengthVector2, Length)

Multiplies a LengthVector2 by a UnitsNet.Length to produce a AreaVector2.

public static AreaVector2 operator *(LengthVector2 left, Length right)

Parameters

left LengthVector2

The left operand.

right Length

The right operand.

Returns

AreaVector2

A AreaVector2.

operator *(Length, LengthVector2)

Multiplies a UnitsNet.Length by a LengthVector2 to produce a AreaVector2. Operands may be supplied in either order.

public static AreaVector2 operator *(Length left, LengthVector2 right)

Parameters

left Length

The left operand.

right LengthVector2

The right operand.

Returns

AreaVector2

A AreaVector2.

operator -(LengthVector2, LengthVector2)

Subtracts two vectors component-wise.

public static LengthVector2 operator -(LengthVector2 left, LengthVector2 right)

Parameters

left LengthVector2

The left operand.

right LengthVector2

The right operand.

Returns

LengthVector2

The component-wise difference.

operator -(LengthVector2)

Negates both components.

public static LengthVector2 operator -(LengthVector2 value)

Parameters

value LengthVector2

The vector to negate.

Returns

LengthVector2

A vector with all components negated.

latest ▼