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>2015-10-22 19:08:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-10-22 19:09:28 +0300
commit80470b639c1c5091541c56ae80212fa8e5148913 (patch)
treef86e47e0213f7e93a5aa9adfec33380700ff51c4 /source/blender/blenlib/intern/math_rotation.c
parent0d54aa9c024261851bef24a3ebfd2bd875fec380 (diff)
BLI_math: axis_angle_to_quat_single
Useful to avoid defining a vector for an axis-aligned rotation. Matches axis_angle_to_mat3_single behavior.
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 575710e8d75..949473a8d86 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1016,6 +1016,20 @@ void angle_to_mat2(float mat[2][2], const float angle)
mat[1][1] = angle_cos;
}
+void axis_angle_to_quat_single(float q[4], const char axis, const float angle)
+{
+ const float angle_half = angle * 0.5f;
+ const float angle_cos = cosf(angle_half);
+ const float angle_sin = sinf(angle_half);
+ const int axis_index = (axis - 'X');
+
+ assert(axis >= 'X' && axis <= 'Z');
+
+ q[0] = angle_cos;
+ zero_v3(q + 1);
+ q[axis_index + 1] = angle_sin;
+}
+
/****************************** Exponential Map ******************************/
void quat_normalized_to_expmap(float expmap[3], const float q[4])