Enhanced C#
Language of your choice: library documentation
|
Represents a two-dimensional vector, i.e. a magnitude and direction or the difference between two points, stored as X and Y components. More...
Represents a two-dimensional vector, i.e. a magnitude and direction or the difference between two points, stored as X and Y components.
A vector is the same as a point except for the operations it supports. For example, it usually does not make sense to add two points, but you can add two vectors (to get another vector) or you can add a vector to a point (to get a point).
If you really do need to add two points together or something like that, you can typecast from Point{T} to Vector{T}.
Although this structure contains operators such as + and -, their performance is suboptimal due to limitations of C#. The PointMath class of Loyc.Utilities.dll contains extension methods such as Add() and Sub() that perform faster on common coorindate types such as int and double.
T | : | IConvertible | |
T | : | IEquatable<T> |
Public fields | |
T | _y |
Properties | |
T | X [get, set] |
T | Y [get, set] |
Properties inherited from Loyc.Geometry.IPointBase< T > | |
new T | X [get, set] |
Horizontal coordinate of a point or vector. More... | |
new T | Y [get, set] |
Vertical coordinate of a point or vector. More... | |
Properties inherited from Loyc.Geometry.IPointReader< T > | |
T | X [get] |
T | Y [get] |
Static Public Member Functions | |
static | operator Point< T > (Vector< T > p) |
static | operator Vector< int > (Vector< T > p) |
static | operator Vector< long > (Vector< T > p) |
static | operator Vector< float > (Vector< T > p) |
static | operator Vector< double > (Vector< T > p) |
static Vector< T > | operator+ (Vector< T > a, Vector< T > b) |
static Vector< T > | operator- (Vector< T > a, Vector< T > b) |
static Vector< T > | operator* (Vector< T > p, T factor) |
static Vector< T > | operator/ (Vector< T > p, T factor) |
static Vector< T > | operator<< (Vector< T > p, int amt) |
static Vector< T > | operator>> (Vector< T > p, int amt) |
static T | operator* (Vector< T > a, Vector< T > b) |
Dot product. a*b equals lhs.Length*rhs.Length*Cos(theta) if theta is the angle between two vectors. More... | |
static Vector< T > | operator- (Vector< T > a) |
Reverses a vector. More... | |
static bool | operator== (Vector< T > a, Vector< T > b) |
static bool | operator!= (Vector< T > a, Vector< T > b) |
|
inlinestatic |
Dot product. a*b equals lhs.Length*rhs.Length*Cos(theta) if theta is the angle between two vectors.
|
inlinestatic |
Reverses a vector.