-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector2.h
More file actions
46 lines (37 loc) · 1.01 KB
/
Copy pathVector2.h
File metadata and controls
46 lines (37 loc) · 1.01 KB
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
#ifndef _VECTOR2_H_
#define _VECTOR2_H_
#include <fstream>
#include <stdio.h>
//
// 2D Vector class
//
class Vector2
{
public:
inline Vector2();
inline Vector2( const Vector2 & a);
inline Vector2( float x, float y);
inline ~Vector2() {}
inline float & operator[]( int i)
{
return data[i];
}
inline const float & operator[]( int i) const
{
return data[i];
}
inline void set( float x, float y);
union {
float data[2];
struct {
float x, y;
};
};
};
inline void dot( const Vector2 & a, const Vector2 & b, float & r);
inline void add( const Vector2 & a, const Vector2 & b, Vector2 & r);
inline void subtract( const Vector2 & a, const Vector2 & b, Vector2 & r);
inline void scale( const Vector2 & a, float s, Vector2 & r);
inline void interp( const Vector2 & a, const Vector2 & b, const float alpha, Vector2 & r);
#include "Vector2.hpp"
#endif