[Bf-python] AngleBetweenVecs found solution
Gilbert, Joseph
jgilbert at tigr.ORG
Mon Oct 10 20:28:41 CEST 2005
For some v1 * v1 operations the dot product was
1.000000000000000000000000000000001 which returns NAN when passed to the
acos() function. Hopefully the clamp solves things. Also, thx martin for
the implementation - was added.
-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Martin
DeMello
Sent: Monday, October 10, 2005 12:12 AM
To: cbarton at metavr.com; Blender Foundation Python list
Subject: Re: [Bf-python] AngleBetweenVecs found solution
On 10/10/05, Campbell Barton <cbarton at metavr.com> wrote:
> //normalize vectors
> norm_a = (double)sqrt(test_v1);
> norm_b = (double)sqrt(test_v2);
> for(x = 0; x < size; x++) {
> vec_a[x] /= norm_a;
> vec_b[x] /= norm_b;
> }
> //dot product
> for(x = 0; x < size; x++) {
> dot += vec_a[x] * vec_b[x];
> }
I think it would be slightly more accurate to take the dot product of
the unnormalised vectors, then divide by (norm_a * norm_b)
martin
_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python
More information about the Bf-python
mailing list