Math Lib: double versions of vector funcs

- add_vn_vn_d
- add_vn_vnvn_d
- mul_vn_db
This commit is contained in:
Campbell Barton 2015-05-21 20:59:08 +10:00
parent 6b40a4bcb1
commit 6ee653352b
3 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -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;
}
}
/** \} */

View File

@ -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];