#include#include int main() { sf::Vector2f vec(3.f, 4.f); float len = vec.length(); std::cout << "Length of (" << vec.x << ", " << vec.y << "): " << len << std::endl; return 0; }
#includeIn this example, we use the GLM (OpenGL Mathematics) library to create a 2D vector of floats. We then call the length() function from the GLM library to calculate the length of the vector. The result should be 5, the length of the vector (3, 4). GLM is a header-only C++ library that provides vector and matrix mathematics for graphics programming. It is commonly used in game development and other graphics-intensive applications.#include int main() { glm::vec2 vec(3.f, 4.f); float len = glm::length(vec); std::cout << "Length of (" << vec.x << ", " << vec.y << "): " << len << std::endl; return 0; }