-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAVector.h
More file actions
83 lines (57 loc) · 1.38 KB
/
AVector.h
File metadata and controls
83 lines (57 loc) · 1.38 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**************************************************************************/
/*!
@file AVector.h
@author Stuart Feichtinger
@license MIT (see license.txt)
Simple library for working with vectors. I got the idea from the
awesome book The Nature of Code: Simulating Natural Systems with
Processing by Daniel Shiffman http://natureofcode.com. You can
download it for free, but it's definitely worth buying!
(http://www.amazon.com/gp/product/0985930802)
@section HISTORY
v0.0.1 - First release
*/
/**************************************************************************/
#ifndef _AVECTOR_H_
#define _AVECTOR_H_
#include "Arduino.h"
#include <math.h>
class AVector {
public:
AVector(int x = 0, int y = 0);
AVector
add(int x, int y),
add(AVector *),
sub(int x, int y),
sub(AVector *),
mult(int),
div(int),
setMag(float),
rotate(float theta),
fromAngle(float theta);
float
distance(int x, int y),
distance(AVector *),
mag(),
heading(),
angleBetween(AVector *),
angleBetween(int x, int y),
angleBetweenFast(AVector *),
angleBetweenFast(int x, int y),
dot(int x, int y),
dot(AVector *);
void
set(int x, int y),
set(AVector *);
int
x(),
y(),
lerp(AVector *, int);
unsigned long
magSq();
private:
int
_x,
_y;
};
#endif