161 lines
8.7 KiB
C
161 lines
8.7 KiB
C
/* 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__ */
|