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:
authorAntony Riakiotakis <kalast@gmail.com>2013-04-15 18:55:42 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-04-15 18:55:42 +0400
commitf6604f7612af998ee275fa0650c5c56f6d208074 (patch)
tree3177fe9b1b362abd076babfc64a62b7c7f26c5f5 /source/blender/blenlib/intern/math_rotation.c
parentfaaa7395800dfdf65510b07b9cf6e424dcb4ed45 (diff)
New implementation for twist brushes.
It has much better rotation and avoids the compression effect that old twist brushes have. Also twisting is now non periodic, meaning you can twist beyond 180 degrees. The amount of twist is also calculated relative to the angle formed after first translating the mouse away from the brush center.
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index cf9280d418f..2d044a13841 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -749,10 +749,33 @@ void eulO_to_axis_angle(float axis[3], float *angle, const float eul[3], const s
quat_to_axis_angle(axis, angle, q);
}
-/* axis angle to 3x3 matrix - safer version (normalization of axis performed)
- *
- * note: we may want a normalized and non normalized version of this function.
- */
+/* axis angle to 3x3 matrix - note: requires that axis is normalized */
+void axis_angle_to_mat3_no_norm(float mat[3][3], const float nor[3], const float angle)
+{
+ float nsi[3], co, si, ico;
+
+ /* now convert this to a 3x3 matrix */
+ co = cosf(angle);
+ si = sinf(angle);
+
+ ico = (1.0f - co);
+ nsi[0] = nor[0] * si;
+ nsi[1] = nor[1] * si;
+ nsi[2] = nor[2] * si;
+
+ mat[0][0] = ((nor[0] * nor[0]) * ico) + co;
+ mat[0][1] = ((nor[0] * nor[1]) * ico) + nsi[2];
+ mat[0][2] = ((nor[0] * nor[2]) * ico) - nsi[1];
+ mat[1][0] = ((nor[0] * nor[1]) * ico) - nsi[2];
+ mat[1][1] = ((nor[1] * nor[1]) * ico) + co;
+ mat[1][2] = ((nor[1] * nor[2]) * ico) + nsi[0];
+ mat[2][0] = ((nor[0] * nor[2]) * ico) + nsi[1];
+ mat[2][1] = ((nor[1] * nor[2]) * ico) - nsi[0];
+ mat[2][2] = ((nor[2] * nor[2]) * ico) + co;
+}
+
+
+/* axis angle to 3x3 matrix - safer version (normalization of axis performed) */
void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle)
{
float nor[3], nsi[3], co, si, ico;