Skip to main content

Vector Struct

Definition

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia
Source:Vector.cs

Defines a vector.

public struct Vector

Inheritance: ValueType -> Vector

Implements: IEquatable<Vector>

Constructors

NameDescription
VectorInitializes a new instance of the Avalonia.Vector structure.

Vector Constructor

Initializes a new instance of the Avalonia.Vector structure.

public Vector(double x, double y)

Parameters

x double

The X component.

y double

The Y component.

Methods

NameDescription
AbsReturns a vector whose elements are the absolute values of each of the specified vector's elements.
AddAdds the second to the first vector
ClampRestricts a vector between a minimum and a maximum value.
CrossReturns the cross product of two vectors.
DeconstructNo summary available.
DistanceComputes the Euclidean distance between the two given points.
DistanceSquaredReturns the Euclidean distance squared between two specified points
Divide (2 overloads)Divides the first vector by the second.
DotReturns the dot product of two vectors.
Equals (2 overloads)Check if two vectors are equal (bitwise).
GetHashCodeNo summary available.
MaxReturns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors
MinReturns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors
Multiply (2 overloads)Multiplies the first vector by the second.
NearlyEqualsCheck if two vectors are nearly equal (numerically).
Negate (2 overloads)Returns a negated version of this vector.
Normalize (2 overloads)Returns a normalized version of this vector.
ParseParses a Avalonia.Vector string.
SubtractSubtracts the second from the first vector
ToStringReturns the string representation of the vector.
WithXReturns a new vector with the specified X component.
WithYReturns a new vector with the specified Y component.

Abs Method

Returns a vector whose elements are the absolute values of each of the specified vector's elements.

public Avalonia.Vector Abs()

Returns

Avalonia.Vector

Add Method

Adds the second to the first vector

public Avalonia.Vector Add(Avalonia.Vector a, Avalonia.Vector b)

Parameters

a Avalonia.Vector

The first vector.

b Avalonia.Vector

The second vector.

Returns

Avalonia.Vector

The summed vector.

Clamp Method

Restricts a vector between a minimum and a maximum value.

public Avalonia.Vector Clamp(Avalonia.Vector value, Avalonia.Vector min, Avalonia.Vector max)

Parameters

value Avalonia.Vector

min Avalonia.Vector

max Avalonia.Vector

Returns

Avalonia.Vector

Cross Method

Returns the cross product of two vectors.

public double Cross(Avalonia.Vector a, Avalonia.Vector b)

Parameters

a Avalonia.Vector

The first vector.

b Avalonia.Vector

The second vector.

Returns

double

The cross product.

Deconstruct Method

public void Deconstruct(double& x, double& y)

Parameters

x double&

y double&

Distance Method

Computes the Euclidean distance between the two given points.

public double Distance(Avalonia.Vector value1, Avalonia.Vector value2)

Parameters

value1 Avalonia.Vector

The first point.

value2 Avalonia.Vector

The second point.

Returns

double

The Euclidean distance.

DistanceSquared Method

Returns the Euclidean distance squared between two specified points

public double DistanceSquared(Avalonia.Vector value1, Avalonia.Vector value2)

Parameters

value1 Avalonia.Vector

The first point.

value2 Avalonia.Vector

The second point.

Returns

double

The Euclidean distance squared.

Divide overloads

Divide Method

Divides the first vector by the second.

public Avalonia.Vector Divide(Avalonia.Vector a, Avalonia.Vector b)
Parameters

a Avalonia.Vector

The first vector.

b Avalonia.Vector

The second vector.

Returns

Avalonia.Vector

The scaled vector.

Divide Method

Divides the vector by the given scalar.

public Avalonia.Vector Divide(Avalonia.Vector vector, double scalar)
Parameters

vector Avalonia.Vector

The vector

scalar double

The scalar value

Returns

Avalonia.Vector

The scaled vector.

Dot Method

Returns the dot product of two vectors.

public double Dot(Avalonia.Vector a, Avalonia.Vector b)

Parameters

a Avalonia.Vector

The first vector.

b Avalonia.Vector

The second vector.

Returns

double

The dot product.

Equals overloads

Equals Method

Check if two vectors are equal (bitwise).

public bool Equals(Avalonia.Vector other)
Parameters

other Avalonia.Vector

Returns

bool

Equals Method

public bool Equals(object obj)
Parameters

obj object

Returns

bool

GetHashCode Method

public int GetHashCode()

Returns

int

Max Method

Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors

public Avalonia.Vector Max(Avalonia.Vector left, Avalonia.Vector right)

Parameters

left Avalonia.Vector

right Avalonia.Vector

Returns

Avalonia.Vector

Min Method

Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors

public Avalonia.Vector Min(Avalonia.Vector left, Avalonia.Vector right)

Parameters

left Avalonia.Vector

right Avalonia.Vector

Returns

Avalonia.Vector

Multiply overloads

Multiply Method

Multiplies the first vector by the second.

public Avalonia.Vector Multiply(Avalonia.Vector a, Avalonia.Vector b)
Parameters

a Avalonia.Vector

The first vector.

b Avalonia.Vector

The second vector.

Returns

Avalonia.Vector

The scaled vector.

Multiply Method

Multiplies the vector by the given scalar.

public Avalonia.Vector Multiply(Avalonia.Vector vector, double scalar)
Parameters

vector Avalonia.Vector

The vector

scalar double

The scalar value

Returns

Avalonia.Vector

The scaled vector.

NearlyEquals Method

Check if two vectors are nearly equal (numerically).

public bool NearlyEquals(Avalonia.Vector other)

Parameters

other Avalonia.Vector

The other vector.

Returns

bool

True if vectors are nearly equal.

Negate overloads

Negate Method

Returns a negated version of this vector.

public Avalonia.Vector Negate()
Returns

Avalonia.Vector

The negated vector.

Negate Method

Negates the vector

public Avalonia.Vector Negate(Avalonia.Vector vector)
Parameters

vector Avalonia.Vector

The vector to negate.

Returns

Avalonia.Vector

The scaled vector.

Normalize overloads

Normalize Method

Returns a normalized version of this vector.

public Avalonia.Vector Normalize()
Returns

Avalonia.Vector

The normalized vector.

Normalize Method

Normalizes the given vector.

public Avalonia.Vector Normalize(Avalonia.Vector vector)
Parameters

vector Avalonia.Vector

The vector

Returns

Avalonia.Vector

The normalized vector.

Parse Method

Parses a Avalonia.Vector string.

public Avalonia.Vector Parse(string s)

Parameters

s string

The string.

Returns

Avalonia.Vector

The Avalonia.Vector.

Subtract Method

Subtracts the second from the first vector

public Avalonia.Vector Subtract(Avalonia.Vector a, Avalonia.Vector b)

Parameters

a Avalonia.Vector

The first vector.

b Avalonia.Vector

The second vector.

Returns

Avalonia.Vector

The difference vector.

ToString Method

Returns the string representation of the vector.

public string ToString()

Returns

string

The string representation of the vector.

WithX Method

Returns a new vector with the specified X component.

public Avalonia.Vector WithX(double x)

Parameters

x double

The X component.

Returns

Avalonia.Vector

The new vector.

WithY Method

Returns a new vector with the specified Y component.

public Avalonia.Vector WithY(double y)

Parameters

y double

The Y component.

Returns

Avalonia.Vector

The new vector.

Properties

NameDescription
LengthLength of the vector.
OneReturns the vector (1.0, 1.0).
SquaredLengthSquared Length of the vector.
UnitXReturns the vector (1.0, 0.0).
UnitYReturns the vector (0.0, 1.0).
XGets the X component.
YGets the Y component.
ZeroReturns the vector (0.0, 0.0).

Length Property

Length of the vector.

public double Length { get; set; }

One Property

Returns the vector (1.0, 1.0).

public Avalonia.Vector One { get; set; }

SquaredLength Property

Squared Length of the vector.

public double SquaredLength { get; set; }

UnitX Property

Returns the vector (1.0, 0.0).

public Avalonia.Vector UnitX { get; set; }

UnitY Property

Returns the vector (0.0, 1.0).

public Avalonia.Vector UnitY { get; set; }

X Property

Gets the X component.

public double X { get; set; }

Y Property

Gets the Y component.

public double Y { get; set; }

Zero Property

Returns the vector (0.0, 0.0).

public Avalonia.Vector Zero { get; set; }