-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVec2.h
47 lines (26 loc) · 743 Bytes
/
Vec2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace sf;
struct Vec2 {
float x, y;
Vec2();
Vec2(float x, float y);
Vec2 normalize() const;
Vec2 rotate(float rads) const;
Vector2f toVector2f() const;
float dot(Vec2& v) const;
float cross(Vec2& v) const;
float distance(Vec2& v) const;
float distanceSquared(Vec2& v) const;
float mag() const;
float angleBetween(Vec2& v) const;
static Vec2 fromAngle(float rads);
Vec2 operator+(const Vec2& v) const;
Vec2 operator-(Vec2& v) const;
Vec2 operator*(float scalar) const;
Vec2 operator*(Vec2& v) const;
Vec2 operator/(float scalar) const;
Vec2 operator/(Vec2& v) const;
};
std::ostream& operator<<(std::ostream& stream, const Vec2& v);