Paste Code
Paste Blends
Paste Images
/**
* $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,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* 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

#define MINLINE

//#define MINLINE static inline
//#include "intern/math_vector_inline.h"

/*************************** Init **************************/

MINLINE void zero_v2(float r[2]);
MINLINE void zero_v3(float r[3]);

MINLINE void copy_v2_v2(float r[2], float a[2]);
MINLINE void copy_v3_v3(float r[3], float a[3]);

/*********************** Arithmetic ***********************/

MINLINE void add_v2_v2(float r[2], float a[2]);
MINLINE void add_v2_v2v2(float r[2], float a[2], float b[2]);
MINLINE void add_v3_v3(float r[3], float a[3]);
MINLINE void add_v3_v3v3(float r[3], float a[3], float b[3]);

MINLINE void sub_v2_v2(float r[2], float a[2]);
MINLINE void sub_v2_v2v2(float r[2], float a[2], float b[2]);
MINLINE void sub_v3_v3(float r[3], float a[3]);
MINLINE void sub_v3_v3v3(float r[3], float a[3], float b[3]);

MINLINE void mul_v2_fl(float r[2], float f);
MINLINE void mul_v3_v3(float r[3], float a[3]);
MINLINE void mul_v3_v3v3(float r[3], float a[3], float b[3]);
MINLINE void mul_v3_fl(float r[3], float f);
MINLINE void mul_v3_v3fl(float r[3], float a[3], float f);

MINLINE void negate_v3(float r[3]);
MINLINE void negate_v3_v3(float r[3], float a[3]);

MINLINE float dot_v2v2(float a[2], float b[2]);
MINLINE float dot_v3v3(float a[3], float b[3]);

MINLINE float cross_v2v2(float a[2], float b[2]);
MINLINE void cross_v3_v3v3(float r[3], float a[3], float b[3]);

void star_m3_v3(float R[3][3],float a[3]);

/************************* Length *************************/

MINLINE float len_v2(float a[2]);
MINLINE float len_v2v2(float a[2], float b[2]);
MINLINE float len_v3(float a[3]);
MINLINE float len_v3v3(float a[3], float b[3]);

MINLINE float normalize_v2(float r[2]);
MINLINE float normalize_v3(float r[3]);

/********************* Interpolation **********************/

void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t); // TODO const
void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[3], const float t[3]); // TODO const
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t); // TODO const
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]); // TODO const

void mid_v3_v3v3(float r[3], float a[3], float b[3]);

/*********************** Comparison ***********************/

int is_zero_v3(float a[3]);
int equals_v3v3(float a[3], float b[3]);
int compare_v3v3(float a[3], float b[3], float limit);
int compare_len_v3v3(float a[3], float b[3], float limit);

int compare_v4v4(float a[4], float b[4], float limit);

/************************ Angles **************************/

float angle_v2v2(float a[2], float b[2]);
float angle_v2v2v2(float a[2], float b[2], float c[2]);
float angle_normalized_v2v2(float a[2], float b[2]);
float angle_v3v3(float a[2], float b[2]);
float angle_v3v3v3(float a[2], float b[2], float c[2]);
float angle_normalized_v3v3(float a[3], float b[3]);

/*********************** Geometry *************************/

void project_v3_v3v3(float r[3], float p[3], float n[3]);
void reflect_v3_v3v3(float r[3], float v[3], float n[3]);
void ortho_basis_v3_v3v3(float r[3], float a[3], float b[3]);
void bisect_v3_v3v3(float r[3], float a[3], float b[3], float c[3]);

/************************* Other **************************/

void print_v2(char *str, float a[2]);
void print_v3(char *str, float a[3]);
void print_v4(char *str, float a[4]);

void normal_short_to_float_v3(float r[3], short n[3]);
void normal_float_to_short_v3(short r[3], float n[3]);

void minmax_v3_v3v3(float r[3], float min[3], float max[3]);

#ifdef __cplusplus
}
#endif

#endif /* BLI_MATH_VECTOR */
  1. /**
  2.  * $Id$
  3.  *
  4.  * ***** BEGIN GPL LICENSE BLOCK *****
  5.  *
  6.  * This program is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU General Public License
  8.  * as published by the Free Software Foundation; either version 2
  9.  * of the License, or (at your option) any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software Foundation,
  18.  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  *
  20.  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  21.  * All rights reserved.
  22.  *
  23.  * The Original Code is: some of this file.
  24.  *
  25.  * ***** END GPL LICENSE BLOCK *****
  26.  * */
  27.  
  28. #ifndef BLI_MATH_VECTOR
  29. #define BLI_MATH_VECTOR
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #define MINLINE
  36.  
  37. //#define MINLINE static inline
  38. //#include "intern/math_vector_inline.h"
  39.  
  40. /*************************** Init **************************/
  41.  
  42. MINLINE void zero_v2(float r[2]);
  43. MINLINE void zero_v3(float r[3]);
  44.  
  45. MINLINE void copy_v2_v2(float r[2], float a[2]);
  46. MINLINE void copy_v3_v3(float r[3], float a[3]);
  47.  
  48. /*********************** Arithmetic ***********************/
  49.  
  50. MINLINE void add_v2_v2(float r[2], float a[2]);
  51. MINLINE void add_v2_v2v2(float r[2], float a[2], float b[2]);
  52. MINLINE void add_v3_v3(float r[3], float a[3]);
  53. MINLINE void add_v3_v3v3(float r[3], float a[3], float b[3]);
  54.  
  55. MINLINE void sub_v2_v2(float r[2], float a[2]);
  56. MINLINE void sub_v2_v2v2(float r[2], float a[2], float b[2]);
  57. MINLINE void sub_v3_v3(float r[3], float a[3]);
  58. MINLINE void sub_v3_v3v3(float r[3], float a[3], float b[3]);
  59.  
  60. MINLINE void mul_v2_fl(float r[2], float f);
  61. MINLINE void mul_v3_v3(float r[3], float a[3]);
  62. MINLINE void mul_v3_v3v3(float r[3], float a[3], float b[3]);
  63. MINLINE void mul_v3_fl(float r[3], float f);
  64. MINLINE void mul_v3_v3fl(float r[3], float a[3], float f);
  65.  
  66. MINLINE void negate_v3(float r[3]);
  67. MINLINE void negate_v3_v3(float r[3], float a[3]);
  68.  
  69. MINLINE float dot_v2v2(float a[2], float b[2]);
  70. MINLINE float dot_v3v3(float a[3], float b[3]);
  71.  
  72. MINLINE float cross_v2v2(float a[2], float b[2]);
  73. MINLINE void cross_v3_v3v3(float r[3], float a[3], float b[3]);
  74.  
  75. void star_m3_v3(float R[3][3],float a[3]);
  76.  
  77. /************************* Length *************************/
  78.  
  79. MINLINE float len_v2(float a[2]);
  80. MINLINE float len_v2v2(float a[2], float b[2]);
  81. MINLINE float len_v3(float a[3]);
  82. MINLINE float len_v3v3(float a[3], float b[3]);
  83.  
  84. MINLINE float normalize_v2(float r[2]);
  85. MINLINE float normalize_v3(float r[3]);
  86.  
  87. /********************* Interpolation **********************/
  88.  
  89. void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t); // TODO const
  90. void interp_v2_v2v2v2(float r[2], const float a[2], const float b[2], const float c[3], const float t[3]); // TODO const
  91. void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t); // TODO const
  92. void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]); // TODO const
  93.  
  94. void mid_v3_v3v3(float r[3], float a[3], float b[3]);
  95.  
  96. /*********************** Comparison ***********************/
  97.  
  98. int is_zero_v3(float a[3]);
  99. int equals_v3v3(float a[3], float b[3]);
  100. int compare_v3v3(float a[3], float b[3], float limit);
  101. int compare_len_v3v3(float a[3], float b[3], float limit);
  102.  
  103. int compare_v4v4(float a[4], float b[4], float limit);
  104.  
  105. /************************ Angles **************************/
  106.  
  107. float angle_v2v2(float a[2], float b[2]);
  108. float angle_v2v2v2(float a[2], float b[2], float c[2]);
  109. float angle_normalized_v2v2(float a[2], float b[2]);
  110. float angle_v3v3(float a[2], float b[2]);
  111. float angle_v3v3v3(float a[2], float b[2], float c[2]);
  112. float angle_normalized_v3v3(float a[3], float b[3]);
  113.  
  114. /*********************** Geometry *************************/
  115.  
  116. void project_v3_v3v3(float r[3], float p[3], float n[3]);
  117. void reflect_v3_v3v3(float r[3], float v[3], float n[3]);
  118. void ortho_basis_v3_v3v3(float r[3], float a[3], float b[3]);
  119. void bisect_v3_v3v3(float r[3], float a[3], float b[3], float c[3]);
  120.  
  121. /************************* Other **************************/
  122.  
  123. void print_v2(char *str, float a[2]);
  124. void print_v3(char *str, float a[3]);
  125. void print_v4(char *str, float a[4]);
  126.  
  127. void normal_short_to_float_v3(float r[3], short n[3]);
  128. void normal_float_to_short_v3(short r[3], float n[3]);
  129.  
  130. void minmax_v3_v3v3(float r[3], float min[3], float max[3]);
  131.  
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135.  
  136. #endif /* BLI_MATH_VECTOR */
  137.  
go to heaven