Represents a 2D vector, which is useful for screen positions (sprites, mouse, touch, etc.)
View code on GitHub
Namespace: DeltaEngine.DatatypesAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Vector2D type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Vector2D(String) | Initializes a new instance of the Vector2D class | |
Vector2D(Single, Single) | Initializes a new instance of the Vector2D class |
Methods
Name | Description | |
---|---|---|
AngleBetweenVector | ||
DirectionTo | ||
DistanceFromProjectAxisPointX | ||
DistanceFromProjectAxisPointY | ||
DistanceTo | ||
DistanceToLine |
http://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
View code on GitHub | |
DistanceToLineSegment |
http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
View code on GitHub | |
DistanceToLineSquared | ||
DistanceToSquared | ||
DotProduct | ||
Equals(Object) | (Overrides ValueType Equals(Object).) | |
Equals(Vector2D) | ||
GetHashCode | (Overrides ValueType GetHashCode .) | |
GetRotation | ||
IsLeftOfLineOrOnIt |
http://stackoverflow.com/questions/3461453/determine-which-side-of-a-line-a-point-lies
View code on GitHub | |
IsNearlyEqual | ||
Lerp | ||
Normalize | ||
ReflectIfHittingBorder | ||
Rotate | ||
RotateAround(Vector2D, Single) | ||
RotateAround(Vector2D, Single, Single) | ||
RotationTo | ||
ToString | (Overrides ValueType ToString .) |
Operators
Fields
Name | Description | |
---|---|---|
Half | ||
One | ||
ScreenDown | ||
ScreenLeft | ||
ScreenRight | ||
ScreenUp | ||
SizeInBytes | ||
UnitX | ||
UnitY | ||
Unused | ||
Zero |
Properties
Name | Description | |
---|---|---|
Length | ||
LengthSquared | ||
X | ||
Y |
Remarks
Examples
[Test] public void Create() { const float X = 3.51f; const float Y = 0.23f; var v = new Vector2D(X, Y); Assert.AreEqual(v.X, X); Assert.AreEqual(v.Y, Y); }
[Test] public void Statics() { Assert.AreEqual(new Vector2D(0, 0), Vector2D.Zero); Assert.AreEqual(new Vector2D(1, 1), Vector2D.One); Assert.AreEqual(new Vector2D(0.5f, 0.5f), Vector2D.Half); Assert.AreEqual(new Vector2D(1, 0), Vector2D.UnitX); Assert.AreEqual(new Vector2D(0, 1), Vector2D.UnitY); Assert.AreEqual(new Vector2D(1, 0), Vector2D.ScreenRight); Assert.AreEqual(new Vector2D(-1, 0), Vector2D.ScreenLeft); Assert.AreEqual(new Vector2D(0, -1), Vector2D.ScreenUp); Assert.AreEqual(new Vector2D(0, 1), Vector2D.ScreenDown); Assert.AreEqual(8, Vector2D.SizeInBytes); }
[Test] public void ChangePoint() { var v = new Vector2D(1.0f, 1.0f) { X = 2.1f, Y = 2.1f }; Assert.AreEqual(2.1f, v.X); Assert.AreEqual(2.1f, v.Y); }
See Also