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