1 | /* graphene-plane.h: A plane in 3D space |
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 | #include "graphene-vec3.h" |
34 | |
35 | GRAPHENE_BEGIN_DECLS |
36 | |
37 | /** |
38 | * graphene_plane_t: |
39 | * |
40 | * A 2D plane that extends infinitely in a 3D volume. |
41 | * |
42 | * The contents of the `graphene_plane_t` are private, and should not be |
43 | * modified directly. |
44 | * |
45 | * Since: 1.2 |
46 | */ |
47 | struct _graphene_plane_t |
48 | { |
49 | /*< private >*/ |
50 | GRAPHENE_PRIVATE_FIELD (graphene_vec3_t, normal); |
51 | GRAPHENE_PRIVATE_FIELD (float, constant); |
52 | }; |
53 | |
54 | GRAPHENE_AVAILABLE_IN_1_2 |
55 | graphene_plane_t * graphene_plane_alloc (void); |
56 | GRAPHENE_AVAILABLE_IN_1_2 |
57 | void graphene_plane_free (graphene_plane_t *p); |
58 | |
59 | GRAPHENE_AVAILABLE_IN_1_2 |
60 | graphene_plane_t * graphene_plane_init (graphene_plane_t *p, |
61 | const graphene_vec3_t *normal, |
62 | float constant); |
63 | GRAPHENE_AVAILABLE_IN_1_2 |
64 | graphene_plane_t * graphene_plane_init_from_vec4 (graphene_plane_t *p, |
65 | const graphene_vec4_t *src); |
66 | GRAPHENE_AVAILABLE_IN_1_2 |
67 | graphene_plane_t * graphene_plane_init_from_plane (graphene_plane_t *p, |
68 | const graphene_plane_t *src); |
69 | GRAPHENE_AVAILABLE_IN_1_2 |
70 | graphene_plane_t * graphene_plane_init_from_point (graphene_plane_t *p, |
71 | const graphene_vec3_t *normal, |
72 | const graphene_point3d_t *point); |
73 | GRAPHENE_AVAILABLE_IN_1_2 |
74 | graphene_plane_t * graphene_plane_init_from_points (graphene_plane_t *p, |
75 | const graphene_point3d_t *a, |
76 | const graphene_point3d_t *b, |
77 | const graphene_point3d_t *c); |
78 | |
79 | GRAPHENE_AVAILABLE_IN_1_2 |
80 | void graphene_plane_normalize (const graphene_plane_t *p, |
81 | graphene_plane_t *res); |
82 | GRAPHENE_AVAILABLE_IN_1_2 |
83 | void graphene_plane_negate (const graphene_plane_t *p, |
84 | graphene_plane_t *res); |
85 | GRAPHENE_AVAILABLE_IN_1_2 |
86 | bool graphene_plane_equal (const graphene_plane_t *a, |
87 | const graphene_plane_t *b); |
88 | GRAPHENE_AVAILABLE_IN_1_2 |
89 | float graphene_plane_distance (const graphene_plane_t *p, |
90 | const graphene_point3d_t *point); |
91 | |
92 | GRAPHENE_AVAILABLE_IN_1_2 |
93 | void graphene_plane_get_normal (const graphene_plane_t *p, |
94 | graphene_vec3_t *normal); |
95 | GRAPHENE_AVAILABLE_IN_1_2 |
96 | float graphene_plane_get_constant (const graphene_plane_t *p); |
97 | |
98 | GRAPHENE_AVAILABLE_IN_1_10 |
99 | void graphene_plane_transform (const graphene_plane_t *p, |
100 | const graphene_matrix_t *matrix, |
101 | const graphene_matrix_t *normal_matrix, |
102 | graphene_plane_t *res); |
103 | |
104 | GRAPHENE_END_DECLS |
105 | |