aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/mimesh/libg3d-0.0.8/include/g3d/vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/mimesh/libg3d-0.0.8/include/g3d/vector.h')
-rw-r--r--src/others/mimesh/libg3d-0.0.8/include/g3d/vector.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/include/g3d/vector.h b/src/others/mimesh/libg3d-0.0.8/include/g3d/vector.h
new file mode 100644
index 0000000..aeb838c
--- /dev/null
+++ b/src/others/mimesh/libg3d-0.0.8/include/g3d/vector.h
@@ -0,0 +1,125 @@
1/* $Id$ */
2
3/*
4 libg3d - 3D object loading library
5
6 Copyright (C) 2005-2009 Markus Dahms <mad@automagically.de>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21*/
22
23#ifndef __G3D_VECTOR_H__
24#define __G3D_VECTOR_H__
25
26#include <g3d/types.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif /* ifdef __cplusplus */
31
32/**
33 * SECTION:vector
34 * @short_description: Vector manipulation and calculation
35 * @include: g3d/vector.h
36 *
37 * A vector is a one-dimensional array of floating point data.
38 *
39 * Declare it as statically as:
40 *
41 * G3DVector vector[3];
42 *
43 * or allocate it dynamically with:
44 *
45 * G3DVector *vector = g3d_vector_new(3, 1);
46 */
47
48/**
49 * g3d_vector_new:
50 * @size: number of items in one vector
51 * @n: number of vectors to allocate
52 *
53 * Allocate memory for a number of vectors.
54 *
55 * Returns: newly allocated vectors
56 */
57_G3D_STATIC_INLINE G3DVector *g3d_vector_new(guint32 size, guint32 n) {
58 return g_new0(G3DVector, size * n);
59}
60
61/**
62 * g3d_vector_free:
63 * @vector: vector to free
64 *
65 * Free memory allocated for vector.
66 */
67_G3D_STATIC_INLINE void g3d_vector_free(G3DVector *vector) {
68 g_free(vector);
69}
70
71/**
72 * g3d_vector_normal:
73 * @ax: x component first vector
74 * @ay: y component first vector
75 * @az: z component first vector
76 * @bx: x component second vector
77 * @by: y component second vector
78 * @bz: z component second vector
79 * @nx: x component resulting normal
80 * @ny: y component resulting normal
81 * @nz: z component resulting normal
82 *
83 * calculate the normal from a plane defined by two vectors
84 *
85 * Returns: TRUE on success, FALSE else
86 */
87EAPI
88gboolean g3d_vector_normal(G3DFloat ax, G3DFloat ay, G3DFloat az,
89 G3DFloat bx, G3DFloat by, G3DFloat bz,
90 G3DFloat *nx, G3DFloat *ny, G3DFloat *nz);
91
92/**
93 * g3d_vector_unify:
94 * @nx: x component of vector
95 * @ny: y component of vector
96 * @nz: z component of vector
97 *
98 * Transforms the given vector to the unit vector.
99 *
100 * Returns: TRUE on success, FALSE else
101 */
102EAPI
103gboolean g3d_vector_unify(G3DFloat *nx, G3DFloat *ny, G3DFloat *nz);
104
105/**
106 * g3d_vector_transform:
107 * @x: x component of vector
108 * @y: y component of vector
109 * @z: z component of vector
110 * @matrix: transformation matrix (4x4)
111 *
112 * Transforms the given vector corresponding to the given matrix
113 *
114 * Returns: TRUE on success, FALSE else
115 */
116EAPI
117gboolean g3d_vector_transform(G3DFloat *x, G3DFloat *y, G3DFloat *z,
118 G3DMatrix *matrix);
119
120#ifdef __cplusplus
121}
122#endif /* ifdef __cplusplus */
123
124#endif /* __G3D_VECTOR_H__ */
125