diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-09-05 13:54:01 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-09-05 13:54:01 +0400 |
commit | 3b743ac5565663d2fd0be4bbbc92e404afafbce4 (patch) | |
tree | b9091982dc98ee28d609dc249381fa1e6ce79f08 /source/blender/blenlib | |
parent | 959757c2d7bdfe7955e2c645a511ac450a607c47 (diff) |
Option to correct for 3D curve twist error. example before and after.
http://www.graphicall.org/ftp/ideasman42/curve_auto_twist.png
Access next to the "3D" edit button.
details...
- open curves use the first points orientation and minimize twist for each new segment.
- cyclic curves calculate the least twist in both directions and blend between them
- AxisAngleToQuat replaced inline code.
- Notice the model on the right now has more even corners. added Vec3ToTangent to arithb.c.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_arithb.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h index 092ed00fbe5..63b351016d4 100644 --- a/source/blender/blenlib/BLI_arithb.h +++ b/source/blender/blenlib/BLI_arithb.h @@ -270,6 +270,7 @@ void AxisAngleToQuat(float *q, float *axis, float angle); void RotationBetweenVectorsToQuat(float *q, float v1[3], float v2[3]); void vectoquat(float *vec, short axis, short upflag, float *q); +void Vec3ToTangent(float *v, float *v1, float *v2, float *v3); float VecAngle2(float *v1, float *v2); float VecAngle3(float *v1, float *v2, float *v3); float NormalizedVecAngle2(float *v1, float *v2); diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index ad1dc1ca12c..970d8f7d0de 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -2969,6 +2969,19 @@ void VecRotToQuat( float *vec, float phi, float *quat) } } +/* get a direction from 3 vectors that wont depend + * on the distance between the points */ +void Vec3ToTangent(float *v, float *v1, float *v2, float *v3) +{ + float d_12[3], d_23[3]; + VecSubf(d_12, v2, v1); + VecSubf(d_23, v3, v2); + Normalize(d_12); + Normalize(d_23); + VecAddf(v, d_12, d_23); + Normalize(v); +} + /* Return the angle in degrees between vecs 1-2 and 2-3 in degrees If v1 is a shoulder, v2 is the elbow and v3 is the hand, this would return the angle at the elbow */ |