2011-02-18 13:58:08 +00:00
|
|
|
/*
|
2009-11-09 22:42:41 +00:00
|
|
|
* ***** 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 *****
|
|
|
|
* */
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLI_MATH_VECTOR_H__
|
|
|
|
#define __BLI_MATH_VECTOR_H__
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2011-02-18 13:58:08 +00:00
|
|
|
/** \file BLI_math_vector.h
|
|
|
|
* \ingroup bli
|
|
|
|
*/
|
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
#include "BLI_compiler_attrs.h"
|
2010-04-15 10:28:32 +00:00
|
|
|
#include "BLI_math_inline.h"
|
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
/************************************* Init ***********************************/
|
|
|
|
|
2013-03-13 15:41:14 +00:00
|
|
|
#ifdef BLI_MATH_GCC_WARN_PRAGMA
|
2013-03-11 20:27:38 +00:00
|
|
|
# pragma GCC diagnostic push
|
|
|
|
# pragma GCC diagnostic ignored "-Wredundant-decls"
|
|
|
|
#endif
|
|
|
|
|
2013-08-01 17:15:11 +00:00
|
|
|
|
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
|
|
|
|
2012-02-29 04:17:26 +00:00
|
|
|
MINLINE void copy_v2_fl(float r[2], float f);
|
|
|
|
MINLINE void copy_v3_fl(float r[3], float f);
|
|
|
|
MINLINE void copy_v4_fl(float r[4], float f);
|
|
|
|
|
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
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
/* char */
|
|
|
|
MINLINE void copy_v2_v2_char(char r[2], const char a[2]);
|
|
|
|
MINLINE void copy_v3_v3_char(char r[3], const char a[3]);
|
|
|
|
MINLINE void copy_v4_v4_char(char r[4], const char a[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
2011-09-12 04:14:12 +00:00
|
|
|
/* short */
|
|
|
|
MINLINE void copy_v2_v2_short(short r[2], const short a[2]);
|
|
|
|
MINLINE void copy_v3_v3_short(short r[3], const short a[3]);
|
|
|
|
MINLINE void copy_v4_v4_short(short r[4], const short a[4]);
|
2011-11-07 01:38:32 +00:00
|
|
|
/* int */
|
2012-10-10 13:18:07 +00:00
|
|
|
MINLINE void zero_v3_int(int r[3]);
|
2011-11-07 01:38:32 +00:00
|
|
|
MINLINE void copy_v2_v2_int(int r[2], const int a[2]);
|
|
|
|
MINLINE void copy_v3_v3_int(int r[3], const int a[3]);
|
|
|
|
MINLINE void copy_v4_v4_int(int r[4], const int a[4]);
|
2012-03-09 06:04:17 +00:00
|
|
|
/* double -> float */
|
|
|
|
MINLINE void copy_v2fl_v2db(float r[2], const double a[2]);
|
|
|
|
MINLINE void copy_v3fl_v3db(float r[3], const double a[3]);
|
|
|
|
MINLINE void copy_v4fl_v4db(float r[4], const double a[4]);
|
|
|
|
/* float -> double */
|
|
|
|
MINLINE void copy_v2db_v2fl(double r[2], const float a[2]);
|
|
|
|
MINLINE void copy_v3db_v3fl(double r[3], const float a[3]);
|
|
|
|
MINLINE void copy_v4db_v4fl(double r[4], const float a[4]);
|
2013-10-22 03:31:21 +00:00
|
|
|
/* float args -> vec */
|
2013-11-26 20:53:26 +11:00
|
|
|
MINLINE void copy_v2_fl2(float v[2], float x, float y);
|
2013-10-18 23:38:51 +00:00
|
|
|
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z);
|
2013-10-22 03:31:21 +00:00
|
|
|
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w);
|
2011-09-12 04:14:12 +00:00
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
/********************************* Arithmetic ********************************/
|
|
|
|
|
2012-09-05 23:22:47 +00:00
|
|
|
MINLINE void add_v2_fl(float r[2], float f);
|
2011-06-06 22:10:05 +00:00
|
|
|
MINLINE void add_v3_fl(float r[3], float f);
|
|
|
|
MINLINE void add_v4_fl(float r[4], float f);
|
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]);
|
2013-03-31 00:38:50 +00:00
|
|
|
MINLINE void add_v2_v2v2_int(int r[2], const int a[2], const int b[2]);
|
2010-03-22 15:55:12 +00:00
|
|
|
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]);
|
2012-06-12 20:04:55 +00:00
|
|
|
MINLINE void add_v4_v4(float r[4], const float a[4]);
|
|
|
|
MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4]);
|
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]);
|
2013-03-31 00:38:50 +00:00
|
|
|
MINLINE void sub_v2_v2v2_int(int r[2], const int a[2], const int b[2]);
|
2010-03-22 15:55:12 +00:00
|
|
|
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]);
|
2010-11-12 11:16:04 +00:00
|
|
|
MINLINE void sub_v4_v4(float r[4], const float a[4]);
|
|
|
|
MINLINE void sub_v4_v4v4(float r[4], const float a[4], const float b[4]);
|
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);
|
2012-06-12 20:04:55 +00:00
|
|
|
MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f);
|
2014-04-03 21:47:03 +11:00
|
|
|
MINLINE void mul_v2_v2_cw(float r[2], const float mat[2], const float vec[2]);
|
|
|
|
MINLINE void mul_v2_v2_ccw(float r[2], const float mat[2], const float vec[2]);
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float dot_m3_v3_row_x(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float dot_m3_v3_row_y(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
2013-11-20 11:46:22 +11:00
|
|
|
MINLINE float dot_m4_v3_row_x(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float dot_m4_v3_row_y(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float dot_m4_v3_row_z(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
2010-03-22 15:55:12 +00:00
|
|
|
|
2013-12-06 03:46:27 +11:00
|
|
|
MINLINE void madd_v2_v2fl(float r[2], const float a[2], 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);
|
2012-06-12 20:04:55 +00:00
|
|
|
MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4]);
|
2009-11-28 13:11:41 +00:00
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
MINLINE void negate_v2(float r[2]);
|
|
|
|
MINLINE void negate_v2_v2(float r[2], const float a[2]);
|
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]);
|
2011-02-02 00:40:55 +00:00
|
|
|
MINLINE void negate_v4(float r[4]);
|
2011-02-08 03:37:49 +00:00
|
|
|
MINLINE void negate_v4_v4(float r[4], const float a[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2012-05-13 11:05:52 +00:00
|
|
|
MINLINE void negate_v3_short(short r[3]);
|
|
|
|
|
2015-03-17 18:13:35 +01:00
|
|
|
MINLINE void abs_v2(float r[2]);
|
|
|
|
MINLINE void abs_v2_v2(float r[2], const float a[2]);
|
|
|
|
MINLINE void abs_v3(float r[3]);
|
|
|
|
MINLINE void abs_v3_v3(float r[3], const float a[3]);
|
|
|
|
MINLINE void abs_v4(float r[4]);
|
|
|
|
MINLINE void abs_v4_v4(float r[4], const float a[4]);
|
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
|
2015-01-09 12:23:34 +01:00
|
|
|
MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
|
2013-12-04 09:23:29 +11:00
|
|
|
MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
|
2009-12-27 01:32:58 +00:00
|
|
|
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
2012-04-16 16:49:37 +00:00
|
|
|
|
|
|
|
MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
MINLINE void star_m3_v3(float rmat[3][3], float a[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/*********************************** Length **********************************/
|
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_manhattan_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE int len_manhattan_v2_int(const int v[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_manhattan_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
|
2014-03-28 15:02:57 +11:00
|
|
|
MINLINE float len_v2v2_int(const int v1[2], const int v2[2]);
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE int len_manhattan_v2v2_int(const int a[2], const int b[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_manhattan_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
|
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]);
|
2013-12-06 03:46:27 +11:00
|
|
|
MINLINE double normalize_v3_d(double n[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);
|
2013-04-12 00:50:40 +00:00
|
|
|
void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[2], const float t[3]);
|
2009-12-27 01:32:58 +00:00
|
|
|
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]);
|
2011-09-05 21:01:50 +00:00
|
|
|
void interp_v4_v4v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float v4[4], const float w[4]);
|
2013-04-17 05:49:06 +00:00
|
|
|
void interp_v3_v3v3v3_uv(float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2014-03-31 13:18:23 +11:00
|
|
|
bool interp_v3_v3v3_slerp(float target[3], const float a[3], const float b[3], const float t) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
bool interp_v2_v2v2_slerp(float target[2], const float a[2], const float b[2], const float t) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
|
|
|
|
void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float b[3], const float t);
|
|
|
|
void interp_v2_v2v2_slerp_safe(float target[2], const float a[2], const float b[2], const float t);
|
|
|
|
|
2014-02-10 17:02:53 +11:00
|
|
|
void interp_v3_v3v3_char(char target[3], const char a[3], const char b[3], const float t);
|
|
|
|
void interp_v3_v3v3_uchar(unsigned char target[3], const unsigned char a[3], const unsigned char b[3], const float t);
|
|
|
|
void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const float t);
|
|
|
|
void interp_v4_v4v4_uchar(unsigned char target[4], const unsigned char a[4], const unsigned char b[4], const float t);
|
|
|
|
|
2010-09-28 11:48:13 +00:00
|
|
|
void mid_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
2012-04-11 07:47:09 +00:00
|
|
|
void mid_v2_v2v2(float r[2], const float a[2], const float b[2]);
|
2012-11-15 13:24:14 +00:00
|
|
|
void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]);
|
2015-03-09 20:20:39 +11:00
|
|
|
void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2013-05-08 14:33:02 +00:00
|
|
|
void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3]);
|
|
|
|
void mid_v3_angle_weighted(float r[3]);
|
|
|
|
|
2013-01-18 23:07:27 +00:00
|
|
|
void flip_v4_v4v4(float v[4], const float v1[4], const float v2[4]);
|
|
|
|
void flip_v3_v3v3(float v[3], const float v1[3], const float v2[3]);
|
|
|
|
void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2]);
|
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
/********************************* Comparison ********************************/
|
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE bool is_zero_v2(const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool is_zero_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool is_zero_v4(const float a[4]) ATTR_WARN_UNUSED_RESULT;
|
2013-08-20 09:34:52 +00:00
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE bool is_finite_v2(const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool is_finite_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool is_finite_v4(const float a[4]) ATTR_WARN_UNUSED_RESULT;
|
2013-08-20 09:34:52 +00:00
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE bool is_one_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
|
2013-08-20 09:34:52 +00:00
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool equals_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool compare_v2v2(const float a[2], const float b[2], const float limit) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool compare_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool compare_len_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE bool compare_len_squared_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
|
2013-08-20 09:34:52 +00:00
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE bool compare_v4v4(const float a[4], const float b[4], const float limit) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
MINLINE bool equals_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) ATTR_WARN_UNUSED_RESULT;
|
2010-10-15 05:18:45 +00:00
|
|
|
|
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 */
|
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
float angle_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
float angle_signed_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
float angle_v2v2v2(const float a[2], const float b[2], const float c[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
float angle_normalized_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
float angle_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
float angle_v3v3v3(const float a[3], const float b[3], const float c[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT;
|
|
|
|
float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]) ATTR_WARN_UNUSED_RESULT;
|
2014-07-09 11:15:08 +10:00
|
|
|
float angle_signed_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]) ATTR_WARN_UNUSED_RESULT;
|
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]);
|
2012-05-12 20:39:39 +00:00
|
|
|
void angle_poly_v3(float *angles, const float *verts[3], int len);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
/********************************* Geometry **********************************/
|
|
|
|
|
2010-12-11 21:27:39 +00:00
|
|
|
void project_v2_v2v2(float c[2], const float v1[2], const float v2[2]);
|
2010-09-28 11:48:13 +00:00
|
|
|
void project_v3_v3v3(float r[3], const float p[3], const float n[3]);
|
2015-04-08 22:49:07 +10:00
|
|
|
void project_plane_v3_v3v3(float c[3], const float v[3], const float v_plane[3]);
|
|
|
|
void project_plane_v2_v2v2(float c[2], const float v[2], const float v_plane[2]);
|
2012-03-25 19:02:28 +00:00
|
|
|
void project_v3_plane(float v[3], const float n[3], const float p[3]);
|
2010-09-28 11:48:13 +00:00
|
|
|
void reflect_v3_v3v3(float r[3], const float v[3], const float n[3]);
|
2014-04-16 17:24:27 +10:00
|
|
|
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3]);
|
2014-03-16 16:31:19 +01:00
|
|
|
void ortho_v3_v3(float p[3], const float v[3]);
|
2014-05-27 14:42:22 +10:00
|
|
|
void ortho_v2_v2(float p[2], const float v[2]);
|
2010-09-28 11:48:13 +00:00
|
|
|
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]);
|
2013-07-11 15:32:26 +00:00
|
|
|
void print_vn(const char *str, const float v[], const int n);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2014-03-30 13:03:30 +11:00
|
|
|
#define print_v2_id(v) print_v2(STRINGIFY(v), v)
|
|
|
|
#define print_v3_id(v) print_v3(STRINGIFY(v), v)
|
|
|
|
#define print_v4_id(v) print_v4(STRINGIFY(v), v)
|
|
|
|
#define print_vn_id(v, n) print_vn(STRINGIFY(v), v, n)
|
|
|
|
|
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]);
|
2012-10-25 22:47:54 +00:00
|
|
|
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2015-02-05 14:00:58 +01:00
|
|
|
void minmax_v3v3_v3_array(float r_min[3], float r_max[3], float (*vec_arr)[3], int nbr);
|
|
|
|
|
2012-08-27 09:44:56 +00:00
|
|
|
void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist);
|
|
|
|
void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist);
|
|
|
|
|
2013-04-04 08:47:07 +00:00
|
|
|
void axis_sort_v3(const float axis_values[3], int r_axis_order[3]);
|
|
|
|
|
2010-10-20 09:18:55 +00:00
|
|
|
/***************************** Array Functions *******************************/
|
2015-05-05 17:08:29 +10:00
|
|
|
/* follow fixed length vector function conventions. */
|
2013-09-01 15:01:15 +00:00
|
|
|
double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size) ATTR_WARN_UNUSED_RESULT;
|
2014-03-31 11:17:46 +11:00
|
|
|
double len_squared_vn(const float *array, const int size) ATTR_WARN_UNUSED_RESULT;
|
2011-11-24 04:12:16 +00:00
|
|
|
float normalize_vn_vn(float *array_tar, const float *array_src, const int size);
|
|
|
|
float normalize_vn(float *array_tar, const int size);
|
|
|
|
void range_vn_i(int *array_tar, const int size, const int start);
|
2015-04-28 06:54:17 +10:00
|
|
|
void range_vn_u(unsigned int *array_tar, const int size, const unsigned int start);
|
2011-12-18 07:27:11 +00:00
|
|
|
void range_vn_fl(float *array_tar, const int size, const float start, const float step);
|
2011-02-05 06:14:50 +00:00
|
|
|
void negate_vn(float *array_tar, const int size);
|
|
|
|
void negate_vn_vn(float *array_tar, const float *array_src, const int size);
|
2011-11-24 04:12:16 +00:00
|
|
|
void mul_vn_fl(float *array_tar, const int size, const float f);
|
2010-10-22 10:17:55 +00:00
|
|
|
void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f);
|
2010-10-20 09:18:55 +00:00
|
|
|
void add_vn_vn(float *array_tar, const float *array_src, const int size);
|
2011-01-09 09:16:04 +00:00
|
|
|
void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size);
|
2012-05-31 11:57:09 +00:00
|
|
|
void madd_vn_vn(float *array_tar, const float *array_src, const float f, const int size);
|
|
|
|
void madd_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const float f, const int size);
|
2011-01-23 08:37:34 +00:00
|
|
|
void sub_vn_vn(float *array_tar, const float *array_src, const int size);
|
2011-01-09 09:16:04 +00:00
|
|
|
void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size);
|
2012-05-31 11:57:09 +00:00
|
|
|
void msub_vn_vn(float *array_tar, const float *array_src, const float f, const int size);
|
|
|
|
void msub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const float f, const int size);
|
2013-01-21 16:43:04 +00:00
|
|
|
void interp_vn_vn(float *array_tar, const float *array_src, const float t, const int size);
|
2015-05-05 17:08:29 +10:00
|
|
|
void copy_vn_i(int *array_tar, const int size, const int val);
|
|
|
|
void copy_vn_short(short *array_tar, const int size, const short val);
|
|
|
|
void copy_vn_ushort(unsigned short *array_tar, const int size, const unsigned short val);
|
|
|
|
void copy_vn_uchar(unsigned char *array_tar, const int size, const unsigned char val);
|
|
|
|
void copy_vn_fl(float *array_tar, const int size, const float val);
|
2010-10-20 09:18:55 +00:00
|
|
|
|
2013-08-05 12:49:13 +00:00
|
|
|
/**************************** Inline Definitions ******************************/
|
|
|
|
|
|
|
|
#if BLI_MATH_DO_INLINE
|
|
|
|
#include "intern/math_vector_inline.c"
|
|
|
|
#endif
|
|
|
|
|
2013-03-13 15:41:14 +00:00
|
|
|
#ifdef BLI_MATH_GCC_WARN_PRAGMA
|
2013-03-11 20:27:38 +00:00
|
|
|
# pragma GCC diagnostic pop
|
|
|
|
#endif
|
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#endif /* __BLI_MATH_VECTOR_H__ */
|