-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathctvector.h
102 lines (83 loc) · 2.11 KB
/
ctvector.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
Copyright 2016 Carter Turnbaugh
This file is part of Terca C++ Vector.
Terca C++ Vector is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Terca C++ Vector is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Terca C++ Vector. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define GMP
#define GRAPHICS
#include <sstream>
#ifdef GMP
#include <gmpxx.h>
#endif
class ctvector{
public:
#ifdef GMP
ctvector(mpf_class ctvx, mpf_class ctvy, mpf_class ctvz){
#else
ctvector(float ctvx, float ctvy, float ctvz){
#endif
x = ctvx;
y = ctvy;
z = ctvz;
}
ctvector(){
x = 0.0f;
y = 0.0f;
z = 0.0f;
}
std::string to_string();
// Proximity definition results in functioning as an array
// i.e. &x[0] == x, &x[1] == y, &x[2] == z
#ifdef GMP
mpf_class x;
mpf_class y;
mpf_class z;
#else
float x;
float y;
float z;
#endif
ctvector rotate(double tx, double ty, double tz);
ctvector operator+ (const ctvector& param);
ctvector operator- (const ctvector& param);
#ifdef GMP
mpf_class operator*= (const ctvector& param);
#else
double operator*= (const ctvector& param);
#endif
ctvector operator* (const int& scalar);
ctvector operator* (const double& scalar);
ctvector operator* (const float& scalar);
#ifdef GMP
ctvector operator* (const mpf_class& scalar);
#endif
// Products (dot and cross)
ctvector operator+= (const ctvector& param);
#ifdef GMP
mpf_class abs();
#else
double abs();
#endif
#ifdef GRAPHICS
void draw(ctvector in);
void draw();
#endif
};
#ifdef GMP
mpf_class abs(ctvector input);
#else
double abs(ctvector input);
#endif
#ifdef GRAPHICS
void gldraw(ctvector in);
#endif