LeiaSR SDK 720218b2 v1.32.7.6322 2025-02-13T14:55:38Z
Stable
types.h
Go to the documentation of this file.
1
5#pragma once
6
7 /*
8 * Standard C/C++ definitions
9 */
10#if defined __cplusplus
11 /* Language: C++ */
12#else
13 /* Language: C */
14# if __STDC_VERSION__ >= 199901L
15 /* C version C99 or higher */
16# else
17 /* C version lower than C99 */
18 typedef _Bool bool;
19# endif
20#endif
21
22#include <stdint.h>
23
28typedef union {
29 int64_t p[2];
30 struct {
31 int64_t x;
32 int64_t y;
33 };
35
40typedef union {
41 double p[2];
42 struct {
43 double x;
44 double y;
45 };
47
48/*
49 * Operator overloading is only possible in C++
50 */
51#if defined __cplusplus
52inline SR_vector2d operator+(const SR_vector2d& l, const SR_vector2d& r) {
53 return SR_vector2d{ l.x + r.x, l.y + r.y };
54}
55inline SR_vector2d operator-(const SR_vector2d& l, const SR_vector2d& r) {
56 return SR_vector2d{ l.x - r.x, l.y - r.y };
57}
58inline SR_vector2d operator/(const SR_vector2d& l, const double& r) {
59 return SR_vector2d{ l.x / r, l.y / r };
60}
61inline SR_vector2d operator*(const SR_vector2d& l, const double& r) {
62 return SR_vector2d{ l.x * r, l.y * r };
63}
64inline SR_vector2d operator*(const SR_vector2d& l, const SR_vector2d& r) {
65 return SR_vector2d{ l.x * r.x, l.y * r.y };
66}
67#endif
68
73typedef union {
74 double p[3];
75 struct {
76 double x;
77 double y;
78 double z;
79 };
81
82/*
83 * Operator overloading is only possible in C++
84 */
85#if defined __cplusplus
86inline SR_vector3d operator+(const SR_vector3d& l, const SR_vector3d& r) {
87 return SR_vector3d{ l.x + r.x, l.y + r.y, l.z + r.z };
88}
89inline SR_vector3d operator-(const SR_vector3d& l, const SR_vector3d& r) {
90 return SR_vector3d{ l.x - r.x, l.y - r.y, l.z - r.z };
91}
92inline SR_vector3d operator/(const SR_vector3d& l, const double& r) {
93 return SR_vector3d{ l.x / r, l.y / r, l.z / r };
94}
95inline SR_vector3d operator*(const SR_vector3d& l, const double& r) {
96 return SR_vector3d{ l.x * r, l.y * r, l.z * r };
97}
98inline SR_vector3d operator*(const SR_vector3d& l, const SR_vector3d& r) {
99 return SR_vector3d{ l.x * r.x, l.y * r.y, l.z * r.z };
100}
101#endif
102
107typedef union {
108 int64_t p[4];
109 struct {
110 SR_point2i topLeft; // Top-left corner of the rectangle
111 SR_point2i bottomRight; // Bottom-right corner of the rectangle
112 };
113 struct {
114 int64_t left;
115 int64_t top;
116 int64_t right;
117 int64_t bottom;
118 };
119} SR_recti;
SR_vector2d operator+(const SR_vector2d &l, const SR_vector2d &r)
Definition: types.h:52
union SR_vector2i SR_point2i
SR_vector2d operator*(const SR_vector2d &l, const double &r)
Definition: types.h:61
SR_vector2d operator-(const SR_vector2d &l, const SR_vector2d &r)
Definition: types.h:55
SR_vector2d operator/(const SR_vector2d &l, const double &r)
Definition: types.h:58
union SR_vector2d SR_point2d
union SR_vector3d SR_point3d
C-compatible integer rectangle representation.
Definition: types.h:107
SR_point2i topLeft
Definition: types.h:110
int64_t top
Top-most border in the rectangle.
Definition: types.h:115
int64_t right
Right-most border in the rectangle.
Definition: types.h:116
SR_point2i bottomRight
Definition: types.h:111
int64_t bottom
Bottom-most border in the rectangle.
Definition: types.h:117
int64_t left
Left-most border in the rectangle.
Definition: types.h:114
C-compatible 2d double vector representation.
Definition: types.h:40
double y
Second value in the 2d vector.
Definition: types.h:44
double x
First value in the 2d vector.
Definition: types.h:43
C-compatible 2d integer vector representation.
Definition: types.h:28
int64_t y
Second value in the 2d vector.
Definition: types.h:32
int64_t x
First value in the 2d vector.
Definition: types.h:31
C-compatible 3d double vector representation.
Definition: types.h:73
double y
Second value in the 3d vector.
Definition: types.h:77
double z
Third value in the 3d vector.
Definition: types.h:78
double x
First value in the 3d vector.
Definition: types.h:76