2009-11-09 22:42:41 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-11-09 22:42:41 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: some of this file.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
* */
|
|
|
|
|
|
|
|
#ifndef BLI_MATH_VECTOR
|
|
|
|
#define BLI_MATH_VECTOR
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2010-04-15 10:28:32 +00:00
|
|
|
#include "BLI_math_inline.h"
|
|
|
|
|
2009-11-10 19:13:05 +00:00
|
|
|
#ifdef BLI_MATH_INLINE
|
|
|
|
#include "intern/math_vector_inline.c"
|
|
|
|
#endif
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/************************************* Init ***********************************/
|
|
|
|
|
2009-11-10 19:13:05 +00:00
|
|
|
MINLINE void zero_v2(float r[2]);
|
|
|
|
MINLINE void zero_v3(float r[3]);
|
2010-01-22 11:10:24 +00:00
|
|
|
MINLINE void zero_v4(float r[4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2009-12-27 01:32:58 +00:00
|
|
|
MINLINE void copy_v2_v2(float r[2], const float a[2]);
|
|
|
|
MINLINE void copy_v3_v3(float r[3], const float a[3]);
|
2010-03-22 15:55:12 +00:00
|
|
|
MINLINE void copy_v4_v4(float r[4], const float a[4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2009-11-28 13:11:41 +00:00
|
|
|
MINLINE void swap_v2_v2(float a[2], float b[2]);
|
|
|
|
MINLINE void swap_v3_v3(float a[3], float b[3]);
|
2010-01-22 11:10:24 +00:00
|
|
|
MINLINE void swap_v4_v4(float a[4], float b[4]);
|
2009-11-28 13:11:41 +00:00
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
/********************************* Arithmetic ********************************/
|
|
|
|
|
2010-03-22 15:55:12 +00:00
|
|
|
MINLINE void add_v2_v2(float r[2], const float a[2]);
|
|
|
|
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2]);
|
|
|
|
MINLINE void add_v3_v3(float r[3], const float a[3]);
|
|
|
|
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2010-03-22 15:55:12 +00:00
|
|
|
MINLINE void sub_v2_v2(float r[2], const float a[2]);
|
|
|
|
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2]);
|
|
|
|
MINLINE void sub_v3_v3(float r[3], const float a[3]);
|
2009-12-27 01:32:58 +00:00
|
|
|
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2009-11-10 19:13:05 +00:00
|
|
|
MINLINE void mul_v2_fl(float r[2], float f);
|
2010-01-12 19:47:54 +00:00
|
|
|
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f);
|
2009-11-10 19:13:05 +00:00
|
|
|
MINLINE void mul_v3_fl(float r[3], float f);
|
2010-01-12 19:47:54 +00:00
|
|
|
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f);
|
2010-01-07 12:41:07 +00:00
|
|
|
MINLINE void mul_v2_v2(float r[2], const float a[2]);
|
2010-03-22 15:55:12 +00:00
|
|
|
MINLINE void mul_v3_v3(float r[3], const float a[3]);
|
|
|
|
MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
MINLINE void mul_v4_fl(float r[4], float f);
|
2010-03-22 15:55:12 +00:00
|
|
|
|
|
|
|
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
|
|
|
|
MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
|
|
|
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f);
|
|
|
|
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f);
|
|
|
|
MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
|
2010-04-15 10:28:32 +00:00
|
|
|
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
|
2009-11-28 13:11:41 +00:00
|
|
|
|
2009-11-10 19:13:05 +00:00
|
|
|
MINLINE void negate_v3(float r[3]);
|
2009-12-29 15:40:26 +00:00
|
|
|
MINLINE void negate_v3_v3(float r[3], const float a[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2009-12-29 15:40:26 +00:00
|
|
|
MINLINE float dot_v2v2(const float a[2], const float b[2]);
|
|
|
|
MINLINE float dot_v3v3(const float a[3], const float b[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2009-12-29 15:40:26 +00:00
|
|
|
MINLINE float cross_v2v2(const float a[2], const float b[2]);
|
2009-12-27 01:32:58 +00:00
|
|
|
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2009-11-10 19:13:05 +00:00
|
|
|
MINLINE void star_m3_v3(float R[3][3],float a[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/*********************************** Length **********************************/
|
|
|
|
|
2009-12-29 15:40:26 +00:00
|
|
|
MINLINE float len_v2(const float a[2]);
|
|
|
|
MINLINE float len_v2v2(const float a[2], const float b[2]);
|
2010-10-03 14:16:27 +00:00
|
|
|
MINLINE float len_squared_v2v2(const float a[3], const float b[3]);
|
2009-12-29 15:40:26 +00:00
|
|
|
MINLINE float len_v3(const float a[3]);
|
|
|
|
MINLINE float len_v3v3(const float a[3], const float b[3]);
|
2010-04-15 10:28:32 +00:00
|
|
|
MINLINE float len_squared_v3v3(const float a[3], const float b[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2009-11-10 19:13:05 +00:00
|
|
|
MINLINE float normalize_v2(float r[2]);
|
2010-01-12 19:47:54 +00:00
|
|
|
MINLINE float normalize_v2_v2(float r[2], const float a[2]);
|
2009-11-10 19:13:05 +00:00
|
|
|
MINLINE float normalize_v3(float r[3]);
|
2010-01-12 19:47:54 +00:00
|
|
|
MINLINE float normalize_v3_v3(float r[3], const float a[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/******************************* Interpolation *******************************/
|
|
|
|
|
2009-12-27 01:32:58 +00:00
|
|
|
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t);
|
|
|
|
void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[3], const float t[3]);
|
|
|
|
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t);
|
|
|
|
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]);
|
|
|
|
void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float w[4]);
|
2010-03-24 17:52:51 +00:00
|
|
|
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], const float t);
|
2010-04-15 10:28:32 +00:00
|
|
|
void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float w[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2010-09-28 11:48:13 +00:00
|
|
|
void mid_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/********************************* Comparison ********************************/
|
|
|
|
|
2010-01-22 11:10:24 +00:00
|
|
|
MINLINE int is_zero_v3(float a[3]);
|
|
|
|
MINLINE int is_one_v3(float a[3]);
|
|
|
|
|
|
|
|
MINLINE int equals_v3v3(float a[3], float b[3]);
|
|
|
|
MINLINE int compare_v3v3(float a[3], float b[3], float limit);
|
|
|
|
MINLINE int compare_len_v3v3(float a[3], float b[3], float limit);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2010-01-22 11:10:24 +00:00
|
|
|
MINLINE int compare_v4v4(float a[4], float b[4], float limit);
|
2010-07-27 04:56:24 +00:00
|
|
|
MINLINE int equals_v4v4(float a[4], float b[4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/********************************** Angles ***********************************/
|
|
|
|
/* - angle with 2 arguments is angle between vector */
|
|
|
|
/* - angle with 3 arguments is angle between 3 points at the middle point */
|
|
|
|
/* - angle_normalized_* is faster equivalent if vectors are normalized */
|
|
|
|
|
2010-09-28 11:48:13 +00:00
|
|
|
float angle_v2v2(const float a[2], const float b[2]);
|
|
|
|
float angle_v2v2v2(const float a[2], const float b[2], const float c[2]);
|
|
|
|
float angle_normalized_v2v2(const float a[2], const float b[2]);
|
|
|
|
float angle_v3v3(const float a[3], const float b[3]);
|
|
|
|
float angle_v3v3v3(const float a[3], const float b[3], const float c[3]);
|
2009-12-27 01:32:58 +00:00
|
|
|
float angle_normalized_v3v3(const float v1[3], const float v2[3]);
|
2009-12-15 09:39:46 +00:00
|
|
|
void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]);
|
|
|
|
void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/********************************* Geometry **********************************/
|
|
|
|
|
2010-09-28 11:48:13 +00:00
|
|
|
void project_v3_v3v3(float r[3], const float p[3], const float n[3]);
|
|
|
|
void reflect_v3_v3v3(float r[3], const float v[3], const float n[3]);
|
|
|
|
void ortho_basis_v3v3_v3(float r1[3], float r2[3], const float a[3]);
|
|
|
|
void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
|
2010-09-29 05:15:55 +00:00
|
|
|
void rotate_v3_v3v3fl(float v[3], const float p[3], const float axis[3], const float angle);
|
|
|
|
void rotate_normalized_v3_v3v3fl(float v[3], const float p[3], const float axis[3], const float angle);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/*********************************** Other ***********************************/
|
|
|
|
|
2010-08-25 08:31:52 +00:00
|
|
|
void print_v2(const char *str, const float a[2]);
|
|
|
|
void print_v3(const char *str, const float a[3]);
|
|
|
|
void print_v4(const char *str, const float a[4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2010-03-05 22:01:42 +00:00
|
|
|
MINLINE void normal_short_to_float_v3(float r[3], const short n[3]);
|
|
|
|
MINLINE void normal_float_to_short_v3(short r[3], const float n[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2010-09-28 11:48:13 +00:00
|
|
|
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* BLI_MATH_VECTOR */
|
|
|
|
|