#include#include "Vec2.h" int main() { Vec2 position(1.0f, 2.0f); std::cout << "Position x=" << position.x << ", y=" << position.y << std::endl; return 0; }
#includeThis example shows how to perform vector arithmetic operations such as addition, multiplication, and finding the length of the vector using the length() method. This example also shows the use of operator overloading to perform vector operations. Vec2 belongs to the package or library called MathGeoLib, which provides various mathematics operations related to geometry, linear algebra, and physics.#include "Vec2.h" int main() { Vec2 position(1.0f, 2.0f); Vec2 velocity(3.0f, 4.0f); Vec2 acceleration(0.1f, 0.2f); position += velocity; velocity += acceleration; position *= 2.0f; std::cout << "Position x=" << position.x << ", y=" << position.y << std::endl; std::cout << "Velocity x=" << velocity.x << ", y=" << velocity.y << std::endl; float distance = velocity.length(); std::cout << "Distance=" << distance << std::endl; return 0; }