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
35GRAPHENE_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 */
47struct _graphene_plane_t
48{
49 /*< private >*/
50 GRAPHENE_PRIVATE_FIELD (graphene_vec3_t, normal);
51 GRAPHENE_PRIVATE_FIELD (float, constant);
52};
53
54GRAPHENE_AVAILABLE_IN_1_2
55graphene_plane_t * graphene_plane_alloc (void);
56GRAPHENE_AVAILABLE_IN_1_2
57void graphene_plane_free (graphene_plane_t *p);
58
59GRAPHENE_AVAILABLE_IN_1_2
60graphene_plane_t * graphene_plane_init (graphene_plane_t *p,
61 const graphene_vec3_t *normal,
62 float constant);
63GRAPHENE_AVAILABLE_IN_1_2
64graphene_plane_t * graphene_plane_init_from_vec4 (graphene_plane_t *p,
65 const graphene_vec4_t *src);
66GRAPHENE_AVAILABLE_IN_1_2
67graphene_plane_t * graphene_plane_init_from_plane (graphene_plane_t *p,
68 const graphene_plane_t *src);
69GRAPHENE_AVAILABLE_IN_1_2
70graphene_plane_t * graphene_plane_init_from_point (graphene_plane_t *p,
71 const graphene_vec3_t *normal,
72 const graphene_point3d_t *point);
73GRAPHENE_AVAILABLE_IN_1_2
74graphene_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
79GRAPHENE_AVAILABLE_IN_1_2
80void graphene_plane_normalize (const graphene_plane_t *p,
81 graphene_plane_t *res);
82GRAPHENE_AVAILABLE_IN_1_2
83void graphene_plane_negate (const graphene_plane_t *p,
84 graphene_plane_t *res);
85GRAPHENE_AVAILABLE_IN_1_2
86bool graphene_plane_equal (const graphene_plane_t *a,
87 const graphene_plane_t *b);
88GRAPHENE_AVAILABLE_IN_1_2
89float graphene_plane_distance (const graphene_plane_t *p,
90 const graphene_point3d_t *point);
91
92GRAPHENE_AVAILABLE_IN_1_2
93void graphene_plane_get_normal (const graphene_plane_t *p,
94 graphene_vec3_t *normal);
95GRAPHENE_AVAILABLE_IN_1_2
96float graphene_plane_get_constant (const graphene_plane_t *p);
97
98GRAPHENE_AVAILABLE_IN_1_10
99void 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
104GRAPHENE_END_DECLS
105

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