Created
August 25, 2017 08:30
-
-
Save MarioLiebisch/b5d9de83b649a63a5ac9c1b64bfa2822 to your computer and use it in GitHub Desktop.
Transforming a vector using SFML, e.g. by rotating it by 45 degree.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SFML/Graphics/Transform.hpp> | |
#include <SFML/System/Vector2.hpp> | |
#include <iostream> | |
int main() { | |
// First we'll need a vector to tranform | |
sf::Vector2f myVector(2, 0); | |
std::cout << "myVector: " << myVector.x << ", " << myVector.y << "\n"; | |
// Then the actual transform | |
sf::Transform myTransform; | |
myTransform.rotate(45); // Rotate by 45 degree | |
// Now calculate and output the resulting vector | |
sf::Vector2f myTransformedVector = myTransform.transformPoint(myVector); | |
std::cout << "myTransformedVector: " << myTransformedVector.x << ", " << myTransformedVector.y << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment