sf::Vector2< T > Class Template Reference

Utility template class for manipulating 2-dimensional vectors. More...

#include <Vector2.hpp>

List of all members.

Public Member Functions

 Vector2 ()
 Default constructor.
 Vector2 (T X, T Y)
 Construct the vector from its coordinates.

Public Attributes

x
 X coordinate of the vector.
y
 Y coordinate of the vector.

Detailed Description

template<typename T>
class sf::Vector2< T >

Utility template class for manipulating 2-dimensional vectors.

sf::Vector2 is a simple class 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 (sf::Vector2<T>), the two most common specializations have special typedefs:

The sf::Vector2 class has a small and simple interface, its x and y members can be accessed directly (there's no accessor like SetX(), GetX()) and it contains no mathematical function like dot product, cross product, length, etc.

Usage example:

 sf::Vector2f v1(16.5f, 24.f);
 v1.x = 18.2f;
 float y = v1.y;

 sf::Vector2f v2 = v1 * 5.f;
 sf::Vector2f v3;
 v3 = v1 + v2;

 bool different = (v2 != v3);

Note: for 3-dimensional vectors, see sf::Vector3.

Definition at line 37 of file Vector2.hpp.


Constructor & Destructor Documentation

template<typename T>
sf::Vector2< T >::Vector2 (  ) 

Default constructor.

template<typename T>
sf::Vector2< T >::Vector2 ( X,
Y 
)

Construct the vector from its coordinates.

Parameters:
X X coordinate
Y Y coordinate

Member Data Documentation

template<typename T>
T sf::Vector2< T >::x

X coordinate of the vector.

Definition at line 59 of file Vector2.hpp.

template<typename T>
T sf::Vector2< T >::y

Y coordinate of the vector.

Definition at line 60 of file Vector2.hpp.


The documentation for this class was generated from the following file: