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
|
#ifndef BLACKSHADES_QUATERNIONS_H
#define BLACKSHADES_QUATERNIONS_H
using namespace std;
struct XYZ {
float x, y, z;
};
#ifdef __cplusplus
constexpr bool operator==(const XYZ& u, const XYZ& v)
{
return u.x == v.x && u.y == v.y && u.z == v.z;
}
constexpr XYZ operator+(XYZ u, const XYZ& v)
{
return {u.x + v.x, u.y + v.y, u.z + v.z};
}
constexpr XYZ operator-(XYZ u, const XYZ& v)
{
return {u.x - v.x, u.y - v.y, u.z - v.z};
}
constexpr XYZ operator*(XYZ u, const XYZ& v)
{
return {u.x * v.x, u.y * v.y, u.z * v.z};
}
constexpr XYZ operator*(XYZ u, float k)
{
return {u.x * k, u.y * k, u.z * k};
}
constexpr XYZ operator/(XYZ u, float k)
{
return {u.x / k, u.y / k, u.z / k};
}
constexpr XYZ& operator+=(XYZ& u, const XYZ& v) { return u = u + v; }
constexpr XYZ& operator-=(XYZ& u, const XYZ& v) { return u = u - v; }
constexpr XYZ& operator*=(XYZ& u, const XYZ& v) { return u = u * v; }
constexpr XYZ& operator*=(XYZ& u, float k) { return u = u * k; }
constexpr XYZ& operator/=(XYZ& u, float k) { return u = u / k; }
float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ* p);
float LineFacetd(XYZ* p1, XYZ* p2, XYZ* pa, XYZ* pb, XYZ* pc, XYZ* n, XYZ* p);
#endif // __cplusplus
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void CrossProduct(XYZ P, XYZ Q, XYZ *V);
void Normalise(XYZ *vectory);
bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3);
void ReflectVector(XYZ *vel, XYZ *n);
XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang);
float findDistance(XYZ point1, XYZ point2);
float findLengthfast(XYZ point1);
float findDistancefast(XYZ point1, XYZ point2);
float dotproduct(XYZ point1, XYZ point2);
bool sphere_line_intersection(float x1, float y1, float z1,
float x2, float y2, float z2,
float x3, float y3, float z3, float r);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // BLACKSHADES_QUATERNIONS_H
|