gimpvector.h 8.72 KB
Newer Older
1 2 3
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
 *
4 5
 * gimpvector.h
 *
6 7 8 9
 * The gimp_vector* functions were taken from:
 * GCK - The General Convenience Kit
 * Copyright (C) 1996 Tom Bech
 *
10
 * This library is free software: you can redistribute it and/or
11 12
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
13
 * version 3 of the License, or (at your option) any later version.
14 15 16 17 18 19 20
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
21
 * License along with this library.  If not, see
22
 * <https://www.gnu.org/licenses/>.
23 24
 */

25 26 27 28
#if !defined (__GIMP_MATH_H_INSIDE__) && !defined (GIMP_MATH_COMPILATION)
#error "Only <libgimpmath/gimpmath.h> can be included directly."
#endif

29 30 31
#ifndef __GIMP_VECTOR_H__
#define __GIMP_VECTOR_H__

32
G_BEGIN_DECLS
33 34 35

/* For information look into the C source or the html documentation */

36 37 38 39

/* Two dimensional vector functions */
/* ================================ */

40 41 42 43 44
GimpVector2 gimp_vector2_new               (gdouble            x,
                                            gdouble            y);
void        gimp_vector2_set               (GimpVector2       *vector,
                                            gdouble            x,
                                            gdouble            y);
45 46 47 48 49 50
gdouble     gimp_vector2_length            (const GimpVector2 *vector);
gdouble     gimp_vector2_length_val        (GimpVector2        vector);
void        gimp_vector2_mul               (GimpVector2       *vector,
                                            gdouble            factor);
GimpVector2 gimp_vector2_mul_val           (GimpVector2        vector,
                                            gdouble            factor);
51 52 53 54 55 56 57 58 59
void        gimp_vector2_normalize         (GimpVector2       *vector);
GimpVector2 gimp_vector2_normalize_val     (GimpVector2        vector);
void        gimp_vector2_neg               (GimpVector2       *vector);
GimpVector2 gimp_vector2_neg_val           (GimpVector2        vector);
void        gimp_vector2_add               (GimpVector2       *result,
                                            const GimpVector2 *vector1,
                                            const GimpVector2 *vector2);
GimpVector2 gimp_vector2_add_val           (GimpVector2        vector1,
                                            GimpVector2        vector2);
60 61 62 63 64
void        gimp_vector2_sub               (GimpVector2       *result,
                                            const GimpVector2 *vector1,
                                            const GimpVector2 *vector2);
GimpVector2 gimp_vector2_sub_val           (GimpVector2        vector1,
                                            GimpVector2        vector2);
65
gdouble     gimp_vector2_inner_product     (const GimpVector2 *vector1,
66
                                            const GimpVector2 *vector2);
67 68 69 70 71
gdouble     gimp_vector2_inner_product_val (GimpVector2        vector1,
                                            GimpVector2        vector2);
GimpVector2 gimp_vector2_cross_product     (const GimpVector2 *vector1,
                                            const GimpVector2 *vector2);
GimpVector2 gimp_vector2_cross_product_val (GimpVector2        vector1,
72 73 74 75 76
                                            GimpVector2        vector2);
void        gimp_vector2_rotate            (GimpVector2       *vector,
                                            gdouble            alpha);
GimpVector2 gimp_vector2_rotate_val        (GimpVector2        vector,
                                            gdouble            alpha);
77 78
GimpVector2 gimp_vector2_normal            (GimpVector2       *vector);
GimpVector2 gimp_vector2_normal_val        (GimpVector2        vector);
79 80 81 82

/* Three dimensional vector functions */
/* ================================== */

83 84 85 86 87 88 89
GimpVector3 gimp_vector3_new               (gdouble            x,
                                            gdouble            y,
                                            gdouble            z);
void        gimp_vector3_set               (GimpVector3       *vector,
                                            gdouble            x,
                                            gdouble            y,
                                            gdouble            z);
90
gdouble     gimp_vector3_length            (const GimpVector3 *vector);
Sven Neumann's avatar
Sven Neumann committed
91
gdouble     gimp_vector3_length_val        (GimpVector3        vector);
92 93 94 95
void        gimp_vector3_mul               (GimpVector3       *vector,
                                            gdouble            factor);
GimpVector3 gimp_vector3_mul_val           (GimpVector3        vector,
                                            gdouble            factor);
96 97 98 99 100 101 102 103 104
void        gimp_vector3_normalize         (GimpVector3       *vector);
GimpVector3 gimp_vector3_normalize_val     (GimpVector3        vector);
void        gimp_vector3_neg               (GimpVector3       *vector);
GimpVector3 gimp_vector3_neg_val           (GimpVector3        vector);
void        gimp_vector3_add               (GimpVector3       *result,
                                            const GimpVector3 *vector1,
                                            const GimpVector3 *vector2);
GimpVector3 gimp_vector3_add_val           (GimpVector3        vector1,
                                            GimpVector3        vector2);
105 106 107 108 109
void        gimp_vector3_sub               (GimpVector3       *result,
                                            const GimpVector3 *vector1,
                                            const GimpVector3 *vector2);
GimpVector3 gimp_vector3_sub_val           (GimpVector3        vector1,
                                            GimpVector3        vector2);
110
gdouble     gimp_vector3_inner_product     (const GimpVector3 *vector1,
111
                                            const GimpVector3 *vector2);
112 113 114 115 116
gdouble     gimp_vector3_inner_product_val (GimpVector3        vector1,
                                            GimpVector3        vector2);
GimpVector3 gimp_vector3_cross_product     (const GimpVector3 *vector1,
                                            const GimpVector3 *vector2);
GimpVector3 gimp_vector3_cross_product_val (GimpVector3        vector1,
117 118 119 120 121 122 123 124 125
                                            GimpVector3        vector2);
void        gimp_vector3_rotate            (GimpVector3       *vector,
                                            gdouble            alpha,
                                            gdouble            beta,
                                            gdouble            gamma);
GimpVector3 gimp_vector3_rotate_val        (GimpVector3        vector,
                                            gdouble            alpha,
                                            gdouble            beta,
                                            gdouble            gamma);
126 127 128 129

/* 2d <-> 3d Vector projection functions */
/* ===================================== */

130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
void        gimp_vector_2d_to_3d           (gint               sx,
                                            gint               sy,
                                            gint               w,
                                            gint               h,
                                            gint               x,
                                            gint               y,
                                            const GimpVector3 *vp,
                                            GimpVector3       *p);

GimpVector3 gimp_vector_2d_to_3d_val       (gint               sx,
                                            gint               sy,
                                            gint               w,
                                            gint               h,
                                            gint               x,
                                            gint               y,
                                            GimpVector3        vp,
                                            GimpVector3        p);
Sven Neumann's avatar
Sven Neumann committed
147 148 149 150 151 152 153 154 155

void        gimp_vector_3d_to_2d           (gint               sx,
                                            gint               sy,
                                            gint               w,
                                            gint               h,
                                            gdouble           *x,
                                            gdouble           *y,
                                            const GimpVector3 *vp,
                                            const GimpVector3 *p);
156

157

158
G_END_DECLS
159 160

#endif  /* __GIMP_VECTOR_H__ */