Mach1 Spatial SDK
Loading...
Searching...
No Matches
Mach1Point4D.h
1#ifndef MACH1POINT4D_H
2#define MACH1POINT4D_H
3
4// Mach1 Spatial SDK
5// Copyright © 2017 Mach1. All rights reserved.
6
7#ifndef DEG_TO_RAD
8# define DEG_TO_RAD (PI / 180.0)
9#endif
10
11#ifndef PI
12# define PI 3.14159265358979323846f
13#endif
14
15typedef struct Mach1Point4D {
16 float x, y, z, w;
17
18 Mach1Point4D operator+(const Mach1Point4D &pnt) const {
20 p.x = this->x + pnt.x;
21 p.y = this->y + pnt.y;
22 p.z = this->z + pnt.z;
23 p.w = this->w + pnt.w;
24 return p;
25 }
26
27 Mach1Point4D operator*(const float f) const {
29 p.x = this->x * f;
30 p.y = this->y * f;
31 p.z = this->z * f;
32 p.w = this->w * f;
33 return p;
34 }
35
36 Mach1Point4D operator*(const Mach1Point4D &pnt) const {
38 p.x = this->x * pnt.x;
39 p.y = this->y * pnt.y;
40 p.z = this->z * pnt.z;
41 p.w = this->w * pnt.w;
42 return p;
43 }
44
45 Mach1Point4D operator-(const Mach1Point4D &pnt) const {
47 p.x = this->x - pnt.x;
48 p.y = this->y - pnt.y;
49 p.z = this->z - pnt.z;
50 p.w = this->w - pnt.w;
51 return p;
52 }
53
54 float length() const {
55 return (float)sqrtf(x * x + y * y + z * z + w * w);
56 }
57
58 float operator[](int index) {
59 float arr[4] = {x, y, z, w};
60 return arr[index];
61 }
62
63 Mach1Point4D Mach1Point4D_create() {
65 p.x = 0;
66 p.y = 0;
67 p.z = 0;
68 p.w = 0;
69 return p;
70 }
71 Mach1Point4D Mach1Point4D_create(float X, float Y, float Z, float W) {
73 p.x = X;
74 p.y = Y;
75 p.z = Z;
76 p.w = W;
77 return p;
78 }
80
81#endif // MACH1POINT4D_H
Definition Mach1Point4D.h:15