Class Vector
A vector structure implementation.
Inheritance
Namespace: Telerik.Windows.Diagrams.Core
Assembly: Telerik.Windows.Diagrams.Core.dll
Syntax
public sealed class Vector : ValueType
Constructors
Vector(Double, Double)
Initializes a new instance of the Vector struct.
Declaration
public Vector(double x, double y)
Parameters
System.Double
x
The x-coordinate. |
System.Double
y
The y-coordinate. |
Vector(Point)
Initializes a new instance of the Vector struct.
Declaration
public Vector(Point point)
Parameters
System.Windows.Point
point
The System.Windows.Point from which the coordinates will be used. |
Properties
Empty
Gets the empty vector.
Declaration
public static Vector Empty { get; }
Property Value
Vector
The empty. |
Length
Gets the length of this vector.
Declaration
public double Length { get; }
Property Value
System.Double
The length. |
LengthSquared
Returns the squared length of this vector.
Declaration
public double LengthSquared { get; }
Property Value
System.Double
|
X
Gets or sets the x-coordinate.
Declaration
public double X { get; set; }
Property Value
System.Double
The x-coordinate. |
Y
Gets or sets the y-coordinate.
Declaration
public double Y { get; set; }
Property Value
System.Double
The y-coordinate. |
Methods
Add(Point, Vector)
Adds the specified point.
Declaration
public static Point Add(Point point, Vector vector)
Parameters
System.Windows.Point
point
The point. |
Vector
vector
The vector. |
Returns
System.Windows.Point
|
Divide(Vector, Double)
Divides the specified vector.
Declaration
public static Vector Divide(Vector vector, double scalar)
Parameters
Vector
vector
The vector. |
System.Double
scalar
The scalar. |
Returns
Vector
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
System.Object
obj
The System.Object to compare with this instance. |
Returns
System.Boolean
|
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
System.Int32
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Multiply(Vector, Double)
Multiplies the specified vector.
Declaration
public static Vector Multiply(Vector vector, double scalar)
Parameters
Vector
vector
The vector. |
System.Double
scalar
The scalar. |
Returns
Vector
|
Negate(Vector, Vector)
Subtracts the specified vector1.
Declaration
public static Vector Negate(Vector vector1, Vector vector2)
Parameters
Vector
vector1
The vector1. |
Vector
vector2
The vector2. |
Returns
Vector
|
Normalize()
Normalizes this vector.
Declaration
public void Normalize()
Remarks
Use the ToUnit() method if you need the result as a returned vector.
Subtract(Point, Vector)
Subtract a point from a vector.
Declaration
public static Point Subtract(Point point, Vector vector)
Parameters
System.Windows.Point
point
The point which will be reduced with the given vector. |
Vector
vector
The vector which will reduce the point. |
Returns
System.Windows.Point
The result of the operation. |
ToString()
Returns a System.String that represents this instance.
Declaration
public override string ToString()
Returns
System.String
A System.String that represents this instance. |
ToUnit()
Returns the normalized vector, i.e. the unit vector with the same direction as this vector.
Declaration
public Vector ToUnit()
Returns
Vector
Return the Empty vector if the length of this vector is zero and the normalized vector if not. |
See Also
Operators
Addition(Point, Vector)
Implements the addition operator.
Declaration
public static Point operator +(Point point, Vector vector)
Parameters
System.Windows.Point
point
The point which will be augmented with the given vector. |
Vector
vector
The vector which will augment the point. |
Returns
System.Windows.Point
The result of the operation. |
Addition(Vector, Vector)
Adds two vectors and returns the result as a vector.
Declaration
public static Vector operator +(Vector vector1, Vector vector2)
Parameters
Vector
vector1
The first vector to add. |
Vector
vector2
The second vector to add. |
Returns
Vector
The sum of |
Division(Vector, Double)
Implements the division operation.
Declaration
public static Vector operator /(Vector vector, double value)
Parameters
Vector
vector
The vector which will be scaled. |
System.Double
value
The division/scaling factor. |
Returns
Vector
The result of the operation. |
Equality(Vector, Vector)
Implements the operator ==.
Declaration
public static bool operator ==(Vector vector1, Vector vector2)
Parameters
Vector
vector1
The vector1. |
Vector
vector2
The vector2. |
Returns
System.Boolean
The result of the operator. |
Inequality(Vector, Vector)
Implements the operator !=.
Declaration
public static bool operator !=(Vector vector1, Vector vector2)
Parameters
Vector
vector1
The vector1. |
Vector
vector2
The vector2. |
Returns
System.Boolean
The result of the operator. |
Multiply(Vector, Double)
Implements the multiplication operator.
Declaration
public static Vector operator *(Vector vector, double value)
Parameters
Vector
vector
The vector which will be multiplied. |
System.Double
value
The scaling factor. |
Returns
Vector
The result of the operation. |
Subtraction(Point, Vector)
Implements the substraction operator.
Declaration
public static Point operator -(Point point, Vector vector)
Parameters
System.Windows.Point
point
The point which will be reduced with the given vector. |
Vector
vector
The vector which will reduce the point. |
Returns
System.Windows.Point
The result of the operation. |
UnaryNegation(Vector)
Implements the subtraction operator.
Declaration
public static Vector operator -(Vector vector)
Parameters
Vector
vector
The second vector. |
Returns
Vector
The result of the operator. |