Simulated Reality SDK 7500c78d v1.30.2.51085 2024-04-26T11:23:03Z
Stable
types.h
Go to the documentation of this file.
1
10// TODO move into library shared with CNSDK
11// Duplicated from https://gitlab.dimenco.eu/simulatedreality/srCore/blob/c4657184/sr/utility/filter.h
12
13#pragma once
14
15 /*
16 * Standard C/C++ definitions
17 */
18#if defined __cplusplus
19 /* Language: C++ */
20#else
21 /* Language: C */
22# if __STDC_VERSION__ >= 199901L
23 /* C version C99 or higher */
24# else
25 /* C version lower than C99 */
26 typedef _Bool bool;
27# endif
28#endif
29
30#include <stdint.h>
31
36typedef union {
37 int64_t p[2];
38 struct {
39 int64_t x;
40 int64_t y;
41 };
43
48typedef union {
49 double p[2];
50 struct {
51 double x;
52 double y;
53 };
55
56/*
57 * Operator overloading is only possible in C++
58 */
59#if defined __cplusplus
60inline SR_vector2d operator+(const SR_vector2d& l, const SR_vector2d& r) {
61 return SR_vector2d{ l.x + r.x, l.y + r.y };
62}
63inline SR_vector2d operator-(const SR_vector2d& l, const SR_vector2d& r) {
64 return SR_vector2d{ l.x - r.x, l.y - r.y };
65}
66inline SR_vector2d operator/(const SR_vector2d& l, const double& r) {
67 return SR_vector2d{ l.x / r, l.y / r };
68}
69inline SR_vector2d operator*(const SR_vector2d& l, const double& r) {
70 return SR_vector2d{ l.x * r, l.y * r };
71}
72inline SR_vector2d operator*(const SR_vector2d& l, const SR_vector2d& r) {
73 return SR_vector2d{ l.x * r.x, l.y * r.y };
74}
75#endif
76
81typedef union {
82 double p[3];
83 struct {
84 double x;
85 double y;
86 double z;
87 };
89
90/*
91 * Operator overloading is only possible in C++
92 */
93#if defined __cplusplus
94inline SR_vector3d operator+(const SR_vector3d& l, const SR_vector3d& r) {
95 return SR_vector3d{ l.x + r.x, l.y + r.y, l.z + r.z };
96}
97inline SR_vector3d operator-(const SR_vector3d& l, const SR_vector3d& r) {
98 return SR_vector3d{ l.x - r.x, l.y - r.y, l.z - r.z };
99}
100inline SR_vector3d operator/(const SR_vector3d& l, const double& r) {
101 return SR_vector3d{ l.x / r, l.y / r, l.z / r };
102}
103inline SR_vector3d operator*(const SR_vector3d& l, const double& r) {
104 return SR_vector3d{ l.x * r, l.y * r, l.z * r };
105}
106inline SR_vector3d operator*(const SR_vector3d& l, const SR_vector3d& r) {
107 return SR_vector3d{ l.x * r.x, l.y * r.y, l.z * r.z };
108}
109#endif
110
115typedef union {
116 int64_t p[4];
117 struct {
118 SR_point2i topLeft; // Top-left corner of the rectangle
119 SR_point2i bottomRight; // Bottom-right corner of the rectangle
120 };
121 struct {
122 int64_t left;
123 int64_t top;
124 int64_t right;
125 int64_t bottom;
126 };
127} SR_recti;
SR_vector2d operator+(const SR_vector2d &l, const SR_vector2d &r)
Definition: types.h:60
union SR_vector2i SR_point2i
SR_vector2d operator*(const SR_vector2d &l, const double &r)
Definition: types.h:69
SR_vector2d operator-(const SR_vector2d &l, const SR_vector2d &r)
Definition: types.h:63
SR_vector2d operator/(const SR_vector2d &l, const double &r)
Definition: types.h:66
union SR_vector2d SR_point2d
union SR_vector3d SR_point3d
C-compatible integer rectangle representation.
Definition: types.h:115
SR_point2i topLeft
Definition: types.h:118
int64_t top
Top-most border in the rectangle.
Definition: types.h:123
int64_t right
Right-most border in the rectangle.
Definition: types.h:124
SR_point2i bottomRight
Definition: types.h:119
int64_t bottom
Bottom-most border in the rectangle.
Definition: types.h:125
int64_t left
Left-most border in the rectangle.
Definition: types.h:122
C-compatible 2d double vector representation.
Definition: types.h:48
double y
Second value in the 2d vector.
Definition: types.h:52
double x
First value in the 2d vector.
Definition: types.h:51
C-compatible 2d integer vector representation.
Definition: types.h:36
int64_t y
Second value in the 2d vector.
Definition: types.h:40
int64_t x
First value in the 2d vector.
Definition: types.h:39
C-compatible 3d double vector representation.
Definition: types.h:81
double y
Second value in the 3d vector.
Definition: types.h:85
double z
Third value in the 3d vector.
Definition: types.h:86
double x
First value in the 3d vector.
Definition: types.h:84