diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-05-21 13:59:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-05-21 14:06:29 +0300 |
commit | 6ee653352bbbc8e358969426186b540f98a9aca0 (patch) | |
tree | 0f751467cc2f36ffe3b248b76e027ccf22eda588 /source/blender/blenlib | |
parent | 6b40a4bcb1bcd82bf21e0a3473f8aacc11727b24 (diff) |
Math Lib: double versions of vector funcs
- add_vn_vn_d
- add_vn_vnvn_d
- mul_vn_db
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 35 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 5 |
3 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 04c2baa5359..9bc1121801e 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -158,6 +158,8 @@ MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESU MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT; MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT; +MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT; + MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT; MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]); @@ -335,6 +337,10 @@ void copy_vn_ushort(unsigned short *array_tar, const int size, const unsigned sh 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); +void add_vn_vn_d(double *array_tar, const double *array_src, const int size); +void add_vn_vnvn_d(double *array_tar, const double *array_src_a, const double *array_src_b, const int size); +void mul_vn_db(double *array_tar, const int size, const double f); + /**************************** Inline Definitions ******************************/ #if BLI_MATH_DO_INLINE diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 88eccd60352..6da0e87355d 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -1095,3 +1095,38 @@ void copy_vn_fl(float *array_tar, const int size, const float val) *(tar--) = val; } } + +/** \name Double precision versions 'db'. + * \{ */ + +void add_vn_vn_d(double *array_tar, const double *array_src, const int size) +{ + double *tar = array_tar + (size - 1); + const double *src = array_src + (size - 1); + int i = size; + while (i--) { + *(tar--) += *(src--); + } +} + +void add_vn_vnvn_d(double *array_tar, const double *array_src_a, const double *array_src_b, const int size) +{ + double *tar = array_tar + (size - 1); + const double *src_a = array_src_a + (size - 1); + const double *src_b = array_src_b + (size - 1); + int i = size; + while (i--) { + *(tar--) = *(src_a--) + *(src_b--); + } +} + +void mul_vn_db(double *array_tar, const int size, const double f) +{ + double *array_pt = array_tar + (size - 1); + int i = size; + while (i--) { + *(array_pt--) *= f; + } +} + +/** \} */ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 621d5fbfbfe..fb33fed33e4 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -680,6 +680,11 @@ MINLINE float dot_v4v4(const float a[4], const float b[4]) return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; } +MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) +{ + return a[0] * (double)b[0] + a[1] * (double)b[1] + a[2] * (double)b[2]; +} + MINLINE float cross_v2v2(const float a[2], const float b[2]) { return a[0] * b[1] - a[1] * b[0]; |