-
Notifications
You must be signed in to change notification settings - Fork 0
/
CVector.h
60 lines (49 loc) · 1.48 KB
/
CVector.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
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// Created by Asher S. on 6/7/23.
//
#ifndef CVECTOR_CVECTOR_H
#define CVECTOR_CVECTOR_H
#include <iostream>
#include <ctime>
#include <vector>
#include <cstdlib>
#include <cmath>
class CVector {
public:
float x;
float y;
CVector(float x1, float y1);
//operator overloading
CVector operator+ (CVector param) const;
void operator+= (CVector param);
CVector operator- (CVector param) const;
void operator-= (CVector param);
CVector operator* (CVector param) const;
void operator*= (CVector param);
CVector operator/ (CVector param) const;
void operator/= (CVector param);
CVector operator% (CVector param) const;
void operator%= (CVector param);
bool operator== (CVector param) const;
//methods
void set(float x, float y);
void set(CVector v1);
static CVector duplicate(CVector v1);
float mag() const;
float magSq() const;
float dot(CVector v1) const;
float dist(CVector v1) const;
void normalize(float value);
void limit(float limit);
void setMag(float mag);
float heading() const;
void setHeading(float angle);
void rotate(float angle);
static std::vector<float> array(CVector v1);
static CVector random2D(float minX, float maxX, float minY, float maxY);
static CVector fromAngle(float angle, float length);
static CVector fromAngle(float angle);
static CVector fromAngles(float theta, float phi);
void lerp(CVector v, float amt);
};
#endif //CVECTOR_CVECTOR_H