Skip to main content

Vector Structure

Defines a vector.

Definition

Namespace: Avalonia
Assembly: Avalonia.Base (in Avalonia.Base.dll)

public readonly struct Vector : IEquatable<Vector>
InheritanceObjectValueType → Vector
ImplementsIEquatable(Vector)

Constructors

Vector(Double, Double)Initializes a new instance of the Vector structure.

Properties

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).

Methods

Abs()Returns a vector whose elements are the absolute values of each of the specified vector's elements.
Add(Vector, Vector)Adds the second to the first vector
Clamp(Vector, Vector, Vector)Restricts a vector between a minimum and a maximum value.
Cross(Vector, Vector)Returns the cross product of two vectors.
Deconstruct(Double, Double)Deconstructs the vector into its X and Y components.
Distance(Vector, Vector)Computes the Euclidean distance between the two given points.
DistanceSquared(Vector, Vector)Returns the Euclidean distance squared between two specified points
Divide(Vector, Vector)Divides the first vector by the second.
Divide(Vector, Double)Divides the vector by the given scalar.
Dot(Vector, Vector)Returns the dot product of two vectors.
Equals(Object)
(Overrides ValueType.Equals(Object))
Equals(Vector)Check if two vectors are equal (bitwise).
GetHashCode()
(Overrides ValueType.GetHashCode())
GetType()Gets the Type of the current instance.
(Inherited from Object)
Max(Vector, Vector)Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors
Min(Vector, Vector)Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors
Multiply(Vector, Vector)Multiplies the first vector by the second.
Multiply(Vector, Double)Multiplies the vector by the given scalar.
NearlyEquals(Vector)Check if two vectors are nearly equal (numerically).
Negate()Returns a negated version of this vector.
Negate(Vector)Negates the vector
Normalize()Returns a normalized version of this vector.
Normalize(Vector)Normalizes the given vector.
Parse(String)Parses a Vector string.
Subtract(Vector, Vector)Subtracts the second from the first vector
ToString()Returns the string representation of the vector.
(Overrides ValueType.ToString())
WithX(Double)Returns a new vector with the specified X component.
WithY(Double)Returns a new vector with the specified Y component.

Operators

Addition(Vector, Vector)Adds two vectors.
Division(Vector, Double)Scales a vector.
Equality(Vector, Vector) 
Explicit(Vector to Point)Converts the Vector to a Point.
Implicit(Vector2 to Vector) 
Inequality(Vector, Vector) 
Multiply(Double, Vector)Scales a vector.
Multiply(Vector, Vector)Calculates the dot product of two vectors.
Multiply(Vector, Double)Scales a vector.
Subtraction(Vector, Vector)Subtracts two vectors.
UnaryNegation(Vector)Negates a vector.

Extension Methods

ToSKPoint()
(Defined by SkiaSharpExtensions)

See Also

Reference

Avalonia Namespace