Struct XVector
Represents a two-dimensional vector specified by x- and y-coordinates. It is a displacement in 2-D space.
public struct XVector : IFormattable
- Implements
- Inherited Members
Constructors
XVector(double, double)
Initializes a new instance of the XVector struct.
public XVector(double x, double y)
Parameters
Properties
Length
Gets the length of this vector.
public double Length { get; }
Property Value
LengthSquared
Gets the square of the length of this vector.
public double LengthSquared { get; }
Property Value
X
Gets or sets the X component of this vector.
public double X { get; set; }
Property Value
Y
Gets or sets the Y component of this vector.
public double Y { get; set; }
Property Value
Methods
Add(XVector, XPoint)
Translates a point by the specified vector and returns the resulting point.
public static XPoint Add(XVector vector, XPoint point)
Parameters
Returns
Add(XVector, XVector)
Adds two vectors and returns the result as a Vector structure.
public static XVector Add(XVector vector1, XVector vector2)
Parameters
Returns
AngleBetween(XVector, XVector)
Retrieves the angle, expressed in degrees, between the two specified vectors.
public static double AngleBetween(XVector vector1, XVector vector2)
Parameters
Returns
CrossProduct(XVector, XVector)
Calculates the cross product of two vectors.
public static double CrossProduct(XVector vector1, XVector vector2)
Parameters
Returns
Determinant(XVector, XVector)
Calculates the determinant of two vectors.
public static double Determinant(XVector vector1, XVector vector2)
Parameters
Returns
Divide(XVector, double)
Divides the specified vector by the specified scalar and returns the result as a Vector.
public static XVector Divide(XVector vector, double scalar)
Parameters
Returns
Equals(XVector)
Compares two vectors for equality.
public bool Equals(XVector value)
Parameters
value
XVectorThe vector to compare with this vector.
Returns
Equals(XVector, XVector)
Compares two vectors for equality.
public static bool Equals(XVector vector1, XVector vector2)
Parameters
Returns
Equals(object?)
Determines whether the specified Object is a Vector structure and, if it is, whether it has the same X and Y values as this vector.
public override bool Equals(object? o)
Parameters
o
objectThe vector to compare.
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
Multiply(XVector, XMatrix)
Transforms the coordinate space of the specified vector using the specified Matrix.
public static XVector Multiply(XVector vector, XMatrix matrix)
Parameters
Returns
Multiply(XVector, XVector)
Calculates the dot product of the two specified vectors and returns the result as a Double.
public static double Multiply(XVector vector1, XVector vector2)
Parameters
vector1
XVectorThe first vector to multiply.
vector2
XVectorThe second vector structure to multiply.
Returns
Multiply(XVector, double)
Multiplies the specified vector by the specified scalar and returns the resulting vector.
public static XVector Multiply(XVector vector, double scalar)
Parameters
Returns
Multiply(double, XVector)
Multiplies the specified scalar by the specified vector and returns the resulting Vector.
public static XVector Multiply(double scalar, XVector vector)
Parameters
Returns
Negate()
Negates this vector. The vector has the same magnitude as before, but its direction is now opposite.
public void Negate()
Normalize()
Normalizes this vector.
public void Normalize()
Parse(string)
Converts a string representation of a vector into the equivalent Vector structure.
public static XVector Parse(string source)
Parameters
source
stringThe string representation of the vector.
Returns
Subtract(XVector, XVector)
Subtracts the specified vector from another specified vector.
public static XVector Subtract(XVector vector1, XVector vector2)
Parameters
vector1
XVectorThe vector from which vector2 is subtracted.
vector2
XVectorThe vector to subtract from vector1.
Returns
ToString()
Returns the string representation of this Vector structure.
public override string ToString()
Returns
ToString(IFormatProvider)
Returns the string representation of this Vector structure with the specified formatting information.
public string ToString(IFormatProvider provider)
Parameters
provider
IFormatProviderThe culture-specific formatting information.
Returns
Operators
operator +(XVector, XPoint)
Translates a point by the specified vector and returns the resulting point.
public static XPoint operator +(XVector vector, XPoint point)
Parameters
Returns
operator +(XVector, XVector)
Adds two vectors and returns the result as a vector.
public static XVector operator +(XVector vector1, XVector vector2)
Parameters
Returns
operator /(XVector, double)
Divides the specified vector by the specified scalar and returns the resulting vector.
public static XVector operator /(XVector vector, double scalar)
Parameters
Returns
operator ==(XVector, XVector)
Compares two vectors for equality.
public static bool operator ==(XVector vector1, XVector vector2)
Parameters
Returns
explicit operator XPoint(XVector)
Creates a Point with the X and Y values of this vector.
public static explicit operator XPoint(XVector vector)
Parameters
vector
XVectorThe vector to convert.
Returns
explicit operator XSize(XVector)
Creates a Size from the offsets of this vector.
public static explicit operator XSize(XVector vector)
Parameters
vector
XVectorThe vector to convert.
Returns
operator !=(XVector, XVector)
Compares two vectors for inequality.
public static bool operator !=(XVector vector1, XVector vector2)
Parameters
Returns
operator *(XVector, XMatrix)
Transforms the coordinate space of the specified vector using the specified Matrix.
public static XVector operator *(XVector vector, XMatrix matrix)
Parameters
Returns
operator *(XVector, XVector)
Calculates the dot product of the two specified vector structures and returns the result as a Double.
public static double operator *(XVector vector1, XVector vector2)
Parameters
Returns
operator *(XVector, double)
Multiplies the specified vector by the specified scalar and returns the resulting vector.
public static XVector operator *(XVector vector, double scalar)
Parameters
Returns
operator *(double, XVector)
Multiplies the specified scalar by the specified vector and returns the resulting vector.
public static XVector operator *(double scalar, XVector vector)
Parameters
Returns
operator -(XVector, XVector)
Subtracts one specified vector from another.
public static XVector operator -(XVector vector1, XVector vector2)
Parameters
vector1
XVectorThe vector from which vector2 is subtracted.
vector2
XVectorThe vector to subtract from vector1.
Returns
operator -(XVector)
Negates the specified vector.
public static XVector operator -(XVector vector)
Parameters
vector
XVectorThe vector to negate.