Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-08-15 19:14:08 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-15 19:14:08 +0400
commit728b713d86e69a57aa84a9aa5ce830befec67238 (patch)
treeada2f36368a3f4fda79ccc57faef512a92726873 /source/blender/blenlib/intern
parent5f525bd723bb1187baab195b11677dfb14bb7322 (diff)
use more BLI math functions.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/math_geom.c12
-rw-r--r--source/blender/blenlib/intern/math_matrix.c8
-rw-r--r--source/blender/blenlib/intern/math_rotation.c13
-rw-r--r--source/blender/blenlib/intern/math_vector.c6
4 files changed, 12 insertions, 27 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index fd0829ebe3b..68b1feea632 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -841,10 +841,8 @@ int isect_line_line_v3(float v1[3], float v2[3], float v3[3], float v4[3], float
sub_v3_v3v3(a, v2, v1);
sub_v3_v3v3(b, v4, v3);
- copy_v3_v3(dir1, a);
- normalize_v3(dir1);
- copy_v3_v3(dir2, b);
- normalize_v3(dir2);
+ normalize_v3_v3(dir1, a);
+ normalize_v3_v3(dir2, b);
d = dot_v3v3(dir1, dir2);
if (d == 1.0f || d == -1.0f) {
/* colinear */
@@ -908,10 +906,8 @@ int isect_line_line_strict_v3(float v1[3], float v2[3], float v3[3], float v4[3]
sub_v3_v3v3(a, v2, v1);
sub_v3_v3v3(b, v4, v3);
- copy_v3_v3(dir1, a);
- normalize_v3(dir1);
- copy_v3_v3(dir2, b);
- normalize_v3(dir2);
+ normalize_v3_v3(dir1, a);
+ normalize_v3_v3(dir2, b);
d = dot_v3v3(dir1, dir2);
if (d == 1.0f || d == -1.0f || d == 0) {
/* colinear or one vector is zero-length*/
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 6c06da2e32d..64c3e746982 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -595,9 +595,7 @@ void transpose_m4(float mat[][4])
void orthogonalize_m3(float mat[][3], int axis)
{
float size[3];
- size[0] = len_v3(mat[0]);
- size[1] = len_v3(mat[1]);
- size[2] = len_v3(mat[2]);
+ mat3_to_size(size, mat);
normalize_v3(mat[axis]);
switch(axis)
{
@@ -658,9 +656,7 @@ void orthogonalize_m3(float mat[][3], int axis)
void orthogonalize_m4(float mat[][4], int axis)
{
float size[3];
- size[0] = len_v3(mat[0]);
- size[1] = len_v3(mat[1]);
- size[2] = len_v3(mat[2]);
+ mat4_to_size(size, mat);
normalize_v3(mat[axis]);
switch(axis)
{
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 4d015e527a8..f72269f6d7b 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -135,10 +135,7 @@ void mul_fac_qt_fl(float *q, const float fac)
float si= (float)sin(angle);
q[0]= co;
normalize_v3(q+1);
- q[1]*= si;
- q[2]*= si;
- q[3]*= si;
-
+ mul_v3_fl(q+1, si);
}
void quat_to_mat3(float m[][3], float *q)
@@ -595,9 +592,8 @@ void axis_angle_to_quat(float q[4], float axis[3], float angle)
{
float nor[3];
float si;
-
- copy_v3_v3(nor, axis);
- normalize_v3(nor);
+
+ normalize_v3_v3(nor, axis);
angle /= 2;
si = (float)sin(angle);
@@ -654,8 +650,7 @@ void axis_angle_to_mat3(float mat[3][3],float axis[3], float angle)
float nor[3], nsi[3], co, si, ico;
/* normalise the axis first (to remove unwanted scaling) */
- copy_v3_v3(nor, axis);
- normalize_v3(nor);
+ normalize_v3_v3(nor, axis);
/* now convert this to a 3x3 matrix */
co= (float)cos(angle);
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 9baf897c830..b1cea9ab3c4 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -120,10 +120,8 @@ float angle_v3v3(float *v1, float *v2)
{
float vec1[3], vec2[3];
- copy_v3_v3(vec1, v1);
- copy_v3_v3(vec2, v2);
- normalize_v3(vec1);
- normalize_v3(vec2);
+ normalize_v3_v3(vec1, v1);
+ normalize_v3_v3(vec2, v2);
return angle_normalized_v3v3(vec1, vec2);
}