diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-09-07 12:37:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-09-07 12:37:28 +0400 |
commit | 4cc908b6769cbb05e10c9c4d55c615a7faa3e83b (patch) | |
tree | 6b94738cf8161722f7aa31595333e2b6d8025b1c /source/blender/blenlib/intern | |
parent | d779410600de3061539c8c433c7a8c72cff022c0 (diff) | |
parent | c9dd69c11a639aece463dac9018e88dede4b9515 (diff) |
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r23023:HEAD
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index 55bdc32c4e9..96056ba7783 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -3374,17 +3374,39 @@ 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) +/* Returns a vector bisecting the angle at v2 formed by v1, v2 and v3 */ +void VecBisect3(float *out, 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); + VecAddf(out, d_12, d_23); + Normalize(out); +} + +/* Returns a reflection vector from a vector and a normal vector +reflect = vec - ((2 * DotVecs(vec, mirror)) * mirror) +*/ +void VecReflect(float *out, float *v1, float *v2) +{ + float vec[3], normal[3]; + float reflect[3] = {0.0f, 0.0f, 0.0f}; + float dot2; + + VecCopyf(vec, v1); + VecCopyf(normal, v2); + + Normalize(normal); + + dot2 = 2 * Inpf(vec, normal); + + reflect[0] = vec[0] - (dot2 * normal[0]); + reflect[1] = vec[1] - (dot2 * normal[1]); + reflect[2] = vec[2] - (dot2 * normal[2]); + + VecCopyf(out, reflect); } /* Return the angle in degrees between vecs 1-2 and 2-3 in degrees |