Last Updated September 25, 2012
SFML supports 2D and 3D (geometric)vectors;
sf::Vector2f pos; sf::Vector3i col; 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);
The documentation for 2D vectors is here.
The 3D vector documentation is here.
Vectors can be manipulated with the Transform class
// define a translation transform sf::Transform translation; translation.translate(20, 50); // define a rotation transform sf::Transform rotation; rotation.rotate(45); // combine them sf::Transform transform = translation * rotation; // use the result to transform stuff... sf::Vector2f point = transform.transformPoint(10, 20); sf::FloatRect rect = transform.transformRect(sf::FloatRect(0, 0, 10, 100)); sf::Vector2f verts[3]; sf::Transform t; t.rotate(angVel); for(int i=0;i<3;i++) verts[i]=t.transformPoint(verts[i]);
Vectors can be used to represent vertices & colours in OpenGL.
© Ken Power 1996-2016