dsfml.system.vector2

$(U Vector2) is a simple structure that defines a mathematical vector with two coordinates (x and y). It can be used to represent anything that has two dimensions: a size, a point, a velocity, etc.

The template parameter T is the type of the coordinates. It can be any type that supports arithmetic operations (+, -, /, *) and comparisons (==, !=), for example int or float.

You generally don't have to care about the templated form (Vector2!(T), the most common specializations have special aliases:

  • Vector2!(float) is Vector2f
  • Vector2!(int) is Vector2i
  • Vector2!(uint) is Vector2u

$(PARA The $(U Vector2) class has a small and simple interface, its x and y members can be accessed directly (there are no accessors like `setX()`, `getX()`) and it contains no mathematical function like dot product, cross product, length, etc.)

Members

Aliases

Vector2f
alias Vector2f = Vector2!(float)

Definition of a Vector2 of floats.

Vector2i
alias Vector2i = Vector2!(int)

Definition of a Vector2 of integers.

Vector2u
alias Vector2u = Vector2!(uint)

Definition of a Vector2 of unsigned integers.

Structs

Vector2
struct Vector2(T)

Utility template struct for manipulating 2-dimensional vectors.

Examples

1 auto v1 = Vector2f(16.5f, 24.f);
2 v1.x = 18.2f;
3 float y = v1.y;
4 
5 auto v2 = v1 * 5.f;
6 Vector2f v3;
7 v3 = v1 + v2;
8 
9 bool different = (v2 != v3);

See Also

$(VECTOR3_LINK)

Meta