Fri, 06 Mar 2020 16:08:53 +0200
begin work on axes program
55 | 1 | #pragma once |
2 | #include "basics.h" | |
3 | ||
4 | namespace geom | |
5 | { | |
6 | struct Plane | |
7 | { | |
8 | glm::vec3 normal; | |
9 | glm::vec3 anchor; | |
10 | }; | |
11 | ||
12 | struct Line | |
13 | { | |
14 | glm::vec3 direction; | |
15 | glm::vec3 anchor; | |
16 | }; | |
17 | ||
18 | template<int N> | |
19 | struct Polygon | |
20 | { | |
21 | glm::vec3 points[N]; | |
22 | }; | |
23 | ||
24 | inline const glm::vec3 origin = {0, 0, 0}; | |
25 | inline const Plane XY = {{0, 0, 1}, origin}; | |
26 | inline const Plane XZ = {{0, 1, 0}, origin}; | |
27 | inline const Plane YZ = {{1, 0, 0}, origin}; | |
28 | using Triangle = Polygon<3>; | |
29 | ||
30 | Line lineFromPoints(const glm::vec3& point_1, const glm::vec3 point_2); | |
31 | Plane planeFromTriangle(const Triangle& triangle); | |
32 | glm::vec3 normalVector(const Triangle& triangle); | |
64
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
33 | std::optional<glm::vec3> linePlaneIntersection(const Line& line, const Plane& plane, const float epsilon = 1e-6f); |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
34 | glm::vec3 scalingVector(const glm::mat4 matrix); |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
35 | struct ScalingExtract |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
36 | { |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
37 | glm::vec3 scaling; |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
38 | glm::mat4 unscaled; |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
39 | }; |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
40 | ScalingExtract extractScaling(const glm::mat4& matrix); |
55 | 41 | } |