Vector2D StructureDelta Engine Documentation
Represents a 2D vector, which is useful for screen positions (sprites, mouse, touch, etc.) View code on GitHub

Namespace: DeltaEngine.Datatypes
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public struct Vector2D : IEquatable<Vector2D>, 
	Lerp<Vector2D>, Lerp

The Vector2D type exposes the following members.

Constructors

  NameDescription
Public methodVector2D(String)
Initializes a new instance of the Vector2D class
Public methodVector2D(Single, Single)
Initializes a new instance of the Vector2D class
Top
Methods

  NameDescription
Public methodAngleBetweenVector
Public methodDirectionTo
Public methodDistanceFromProjectAxisPointX
Public methodDistanceFromProjectAxisPointY
Public methodDistanceTo
Public methodDistanceToLine
http://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line View code on GitHub
Public methodDistanceToLineSegment
http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment View code on GitHub
Public methodDistanceToLineSquared
Public methodDistanceToSquared
Public methodDotProduct
Public methodEquals(Object) (Overrides ValueType Equals(Object).)
Public methodEquals(Vector2D)
Public methodGetHashCode (Overrides ValueType GetHashCode .)
Public methodGetRotation
Public methodIsLeftOfLineOrOnIt
http://stackoverflow.com/questions/3461453/determine-which-side-of-a-line-a-point-lies View code on GitHub
Public methodIsNearlyEqual
Public methodLerp
Public methodStatic memberNormalize
Public methodReflectIfHittingBorder
Public methodRotate
Public methodRotateAround(Vector2D, Single)
Public methodRotateAround(Vector2D, Single, Single)
Public methodRotationTo
Public methodToString (Overrides ValueType ToString .)
Top
Operators

  NameDescription
Public operatorStatic memberAddition
Public operatorStatic memberDivision(Vector2D, Size)
Public operatorStatic memberDivision(Vector2D, Single)
Public operatorStatic memberEquality
Public operatorStatic member (Size to Vector2D)
Public operatorStatic memberInequality
Public operatorStatic memberMultiply(Single, Vector2D)
Public operatorStatic memberMultiply(Vector2D, Size)
Public operatorStatic memberMultiply(Vector2D, Single)
Public operatorStatic memberSubtraction
Public operatorStatic memberUnaryNegation
Top
Fields

  NameDescription
Public fieldStatic memberHalf
Public fieldStatic memberOne
Public fieldStatic memberScreenDown
Public fieldStatic memberScreenLeft
Public fieldStatic memberScreenRight
Public fieldStatic memberScreenUp
Public fieldStatic memberSizeInBytes
Public fieldStatic memberUnitX
Public fieldStatic memberUnitY
Public fieldStatic memberUnused
Public fieldStatic memberZero
Top
Properties

  NameDescription
Public propertyLength
Public propertyLengthSquared
Public propertyX
Public propertyY
Top
Remarks

Tests: DeltaEngine.Tests.Datatypes.Vector2DTests
Examples

33 unit tests call DeltaEngine.Datatypes.Vector2D
[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