1 | /* graphene-vec3.h: 3-coords vector |
2 | * |
3 | * SPDX-License-Identifier: MIT |
4 | * |
5 | * Copyright 2014 Emmanuele Bassi |
6 | * |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | * of this software and associated documentation files (the "Software"), to deal |
9 | * in the Software without restriction, including without limitation the rights |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 | * copies of the Software, and to permit persons to whom the Software is |
12 | * furnished to do so, subject to the following conditions: |
13 | * |
14 | * The above copyright notice and this permission notice shall be included in |
15 | * all copies or substantial portions of the Software. |
16 | * |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | * THE SOFTWARE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #if !defined(GRAPHENE_H_INSIDE) && !defined(GRAPHENE_COMPILATION) |
29 | #error "Only graphene.h can be included directly." |
30 | #endif |
31 | |
32 | #include "graphene-types.h" |
33 | |
34 | GRAPHENE_BEGIN_DECLS |
35 | |
36 | /** |
37 | * graphene_vec3_t: |
38 | * |
39 | * A structure capable of holding a vector with three dimensions: x, y, and z. |
40 | * |
41 | * The contents of the #graphene_vec3_t structure are private and should |
42 | * never be accessed directly. |
43 | */ |
44 | struct _graphene_vec3_t |
45 | { |
46 | /*< private >*/ |
47 | GRAPHENE_ALIGNED_DECL (GRAPHENE_PRIVATE_FIELD (graphene_simd4f_t, value), 16); |
48 | }; |
49 | |
50 | GRAPHENE_AVAILABLE_IN_1_0 |
51 | graphene_vec3_t * graphene_vec3_alloc (void); |
52 | GRAPHENE_AVAILABLE_IN_1_0 |
53 | void graphene_vec3_free (graphene_vec3_t *v); |
54 | GRAPHENE_AVAILABLE_IN_1_0 |
55 | graphene_vec3_t * graphene_vec3_init (graphene_vec3_t *v, |
56 | float x, |
57 | float y, |
58 | float z); |
59 | GRAPHENE_AVAILABLE_IN_1_0 |
60 | graphene_vec3_t * graphene_vec3_init_from_vec3 (graphene_vec3_t *v, |
61 | const graphene_vec3_t *src); |
62 | GRAPHENE_AVAILABLE_IN_1_0 |
63 | graphene_vec3_t * graphene_vec3_init_from_float (graphene_vec3_t *v, |
64 | const float *src); |
65 | GRAPHENE_AVAILABLE_IN_1_0 |
66 | void graphene_vec3_to_float (const graphene_vec3_t *v, |
67 | float *dest); |
68 | GRAPHENE_AVAILABLE_IN_1_0 |
69 | void graphene_vec3_add (const graphene_vec3_t *a, |
70 | const graphene_vec3_t *b, |
71 | graphene_vec3_t *res); |
72 | GRAPHENE_AVAILABLE_IN_1_0 |
73 | void graphene_vec3_subtract (const graphene_vec3_t *a, |
74 | const graphene_vec3_t *b, |
75 | graphene_vec3_t *res); |
76 | GRAPHENE_AVAILABLE_IN_1_0 |
77 | void graphene_vec3_multiply (const graphene_vec3_t *a, |
78 | const graphene_vec3_t *b, |
79 | graphene_vec3_t *res); |
80 | GRAPHENE_AVAILABLE_IN_1_0 |
81 | void graphene_vec3_divide (const graphene_vec3_t *a, |
82 | const graphene_vec3_t *b, |
83 | graphene_vec3_t *res); |
84 | GRAPHENE_AVAILABLE_IN_1_0 |
85 | void graphene_vec3_cross (const graphene_vec3_t *a, |
86 | const graphene_vec3_t *b, |
87 | graphene_vec3_t *res); |
88 | GRAPHENE_AVAILABLE_IN_1_0 |
89 | float graphene_vec3_dot (const graphene_vec3_t *a, |
90 | const graphene_vec3_t *b); |
91 | GRAPHENE_AVAILABLE_IN_1_0 |
92 | float graphene_vec3_length (const graphene_vec3_t *v); |
93 | GRAPHENE_AVAILABLE_IN_1_0 |
94 | void graphene_vec3_normalize (const graphene_vec3_t *v, |
95 | graphene_vec3_t *res); |
96 | GRAPHENE_AVAILABLE_IN_1_2 |
97 | void graphene_vec3_scale (const graphene_vec3_t *v, |
98 | float factor, |
99 | graphene_vec3_t *res); |
100 | GRAPHENE_AVAILABLE_IN_1_2 |
101 | void graphene_vec3_negate (const graphene_vec3_t *v, |
102 | graphene_vec3_t *res); |
103 | GRAPHENE_AVAILABLE_IN_1_2 |
104 | bool graphene_vec3_equal (const graphene_vec3_t *v1, |
105 | const graphene_vec3_t *v2); |
106 | GRAPHENE_AVAILABLE_IN_1_2 |
107 | bool graphene_vec3_near (const graphene_vec3_t *v1, |
108 | const graphene_vec3_t *v2, |
109 | float epsilon); |
110 | GRAPHENE_AVAILABLE_IN_1_0 |
111 | void graphene_vec3_min (const graphene_vec3_t *a, |
112 | const graphene_vec3_t *b, |
113 | graphene_vec3_t *res); |
114 | GRAPHENE_AVAILABLE_IN_1_0 |
115 | void graphene_vec3_max (const graphene_vec3_t *a, |
116 | const graphene_vec3_t *b, |
117 | graphene_vec3_t *res); |
118 | GRAPHENE_AVAILABLE_IN_1_10 |
119 | void graphene_vec3_interpolate (const graphene_vec3_t *v1, |
120 | const graphene_vec3_t *v2, |
121 | double factor, |
122 | graphene_vec3_t *res); |
123 | |
124 | GRAPHENE_AVAILABLE_IN_1_0 |
125 | float graphene_vec3_get_x (const graphene_vec3_t *v); |
126 | GRAPHENE_AVAILABLE_IN_1_0 |
127 | float graphene_vec3_get_y (const graphene_vec3_t *v); |
128 | GRAPHENE_AVAILABLE_IN_1_0 |
129 | float graphene_vec3_get_z (const graphene_vec3_t *v); |
130 | |
131 | GRAPHENE_AVAILABLE_IN_1_0 |
132 | void graphene_vec3_get_xy (const graphene_vec3_t *v, |
133 | graphene_vec2_t *res); |
134 | GRAPHENE_AVAILABLE_IN_1_0 |
135 | void graphene_vec3_get_xy0 (const graphene_vec3_t *v, |
136 | graphene_vec3_t *res); |
137 | GRAPHENE_AVAILABLE_IN_1_0 |
138 | void graphene_vec3_get_xyz0 (const graphene_vec3_t *v, |
139 | graphene_vec4_t *res); |
140 | GRAPHENE_AVAILABLE_IN_1_0 |
141 | void graphene_vec3_get_xyz1 (const graphene_vec3_t *v, |
142 | graphene_vec4_t *res); |
143 | GRAPHENE_AVAILABLE_IN_1_0 |
144 | void graphene_vec3_get_xyzw (const graphene_vec3_t *v, |
145 | float w, |
146 | graphene_vec4_t *res); |
147 | |
148 | GRAPHENE_AVAILABLE_IN_1_0 |
149 | const graphene_vec3_t * graphene_vec3_zero (void); |
150 | GRAPHENE_AVAILABLE_IN_1_0 |
151 | const graphene_vec3_t * graphene_vec3_one (void); |
152 | GRAPHENE_AVAILABLE_IN_1_0 |
153 | const graphene_vec3_t * graphene_vec3_x_axis (void); |
154 | GRAPHENE_AVAILABLE_IN_1_0 |
155 | const graphene_vec3_t * graphene_vec3_y_axis (void); |
156 | GRAPHENE_AVAILABLE_IN_1_0 |
157 | const graphene_vec3_t * graphene_vec3_z_axis (void); |
158 | |
159 | GRAPHENE_END_DECLS |
160 | |