-
Notifications
You must be signed in to change notification settings - Fork 1
/
jablko3d.h
61 lines (50 loc) · 1.43 KB
/
jablko3d.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
// Jablko 3D geometry library
// Cale Overstreet
// February 24, 2020
// Used for 3D physics
#include <string>
#include <vector>
// Vector Definitions
namespace jablko3d {
struct vect {
vect();
vect(double x_in, double y_in, double z_in); // Base constructor, no precomputing
vect(char* float_vector);
~vect();
double x;
double y;
double z;
double mag;
double magnitude();
vect unit_vector();
std::string vector_string();
void operator = (vect);
};
vect operator + (vect, vect); // Standard vector addition
vect operator - (vect, vect); // Standard vector subtraction
vect operator * (vect, vect); // Multiplies each vector element by the corresponding element in the other vector
vect operator * (double, vect); // Scalar Multiplication
vect operator * (vect, double); // Scalar Mulitplication
vect cross_product(vect a, vect b); // a x b
double dot_product(vect, vect); // Standard vector dot product
}
// STL File Read
namespace jablko3d {
struct triangle {
triangle(vect normal_in, vect p1_in, vect p2_in, vect p3_in); // Constructor taking vects as parameters
triangle(char* facet); // Constructor that takes a binary STL facet as a parameter
vect normal;
vect p1;
vect p2;
vect p3;
vect area_vector;
double area;
};
struct stl_object {
stl_object();
stl_object(std::string filepath, std::string units);
std::string header;
unsigned int n_triangles;
std::vector<triangle> triangles;
};
}