Voltray Engine Docs
Loading...
Searching...
No Matches
Vec2.h
Go to the documentation of this file.
1#pragma once
2
7struct Vec2
8{
9 float x, y;
10
12 Vec2() : x(0.0f), y(0.0f) {}
13
17 Vec2(float x, float y) : x(x), y(y) {}
18
22 Vec2 operator+(const Vec2 &other) const
23 {
24 return Vec2(x + other.x, y + other.y);
25 }
26
30 Vec2 operator-(const Vec2 &other) const
31 {
32 return Vec2(x - other.x, y - other.y);
33 }
34
38 Vec2 operator*(float scalar) const
39 {
40 return Vec2(x * scalar, y * scalar);
41 }
42};
Represents a 2-dimensional vector with float components.
Definition Vec2.h:8
Vec2 operator-(const Vec2 &other) const
Definition Vec2.h:30
float y
The x and y components of the vector.
Definition Vec2.h:9
Vec2(float x, float y)
Definition Vec2.h:17
Vec2()
Default constructor. Initializes all components to zero.
Definition Vec2.h:12
Vec2 operator*(float scalar) const
Definition Vec2.h:38
Vec2 operator+(const Vec2 &other) const
Definition Vec2.h:22
float x
Definition Vec2.h:9