Struct Vector
Vector - A value type which defined a vector in terms of X and Y
Inherited Members
Namespace:ImGui
Assembly:ImGui.dll
Syntax
[Serializable]
public struct Vector : IFormattable
Constructors
| Improve this DocVector(Double, Double)
Constructor which sets the vector's initial values
Declaration
public Vector(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
System.Double | x | double - The initial X |
System.Double | y | double - THe initial Y |
Fields
| Improve this DocZero
Declaration
public static readonly Vector Zero
Field Value
Type | Description |
---|---|
Vector |
Properties
| Improve this DocLength
Length Property - the length of this Vector
Declaration
public double Length { get; }
Property Value
Type | Description |
---|---|
System.Double |
LengthSquared
LengthSquared Property - the squared length of this Vector
Declaration
public double LengthSquared { get; }
Property Value
Type | Description |
---|---|
System.Double |
X
X - double. Default value is 0.
Declaration
public double X { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Y
Y - double. Default value is 0.
Declaration
public double Y { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this DocAdd(Vector, Point)
Add: Vector + Point
Declaration
public static Point Add(Vector vector, Point point)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | |
Point | point |
Returns
Type | Description |
---|---|
Point |
Add(Vector, Vector)
Add: Vector + Vector
Declaration
public static Vector Add(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | |
Vector | vector2 |
Returns
Type | Description |
---|---|
Vector |
AngleBetween(Vector, Vector)
AngleBetween - the angle between 2 vectors
Declaration
public static double AngleBetween(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first Vector |
Vector | vector2 | The second Vector |
Returns
Type | Description |
---|---|
System.Double | Returns the the angle in degrees between vector1 and vector2 |
CrossProduct(Vector, Vector)
CrossProduct - Returns the cross product: vector1.Xvector2.Y - vector1.Yvector2.X
Declaration
public static double CrossProduct(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first Vector |
Vector | vector2 | The second Vector |
Returns
Type | Description |
---|---|
System.Double | Returns the cross product: vector1.Xvector2.Y - vector1.Yvector2.X |
Determinant(Vector, Vector)
Determinant - Returns the determinant det(vector1, vector2)
Declaration
public static double Determinant(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first Vector |
Vector | vector2 | The second Vector |
Returns
Type | Description |
---|---|
System.Double | Returns the determinant: vector1.Xvector2.Y - vector1.Yvector2.X |
Divide(Vector, Double)
Multiply: Vector / double
Declaration
public static Vector Divide(Vector vector, double scalar)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | |
System.Double | scalar |
Returns
Type | Description |
---|---|
Vector |
Equals(Vector)
Equals - compares this Vector with the passed in object. In this equality double.NaN is equal to itself, unlike in numeric equality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail.
Declaration
public bool Equals(Vector value)
Parameters
Type | Name | Description |
---|---|---|
Vector | value | The Vector to compare to "this" |
Returns
Type | Description |
---|---|
System.Boolean | bool - true if "value" is equal to "this". |
Equals(Vector, Vector)
Compares two Vector instances for object equality. In this equality double.NaN is equal to itself, unlike in numeric equality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail.
Declaration
public static bool Equals(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first Vector to compare |
Vector | vector2 | The second Vector to compare |
Returns
Type | Description |
---|---|
System.Boolean | bool - true if the two Vector instances are exactly equal, false otherwise |
Equals(Object)
Equals - compares this Vector with the passed in object. In this equality double.NaN is equal to itself, unlike in numeric equality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail.
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | The object to compare to "this" |
Returns
Type | Description |
---|---|
System.Boolean | bool - true if the object is an instance of Vector and if it's equal to "this". |
Overrides
GetHashCode()
Returns the HashCode for this Vector
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | int - the HashCode for this Vector |
Overrides
Multiply(Vector, Vector)
Multiply - Returns the dot product: vector1.Xvector2.X + vector1.Yvector2.Y
Declaration
public static double Multiply(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first Vector |
Vector | vector2 | The second Vector |
Returns
Type | Description |
---|---|
System.Double | Returns the dot product: vector1.Xvector2.X + vector1.Yvector2.Y |
Multiply(Vector, Double)
Multiply: Vector * double
Declaration
public static Vector Multiply(Vector vector, double scalar)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | |
System.Double | scalar |
Returns
Type | Description |
---|---|
Vector |
Multiply(Double, Vector)
Multiply: double * Vector
Declaration
public static Vector Multiply(double scalar, Vector vector)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scalar | |
Vector | vector |
Returns
Type | Description |
---|---|
Vector |
Negate()
Negates the values of X and Y on this Vector
Declaration
public void Negate()
Normalize()
Normalize - Updates this Vector to maintain its direction, but to have a length of 1. This is equivalent to dividing this Vector by Length
Declaration
public void Normalize()
Parse(String)
Parse - returns an instance converted from the provided string using the culture "en-US"
string with Vector dataDeclaration
public static Vector Parse(string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source |
Returns
Type | Description |
---|---|
Vector |
Subtract(Vector, Vector)
Subtract: Vector - Vector
Declaration
public static Vector Subtract(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | |
Vector | vector2 |
Returns
Type | Description |
---|---|
Vector |
ToString()
Creates a string representation of this object based on the current culture.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation of this object. |
Overrides
ToString(IFormatProvider)
Creates a string representation of this object based on the IFormatProvider passed in. If the provider is null, the CurrentCulture is used.
Declaration
public string ToString(IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | provider |
Returns
Type | Description |
---|---|
System.String | A string representation of this object. |
Operators
| Improve this DocAddition(Vector, Point)
Operator Vector + Point
Declaration
public static Point operator +(Vector vector, Point point)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | |
Point | point |
Returns
Type | Description |
---|---|
Point |
Addition(Vector, Vector)
Operator Vector + Vector
Declaration
public static Vector operator +(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | |
Vector | vector2 |
Returns
Type | Description |
---|---|
Vector |
Division(Vector, Double)
Operator Vector / double
Declaration
public static Vector operator /(Vector vector, double scalar)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | |
System.Double | scalar |
Returns
Type | Description |
---|---|
Vector |
Equality(Vector, Vector)
Compares two Vector instances for exact equality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail. Furthermore, using this equality operator, double.NaN is not equal to itself.
Declaration
public static bool operator ==(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first Vector to compare |
Vector | vector2 | The second Vector to compare |
Returns
Type | Description |
---|---|
System.Boolean | bool - true if the two Vector instances are exactly equal, false otherwise |
Explicit(Vector to Point)
Explicit conversion to Point
Declaration
public static explicit operator Point(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | Vector - the Vector to convert to a Point |
Returns
Type | Description |
---|---|
Point | Point - A Point equal to this Vector |
Explicit(Vector to Size)
Explicit conversion to Size. Note that since Size cannot contain negative values, the resulting size will contains the absolute values of X and Y
Declaration
public static explicit operator Size(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | Vector - the Vector to convert to a Size |
Returns
Type | Description |
---|---|
Size | Size - A Size equal to this Vector |
Inequality(Vector, Vector)
Compares two Vector instances for exact inequality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail. Furthermore, using this equality operator, double.NaN is not equal to itself.
Declaration
public static bool operator !=(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | The first Vector to compare |
Vector | vector2 | The second Vector to compare |
Returns
Type | Description |
---|---|
System.Boolean | bool - true if the two Vector instances are exactly unequal, false otherwise |
Multiply(Vector, Vector)
Operator Vector * Vector, interpreted as their dot product
Declaration
public static double operator *(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | |
Vector | vector2 |
Returns
Type | Description |
---|---|
System.Double |
Multiply(Vector, Double)
Operator Vector * double
Declaration
public static Vector operator *(Vector vector, double scalar)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | |
System.Double | scalar |
Returns
Type | Description |
---|---|
Vector |
Multiply(Double, Vector)
Operator double * Vector
Declaration
public static Vector operator *(double scalar, Vector vector)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scalar | |
Vector | vector |
Returns
Type | Description |
---|---|
Vector |
Subtraction(Vector, Vector)
Operator Vector - Vector
Declaration
public static Vector operator -(Vector vector1, Vector vector2)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector1 | |
Vector | vector2 |
Returns
Type | Description |
---|---|
Vector |
UnaryNegation(Vector)
Operator -Vector (unary negation)
Declaration
public static Vector operator -(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector |
Returns
Type | Description |
---|---|
Vector |
Explicit Interface Implementations
| Improve this DocIFormattable.ToString(String, IFormatProvider)
Creates a string representation of this object based on the format string and IFormatProvider passed in. If the provider is null, the CurrentCulture is used. See the documentation for IFormattable for more information.
Declaration
string IFormattable.ToString(string format, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | |
System.IFormatProvider | provider |
Returns
Type | Description |
---|---|
System.String | A string representation of this object. |