1/* graphene-point3d.h: Point 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
34GRAPHENE_BEGIN_DECLS
35
36/**
37 * GRAPHENE_POINT3D_INIT:
38 * @_x: the X coordinate
39 * @_y: the Y coordinate
40 * @_z: the Z coordinate
41 *
42 * Initializes a #graphene_point3d_t to the given coordinates when declaring it.
43 *
44 * Since: 1.0
45 */
46#define GRAPHENE_POINT3D_INIT(_x,_y,_z) (graphene_point3d_t) { .x = (_x), .y = (_y), .z = (_z) }
47
48/**
49 * GRAPHENE_POINT3D_INIT_ZERO:
50 *
51 * Initializes a #graphene_point3d_t to (0, 0, 0) when declaring it.
52 *
53 * Since: 1.0
54 */
55#define GRAPHENE_POINT3D_INIT_ZERO GRAPHENE_POINT3D_INIT (0.f, 0.f, 0.f)
56
57/**
58 * graphene_point3d_t:
59 * @x: the X coordinate
60 * @y: the Y coordinate
61 * @z: the Z coordinate
62 *
63 * A point with three components: X, Y, and Z.
64 *
65 * Since: 1.0
66 */
67struct _graphene_point3d_t
68{
69 float x;
70 float y;
71 float z;
72};
73
74GRAPHENE_AVAILABLE_IN_1_0
75graphene_point3d_t * graphene_point3d_alloc (void);
76GRAPHENE_AVAILABLE_IN_1_0
77void graphene_point3d_free (graphene_point3d_t *p);
78
79GRAPHENE_AVAILABLE_IN_1_0
80graphene_point3d_t * graphene_point3d_init (graphene_point3d_t *p,
81 float x,
82 float y,
83 float z);
84GRAPHENE_AVAILABLE_IN_1_0
85graphene_point3d_t * graphene_point3d_init_from_point (graphene_point3d_t *p,
86 const graphene_point3d_t *src);
87GRAPHENE_AVAILABLE_IN_1_0
88graphene_point3d_t * graphene_point3d_init_from_vec3 (graphene_point3d_t *p,
89 const graphene_vec3_t *v);
90GRAPHENE_AVAILABLE_IN_1_0
91void graphene_point3d_to_vec3 (const graphene_point3d_t *p,
92 graphene_vec3_t *v);
93
94GRAPHENE_AVAILABLE_IN_1_0
95bool graphene_point3d_equal (const graphene_point3d_t *a,
96 const graphene_point3d_t *b);
97GRAPHENE_AVAILABLE_IN_1_0
98bool graphene_point3d_near (const graphene_point3d_t *a,
99 const graphene_point3d_t *b,
100 float epsilon);
101
102GRAPHENE_AVAILABLE_IN_1_0
103void graphene_point3d_scale (const graphene_point3d_t *p,
104 float factor,
105 graphene_point3d_t *res);
106GRAPHENE_AVAILABLE_IN_1_0
107void graphene_point3d_cross (const graphene_point3d_t *a,
108 const graphene_point3d_t *b,
109 graphene_point3d_t *res);
110GRAPHENE_AVAILABLE_IN_1_0
111float graphene_point3d_dot (const graphene_point3d_t *a,
112 const graphene_point3d_t *b);
113GRAPHENE_AVAILABLE_IN_1_0
114float graphene_point3d_length (const graphene_point3d_t *p);
115GRAPHENE_AVAILABLE_IN_1_0
116void graphene_point3d_normalize (const graphene_point3d_t *p,
117 graphene_point3d_t *res);
118GRAPHENE_AVAILABLE_IN_1_4
119float graphene_point3d_distance (const graphene_point3d_t *a,
120 const graphene_point3d_t *b,
121 graphene_vec3_t *delta);
122
123GRAPHENE_AVAILABLE_IN_1_0
124void graphene_point3d_interpolate (const graphene_point3d_t *a,
125 const graphene_point3d_t *b,
126 double factor,
127 graphene_point3d_t *res);
128
129GRAPHENE_AVAILABLE_IN_1_4
130void graphene_point3d_normalize_viewport (const graphene_point3d_t *p,
131 const graphene_rect_t *viewport,
132 float z_near,
133 float z_far,
134 graphene_point3d_t *res);
135
136GRAPHENE_AVAILABLE_IN_1_0
137const graphene_point3d_t * graphene_point3d_zero (void);
138
139GRAPHENE_END_DECLS
140

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