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
34GRAPHENE_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 */
44struct _graphene_vec3_t
45{
46 /*< private >*/
47 GRAPHENE_ALIGNED_DECL (GRAPHENE_PRIVATE_FIELD (graphene_simd4f_t, value), 16);
48};
49
50GRAPHENE_AVAILABLE_IN_1_0
51graphene_vec3_t * graphene_vec3_alloc (void);
52GRAPHENE_AVAILABLE_IN_1_0
53void graphene_vec3_free (graphene_vec3_t *v);
54GRAPHENE_AVAILABLE_IN_1_0
55graphene_vec3_t * graphene_vec3_init (graphene_vec3_t *v,
56 float x,
57 float y,
58 float z);
59GRAPHENE_AVAILABLE_IN_1_0
60graphene_vec3_t * graphene_vec3_init_from_vec3 (graphene_vec3_t *v,
61 const graphene_vec3_t *src);
62GRAPHENE_AVAILABLE_IN_1_0
63graphene_vec3_t * graphene_vec3_init_from_float (graphene_vec3_t *v,
64 const float *src);
65GRAPHENE_AVAILABLE_IN_1_0
66void graphene_vec3_to_float (const graphene_vec3_t *v,
67 float *dest);
68GRAPHENE_AVAILABLE_IN_1_0
69void graphene_vec3_add (const graphene_vec3_t *a,
70 const graphene_vec3_t *b,
71 graphene_vec3_t *res);
72GRAPHENE_AVAILABLE_IN_1_0
73void graphene_vec3_subtract (const graphene_vec3_t *a,
74 const graphene_vec3_t *b,
75 graphene_vec3_t *res);
76GRAPHENE_AVAILABLE_IN_1_0
77void graphene_vec3_multiply (const graphene_vec3_t *a,
78 const graphene_vec3_t *b,
79 graphene_vec3_t *res);
80GRAPHENE_AVAILABLE_IN_1_0
81void graphene_vec3_divide (const graphene_vec3_t *a,
82 const graphene_vec3_t *b,
83 graphene_vec3_t *res);
84GRAPHENE_AVAILABLE_IN_1_0
85void graphene_vec3_cross (const graphene_vec3_t *a,
86 const graphene_vec3_t *b,
87 graphene_vec3_t *res);
88GRAPHENE_AVAILABLE_IN_1_0
89float graphene_vec3_dot (const graphene_vec3_t *a,
90 const graphene_vec3_t *b);
91GRAPHENE_AVAILABLE_IN_1_0
92float graphene_vec3_length (const graphene_vec3_t *v);
93GRAPHENE_AVAILABLE_IN_1_0
94void graphene_vec3_normalize (const graphene_vec3_t *v,
95 graphene_vec3_t *res);
96GRAPHENE_AVAILABLE_IN_1_2
97void graphene_vec3_scale (const graphene_vec3_t *v,
98 float factor,
99 graphene_vec3_t *res);
100GRAPHENE_AVAILABLE_IN_1_2
101void graphene_vec3_negate (const graphene_vec3_t *v,
102 graphene_vec3_t *res);
103GRAPHENE_AVAILABLE_IN_1_2
104bool graphene_vec3_equal (const graphene_vec3_t *v1,
105 const graphene_vec3_t *v2);
106GRAPHENE_AVAILABLE_IN_1_2
107bool graphene_vec3_near (const graphene_vec3_t *v1,
108 const graphene_vec3_t *v2,
109 float epsilon);
110GRAPHENE_AVAILABLE_IN_1_0
111void graphene_vec3_min (const graphene_vec3_t *a,
112 const graphene_vec3_t *b,
113 graphene_vec3_t *res);
114GRAPHENE_AVAILABLE_IN_1_0
115void graphene_vec3_max (const graphene_vec3_t *a,
116 const graphene_vec3_t *b,
117 graphene_vec3_t *res);
118GRAPHENE_AVAILABLE_IN_1_10
119void graphene_vec3_interpolate (const graphene_vec3_t *v1,
120 const graphene_vec3_t *v2,
121 double factor,
122 graphene_vec3_t *res);
123
124GRAPHENE_AVAILABLE_IN_1_0
125float graphene_vec3_get_x (const graphene_vec3_t *v);
126GRAPHENE_AVAILABLE_IN_1_0
127float graphene_vec3_get_y (const graphene_vec3_t *v);
128GRAPHENE_AVAILABLE_IN_1_0
129float graphene_vec3_get_z (const graphene_vec3_t *v);
130
131GRAPHENE_AVAILABLE_IN_1_0
132void graphene_vec3_get_xy (const graphene_vec3_t *v,
133 graphene_vec2_t *res);
134GRAPHENE_AVAILABLE_IN_1_0
135void graphene_vec3_get_xy0 (const graphene_vec3_t *v,
136 graphene_vec3_t *res);
137GRAPHENE_AVAILABLE_IN_1_0
138void graphene_vec3_get_xyz0 (const graphene_vec3_t *v,
139 graphene_vec4_t *res);
140GRAPHENE_AVAILABLE_IN_1_0
141void graphene_vec3_get_xyz1 (const graphene_vec3_t *v,
142 graphene_vec4_t *res);
143GRAPHENE_AVAILABLE_IN_1_0
144void graphene_vec3_get_xyzw (const graphene_vec3_t *v,
145 float w,
146 graphene_vec4_t *res);
147
148GRAPHENE_AVAILABLE_IN_1_0
149const graphene_vec3_t * graphene_vec3_zero (void);
150GRAPHENE_AVAILABLE_IN_1_0
151const graphene_vec3_t * graphene_vec3_one (void);
152GRAPHENE_AVAILABLE_IN_1_0
153const graphene_vec3_t * graphene_vec3_x_axis (void);
154GRAPHENE_AVAILABLE_IN_1_0
155const graphene_vec3_t * graphene_vec3_y_axis (void);
156GRAPHENE_AVAILABLE_IN_1_0
157const graphene_vec3_t * graphene_vec3_z_axis (void);
158
159GRAPHENE_END_DECLS
160

source code of gtk/subprojects/graphene/include/graphene-vec3.h