Initial checkin of Pika from heckimp
This commit is contained in:
11
libpikamath/Makefile.gi
Normal file
11
libpikamath/Makefile.gi
Normal file
@ -0,0 +1,11 @@
|
||||
# Introspectable sources for libpikamath
|
||||
#
|
||||
libpikamath_introspectable_headers = \
|
||||
../libpikamath/pikamathtypes.h \
|
||||
../libpikamath/pikamatrix.h \
|
||||
../libpikamath/pikavector.h
|
||||
|
||||
libpikamath_introspectable = \
|
||||
../libpikamath/pikamatrix.c \
|
||||
../libpikamath/pikavector.c \
|
||||
$(libpikamath_introspectable_headers)
|
46
libpikamath/meson.build
Normal file
46
libpikamath/meson.build
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
libpikamath_sources_introspectable = files(
|
||||
'pikamatrix.c',
|
||||
'pikavector.c',
|
||||
)
|
||||
|
||||
libpikamath_sources = [
|
||||
libpikamath_sources_introspectable,
|
||||
]
|
||||
|
||||
libpikamath_headers_introspectable = files(
|
||||
'pikamathtypes.h',
|
||||
'pikamatrix.h',
|
||||
'pikavector.h',
|
||||
)
|
||||
|
||||
libpikamath_headers = [
|
||||
libpikamath_headers_introspectable,
|
||||
'pikamath.h',
|
||||
]
|
||||
|
||||
libpikamath_introspectable = [
|
||||
libpikamath_sources_introspectable,
|
||||
libpikamath_headers_introspectable,
|
||||
]
|
||||
|
||||
|
||||
libpikamath = library('pikamath-' + pika_api_version,
|
||||
libpikamath_sources,
|
||||
include_directories: rootInclude,
|
||||
dependencies: [
|
||||
glib, gobject, math,
|
||||
],
|
||||
c_args: [ '-DG_LOG_DOMAIN="LibPikaMath"', '-DPIKA_MATH_COMPILATION', ],
|
||||
link_with: [
|
||||
libpikabase,
|
||||
],
|
||||
vs_module_defs: 'pikamath.def',
|
||||
install: true,
|
||||
version: so_version,
|
||||
)
|
||||
|
||||
install_headers(
|
||||
libpikamath_headers,
|
||||
subdir: pika_api_name / 'libpikamath',
|
||||
)
|
79
libpikamath/pikamath.def
Normal file
79
libpikamath/pikamath.def
Normal file
@ -0,0 +1,79 @@
|
||||
EXPORTS
|
||||
pika_matrix2_determinant
|
||||
pika_matrix2_get_type
|
||||
pika_matrix2_identity
|
||||
pika_matrix2_invert
|
||||
pika_matrix2_mult
|
||||
pika_matrix2_transform_point
|
||||
pika_matrix3_affine
|
||||
pika_matrix3_determinant
|
||||
pika_matrix3_equal
|
||||
pika_matrix3_get_type
|
||||
pika_matrix3_identity
|
||||
pika_matrix3_invert
|
||||
pika_matrix3_is_affine
|
||||
pika_matrix3_is_diagonal
|
||||
pika_matrix3_is_identity
|
||||
pika_matrix3_is_simple
|
||||
pika_matrix3_mult
|
||||
pika_matrix3_rotate
|
||||
pika_matrix3_scale
|
||||
pika_matrix3_transform_point
|
||||
pika_matrix3_translate
|
||||
pika_matrix3_xshear
|
||||
pika_matrix3_yshear
|
||||
pika_matrix4_identity
|
||||
pika_matrix4_mult
|
||||
pika_matrix4_to_deg
|
||||
pika_matrix4_transform_point
|
||||
pika_param_matrix2_get_type
|
||||
pika_param_matrix3_get_type
|
||||
pika_param_spec_matrix2
|
||||
pika_param_spec_matrix3
|
||||
pika_vector2_add
|
||||
pika_vector2_add_val
|
||||
pika_vector2_cross_product
|
||||
pika_vector2_cross_product_val
|
||||
pika_vector2_get_type
|
||||
pika_vector2_inner_product
|
||||
pika_vector2_inner_product_val
|
||||
pika_vector2_length
|
||||
pika_vector2_length_val
|
||||
pika_vector2_mul
|
||||
pika_vector2_mul_val
|
||||
pika_vector2_neg
|
||||
pika_vector2_neg_val
|
||||
pika_vector2_new
|
||||
pika_vector2_normal
|
||||
pika_vector2_normal_val
|
||||
pika_vector2_normalize
|
||||
pika_vector2_normalize_val
|
||||
pika_vector2_rotate
|
||||
pika_vector2_rotate_val
|
||||
pika_vector2_set
|
||||
pika_vector2_sub
|
||||
pika_vector2_sub_val
|
||||
pika_vector3_add
|
||||
pika_vector3_add_val
|
||||
pika_vector3_cross_product
|
||||
pika_vector3_cross_product_val
|
||||
pika_vector3_get_type
|
||||
pika_vector3_inner_product
|
||||
pika_vector3_inner_product_val
|
||||
pika_vector3_length
|
||||
pika_vector3_length_val
|
||||
pika_vector3_mul
|
||||
pika_vector3_mul_val
|
||||
pika_vector3_neg
|
||||
pika_vector3_neg_val
|
||||
pika_vector3_new
|
||||
pika_vector3_normalize
|
||||
pika_vector3_normalize_val
|
||||
pika_vector3_rotate
|
||||
pika_vector3_rotate_val
|
||||
pika_vector3_set
|
||||
pika_vector3_sub
|
||||
pika_vector3_sub_val
|
||||
pika_vector_2d_to_3d
|
||||
pika_vector_2d_to_3d_val
|
||||
pika_vector_3d_to_2d
|
152
libpikamath/pikamath.h
Normal file
152
libpikamath/pikamath.h
Normal file
@ -0,0 +1,152 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* pikamath.h
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PIKA_MATH_H__
|
||||
#define __PIKA_MATH_H__
|
||||
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <float.h>
|
||||
#endif
|
||||
|
||||
#define __PIKA_MATH_H_INSIDE__
|
||||
|
||||
#include <libpikamath/pikamathtypes.h>
|
||||
|
||||
#include <libpikamath/pikamatrix.h>
|
||||
#include <libpikamath/pikavector.h>
|
||||
|
||||
#undef __PIKA_MATH_H_INSIDE__
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* SECTION: pikamath
|
||||
* @title: PikaMath
|
||||
* @short_description: Mathematical definitions and macros.
|
||||
*
|
||||
* Mathematical definitions and macros for use both by the PIKA
|
||||
* application and plug-ins. These macros should be used rather than
|
||||
* the ones from <math.h> for enhanced portability.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* RINT:
|
||||
* @x: the value to be rounded
|
||||
*
|
||||
* This macro rounds its argument @x to an integer value in floating
|
||||
* point format. Use RINT() instead of rint().
|
||||
**/
|
||||
#if defined (HAVE_RINT) && 0
|
||||
/* note: rint() depends on the current floating-point rounding mode. when the
|
||||
* rounding mode is FE_TONEAREST, it, in parctice, breaks ties to even. this
|
||||
* is different from 'floor (x + 0.5)', which breaks ties up. in other words
|
||||
* 'rint (2.5) == 2.0', while 'floor (2.5 + 0.5) == 3.0'. this is asking for
|
||||
* trouble, so let's just use the latter.
|
||||
*/
|
||||
#define RINT(x) rint(x)
|
||||
#else
|
||||
#define RINT(x) floor ((x) + 0.5)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ROUND:
|
||||
* @x: the value to be rounded.
|
||||
*
|
||||
* This macro rounds its positive argument @x to the nearest integer.
|
||||
**/
|
||||
#define ROUND(x) ((int) ((x) + 0.5))
|
||||
|
||||
/**
|
||||
* SIGNED_ROUND:
|
||||
* @x: the value to be rounded.
|
||||
*
|
||||
* This macro rounds its argument @x to the nearest integer.
|
||||
**/
|
||||
#define SIGNED_ROUND(x) ((int) RINT (x))
|
||||
|
||||
/**
|
||||
* SQR:
|
||||
* @x: the value to be squared.
|
||||
*
|
||||
* This macro squares its argument @x.
|
||||
**/
|
||||
#define SQR(x) ((x) * (x))
|
||||
|
||||
/**
|
||||
* MAX255:
|
||||
* @a: the value to be limited.
|
||||
*
|
||||
* This macro limits it argument @a, an (0-511) int, to 255.
|
||||
**/
|
||||
#define MAX255(a) ((a) | (((a) & 256) - (((a) & 256) >> 8)))
|
||||
|
||||
/**
|
||||
* CLAMP0255:
|
||||
* @a: the value to be clamped.
|
||||
*
|
||||
* This macro clamps its argument @a, an int32-range int, between 0
|
||||
* and 255 inclusive.
|
||||
**/
|
||||
#define CLAMP0255(a) CLAMP(a,0,255)
|
||||
|
||||
/**
|
||||
* SAFE_CLAMP:
|
||||
* @x: the value to be limited.
|
||||
* @low: the lower limit.
|
||||
* @high: the upper limit.
|
||||
*
|
||||
* Ensures that @x is between the limits set by @low and @high,
|
||||
* even if @x is NaN. If @low is greater than @high, or if either
|
||||
* of them is NaN, the result is undefined.
|
||||
*
|
||||
* Since: 2.10
|
||||
**/
|
||||
#define SAFE_CLAMP(x, low, high) ((x) > (low) ? (x) < (high) ? (x) : (high) : (low))
|
||||
|
||||
/**
|
||||
* pika_deg_to_rad:
|
||||
* @angle: the angle to be converted.
|
||||
*
|
||||
* This macro converts its argument @angle from degree to radian.
|
||||
**/
|
||||
#define pika_deg_to_rad(angle) ((angle) * (2.0 * G_PI) / 360.0)
|
||||
|
||||
/**
|
||||
* pika_rad_to_deg:
|
||||
* @angle: the angle to be converted.
|
||||
*
|
||||
* This macro converts its argument @angle from radian to degree.
|
||||
**/
|
||||
#define pika_rad_to_deg(angle) ((angle) * 360.0 / (2.0 * G_PI))
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PIKA_MATH_H__ */
|
134
libpikamath/pikamathtypes.h
Normal file
134
libpikamath/pikamathtypes.h
Normal file
@ -0,0 +1,134 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* pikamathtypes.h
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PIKA_MATH_TYPES_H__
|
||||
#define __PIKA_MATH_TYPES_H__
|
||||
|
||||
|
||||
#include <libpikabase/pikabasetypes.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _PikaMatrix2 PikaMatrix2;
|
||||
typedef struct _PikaMatrix3 PikaMatrix3;
|
||||
typedef struct _PikaMatrix4 PikaMatrix4;
|
||||
|
||||
/**
|
||||
* PikaMatrix2
|
||||
* @coeff: the coefficients
|
||||
*
|
||||
* A two by two matrix.
|
||||
**/
|
||||
struct _PikaMatrix2
|
||||
{
|
||||
gdouble coeff[2][2];
|
||||
};
|
||||
|
||||
/**
|
||||
* PikaMatrix3
|
||||
* @coeff: the coefficients
|
||||
*
|
||||
* A three by three matrix.
|
||||
**/
|
||||
struct _PikaMatrix3
|
||||
{
|
||||
gdouble coeff[3][3];
|
||||
};
|
||||
|
||||
/**
|
||||
* PikaMatrix4
|
||||
* @coeff: the coefficients
|
||||
*
|
||||
* A four by four matrix.
|
||||
**/
|
||||
struct _PikaMatrix4
|
||||
{
|
||||
gdouble coeff[4][4];
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PikaVector2 PikaVector2;
|
||||
typedef struct _PikaVector3 PikaVector3;
|
||||
typedef struct _PikaVector4 PikaVector4;
|
||||
|
||||
/**
|
||||
* PikaVector2:
|
||||
* @x: the x axis
|
||||
* @y: the y axis
|
||||
*
|
||||
* A two dimensional vector.
|
||||
**/
|
||||
struct _PikaVector2
|
||||
{
|
||||
gdouble x, y;
|
||||
};
|
||||
|
||||
/**
|
||||
* PIKA_TYPE_VECTOR2:
|
||||
*
|
||||
* Boxed type representing a two-dimensional vector.
|
||||
*/
|
||||
#define PIKA_TYPE_VECTOR2 (pika_vector2_get_type ())
|
||||
|
||||
GType pika_vector2_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
/**
|
||||
* PikaVector3:
|
||||
* @x: the x axis
|
||||
* @y: the y axis
|
||||
* @z: the z axis
|
||||
*
|
||||
* A three dimensional vector.
|
||||
**/
|
||||
struct _PikaVector3
|
||||
{
|
||||
gdouble x, y, z;
|
||||
};
|
||||
|
||||
/**
|
||||
* PIKA_TYPE_VECTOR3:
|
||||
*
|
||||
* Boxed type representing a three-dimensional vector.
|
||||
*/
|
||||
#define PIKA_TYPE_VECTOR3 (pika_vector3_get_type ())
|
||||
|
||||
GType pika_vector3_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
/**
|
||||
* PikaVector4:
|
||||
* @x: the x axis
|
||||
* @y: the y axis
|
||||
* @z: the z axis
|
||||
* @w: the w axis
|
||||
*
|
||||
* A four dimensional vector.
|
||||
**/
|
||||
struct _PikaVector4
|
||||
{
|
||||
gdouble x, y, z, w;
|
||||
};
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PIKA_MATH_TYPES_H__ */
|
1039
libpikamath/pikamatrix.c
Normal file
1039
libpikamath/pikamatrix.c
Normal file
File diff suppressed because it is too large
Load Diff
157
libpikamath/pikamatrix.h
Normal file
157
libpikamath/pikamatrix.h
Normal file
@ -0,0 +1,157 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* pikamatrix.h
|
||||
* Copyright (C) 1998 Jay Cox <jaycox@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (__PIKA_MATH_H_INSIDE__) && !defined (PIKA_MATH_COMPILATION)
|
||||
#error "Only <libpikamath/pikamath.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __PIKA_MATRIX_H__
|
||||
#define __PIKA_MATRIX_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
/*****************/
|
||||
/* PikaMatrix2 */
|
||||
/*****************/
|
||||
|
||||
#define PIKA_TYPE_MATRIX2 (pika_matrix2_get_type ())
|
||||
#define PIKA_VALUE_HOLDS_MATRIX2(value) (G_TYPE_CHECK_VALUE_TYPE ((value), PIKA_TYPE_MATRIX2))
|
||||
|
||||
GType pika_matrix2_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#define PIKA_TYPE_PARAM_MATRIX2 (pika_param_matrix2_get_type ())
|
||||
#define PIKA_IS_PARAM_SPEC_MATRIX2(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), PIKA_TYPE_PARAM_MATRIX2))
|
||||
|
||||
GType pika_param_matrix2_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GParamSpec * pika_param_spec_matrix2 (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
const PikaMatrix2 *default_value,
|
||||
GParamFlags flags);
|
||||
|
||||
|
||||
void pika_matrix2_identity (PikaMatrix2 *matrix);
|
||||
void pika_matrix2_mult (const PikaMatrix2 *left,
|
||||
PikaMatrix2 *right);
|
||||
|
||||
gdouble pika_matrix2_determinant (const PikaMatrix2 *matrix);
|
||||
void pika_matrix2_invert (PikaMatrix2 *matrix);
|
||||
|
||||
void pika_matrix2_transform_point (const PikaMatrix2 *matrix,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble *newx,
|
||||
gdouble *newy);
|
||||
|
||||
|
||||
/*****************/
|
||||
/* PikaMatrix3 */
|
||||
/*****************/
|
||||
|
||||
#define PIKA_TYPE_MATRIX3 (pika_matrix3_get_type ())
|
||||
#define PIKA_VALUE_HOLDS_MATRIX3(value) (G_TYPE_CHECK_VALUE_TYPE ((value), PIKA_TYPE_MATRIX3))
|
||||
|
||||
GType pika_matrix3_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#define PIKA_TYPE_PARAM_MATRIX3 (pika_param_matrix3_get_type ())
|
||||
#define PIKA_IS_PARAM_SPEC_MATRIX3(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), PIKA_TYPE_PARAM_MATRIX3))
|
||||
|
||||
GType pika_param_matrix3_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GParamSpec * pika_param_spec_matrix3 (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
const PikaMatrix3 *default_value,
|
||||
GParamFlags flags);
|
||||
|
||||
|
||||
void pika_matrix3_identity (PikaMatrix3 *matrix);
|
||||
void pika_matrix3_mult (const PikaMatrix3 *left,
|
||||
PikaMatrix3 *right);
|
||||
void pika_matrix3_translate (PikaMatrix3 *matrix,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void pika_matrix3_scale (PikaMatrix3 *matrix,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void pika_matrix3_rotate (PikaMatrix3 *matrix,
|
||||
gdouble theta);
|
||||
void pika_matrix3_xshear (PikaMatrix3 *matrix,
|
||||
gdouble amount);
|
||||
void pika_matrix3_yshear (PikaMatrix3 *matrix,
|
||||
gdouble amount);
|
||||
void pika_matrix3_affine (PikaMatrix3 *matrix,
|
||||
gdouble a,
|
||||
gdouble b,
|
||||
gdouble c,
|
||||
gdouble d,
|
||||
gdouble e,
|
||||
gdouble f);
|
||||
|
||||
gdouble pika_matrix3_determinant (const PikaMatrix3 *matrix);
|
||||
void pika_matrix3_invert (PikaMatrix3 *matrix);
|
||||
|
||||
gboolean pika_matrix3_is_identity (const PikaMatrix3 *matrix);
|
||||
gboolean pika_matrix3_is_diagonal (const PikaMatrix3 *matrix);
|
||||
gboolean pika_matrix3_is_affine (const PikaMatrix3 *matrix);
|
||||
gboolean pika_matrix3_is_simple (const PikaMatrix3 *matrix);
|
||||
|
||||
gboolean pika_matrix3_equal (const PikaMatrix3 *matrix1,
|
||||
const PikaMatrix3 *matrix2);
|
||||
|
||||
void pika_matrix3_transform_point (const PikaMatrix3 *matrix,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble *newx,
|
||||
gdouble *newy);
|
||||
|
||||
|
||||
/*****************/
|
||||
/* PikaMatrix4 */
|
||||
/*****************/
|
||||
|
||||
void pika_matrix4_identity (PikaMatrix4 *matrix);
|
||||
void pika_matrix4_mult (const PikaMatrix4 *left,
|
||||
PikaMatrix4 *right);
|
||||
|
||||
void pika_matrix4_to_deg (const PikaMatrix4 *matrix,
|
||||
gdouble *a,
|
||||
gdouble *b,
|
||||
gdouble *c);
|
||||
|
||||
gdouble pika_matrix4_transform_point (const PikaMatrix4 *matrix,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble z,
|
||||
gdouble *newx,
|
||||
gdouble *newy,
|
||||
gdouble *newz);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PIKA_MATRIX_H__ */
|
1183
libpikamath/pikavector.c
Normal file
1183
libpikamath/pikavector.c
Normal file
File diff suppressed because it is too large
Load Diff
160
libpikamath/pikavector.h
Normal file
160
libpikamath/pikavector.h
Normal file
@ -0,0 +1,160 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* pikavector.h
|
||||
*
|
||||
* The pika_vector* functions were taken from:
|
||||
* GCK - The General Convenience Kit
|
||||
* Copyright (C) 1996 Tom Bech
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (__PIKA_MATH_H_INSIDE__) && !defined (PIKA_MATH_COMPILATION)
|
||||
#error "Only <libpikamath/pikamath.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __PIKA_VECTOR_H__
|
||||
#define __PIKA_VECTOR_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
/* Two dimensional vector functions */
|
||||
/* ================================ */
|
||||
|
||||
PikaVector2 pika_vector2_new (gdouble x,
|
||||
gdouble y);
|
||||
void pika_vector2_set (PikaVector2 *vector,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
gdouble pika_vector2_length (const PikaVector2 *vector);
|
||||
gdouble pika_vector2_length_val (PikaVector2 vector);
|
||||
void pika_vector2_mul (PikaVector2 *vector,
|
||||
gdouble factor);
|
||||
PikaVector2 pika_vector2_mul_val (PikaVector2 vector,
|
||||
gdouble factor);
|
||||
void pika_vector2_normalize (PikaVector2 *vector);
|
||||
PikaVector2 pika_vector2_normalize_val (PikaVector2 vector);
|
||||
void pika_vector2_neg (PikaVector2 *vector);
|
||||
PikaVector2 pika_vector2_neg_val (PikaVector2 vector);
|
||||
void pika_vector2_add (PikaVector2 *result,
|
||||
const PikaVector2 *vector1,
|
||||
const PikaVector2 *vector2);
|
||||
PikaVector2 pika_vector2_add_val (PikaVector2 vector1,
|
||||
PikaVector2 vector2);
|
||||
void pika_vector2_sub (PikaVector2 *result,
|
||||
const PikaVector2 *vector1,
|
||||
const PikaVector2 *vector2);
|
||||
PikaVector2 pika_vector2_sub_val (PikaVector2 vector1,
|
||||
PikaVector2 vector2);
|
||||
gdouble pika_vector2_inner_product (const PikaVector2 *vector1,
|
||||
const PikaVector2 *vector2);
|
||||
gdouble pika_vector2_inner_product_val (PikaVector2 vector1,
|
||||
PikaVector2 vector2);
|
||||
PikaVector2 pika_vector2_cross_product (const PikaVector2 *vector1,
|
||||
const PikaVector2 *vector2);
|
||||
PikaVector2 pika_vector2_cross_product_val (PikaVector2 vector1,
|
||||
PikaVector2 vector2);
|
||||
void pika_vector2_rotate (PikaVector2 *vector,
|
||||
gdouble alpha);
|
||||
PikaVector2 pika_vector2_rotate_val (PikaVector2 vector,
|
||||
gdouble alpha);
|
||||
PikaVector2 pika_vector2_normal (PikaVector2 *vector);
|
||||
PikaVector2 pika_vector2_normal_val (PikaVector2 vector);
|
||||
|
||||
/* Three dimensional vector functions */
|
||||
/* ================================== */
|
||||
|
||||
PikaVector3 pika_vector3_new (gdouble x,
|
||||
gdouble y,
|
||||
gdouble z);
|
||||
void pika_vector3_set (PikaVector3 *vector,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble z);
|
||||
gdouble pika_vector3_length (const PikaVector3 *vector);
|
||||
gdouble pika_vector3_length_val (PikaVector3 vector);
|
||||
void pika_vector3_mul (PikaVector3 *vector,
|
||||
gdouble factor);
|
||||
PikaVector3 pika_vector3_mul_val (PikaVector3 vector,
|
||||
gdouble factor);
|
||||
void pika_vector3_normalize (PikaVector3 *vector);
|
||||
PikaVector3 pika_vector3_normalize_val (PikaVector3 vector);
|
||||
void pika_vector3_neg (PikaVector3 *vector);
|
||||
PikaVector3 pika_vector3_neg_val (PikaVector3 vector);
|
||||
void pika_vector3_add (PikaVector3 *result,
|
||||
const PikaVector3 *vector1,
|
||||
const PikaVector3 *vector2);
|
||||
PikaVector3 pika_vector3_add_val (PikaVector3 vector1,
|
||||
PikaVector3 vector2);
|
||||
void pika_vector3_sub (PikaVector3 *result,
|
||||
const PikaVector3 *vector1,
|
||||
const PikaVector3 *vector2);
|
||||
PikaVector3 pika_vector3_sub_val (PikaVector3 vector1,
|
||||
PikaVector3 vector2);
|
||||
gdouble pika_vector3_inner_product (const PikaVector3 *vector1,
|
||||
const PikaVector3 *vector2);
|
||||
gdouble pika_vector3_inner_product_val (PikaVector3 vector1,
|
||||
PikaVector3 vector2);
|
||||
PikaVector3 pika_vector3_cross_product (const PikaVector3 *vector1,
|
||||
const PikaVector3 *vector2);
|
||||
PikaVector3 pika_vector3_cross_product_val (PikaVector3 vector1,
|
||||
PikaVector3 vector2);
|
||||
void pika_vector3_rotate (PikaVector3 *vector,
|
||||
gdouble alpha,
|
||||
gdouble beta,
|
||||
gdouble gamma);
|
||||
PikaVector3 pika_vector3_rotate_val (PikaVector3 vector,
|
||||
gdouble alpha,
|
||||
gdouble beta,
|
||||
gdouble gamma);
|
||||
|
||||
/* 2d <-> 3d Vector projection functions */
|
||||
/* ===================================== */
|
||||
|
||||
void pika_vector_2d_to_3d (gint sx,
|
||||
gint sy,
|
||||
gint w,
|
||||
gint h,
|
||||
gint x,
|
||||
gint y,
|
||||
const PikaVector3 *vp,
|
||||
PikaVector3 *p);
|
||||
|
||||
PikaVector3 pika_vector_2d_to_3d_val (gint sx,
|
||||
gint sy,
|
||||
gint w,
|
||||
gint h,
|
||||
gint x,
|
||||
gint y,
|
||||
PikaVector3 vp,
|
||||
PikaVector3 p);
|
||||
|
||||
void pika_vector_3d_to_2d (gint sx,
|
||||
gint sy,
|
||||
gint w,
|
||||
gint h,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
const PikaVector3 *vp,
|
||||
const PikaVector3 *p);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PIKA_VECTOR_H__ */
|
Reference in New Issue
Block a user