Dot(v1, v2) = Gibberish?
-
On 22/11/2013 at 11:36, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 13
Platform: Windows ;
Language(s) : C++ ;---------
I'm getting very strange values out of the Dot() SDK function.
According to the internet. My hand calculated results are correct. And the result from Dot() is not.What's going on with this function?
Example #1
LVector a = (2, 3, 4); LVector b = (1,-2, 3); /* Calculating the dot product myself by hand 2*1 + 3*-2 + 4*3 2 + -6 \+ 12 8 <--The answer */ LReal dot = Dot(a,b); //<---returns 36! why? GePrint(RealToString(dot));
Example #2
LVector a2 = (4, 8, 10); LVector b2 = (9, 2, 7); /* Calculating the dot product myself by hand 4*9 + 8*2 + 10*7 36 \+ 16 + 70 122 <--The answer */ LReal dot2 = Dot(a2,b2); //<---returns 210! why? GePrint(RealToString(dot2));
-ScottA
-
On 22/11/2013 at 12:06, xxxxxxxx wrote:
I think this must look like this :
LVector a = (2, 3, 4); //set x,y,z to 4 LVector b = (1,-2, 3); //set x,y,z to 3 // Calculating the dot product myself by hand // 4*3+4*3+4*3 // 36 <--The answer LReal dot = Dot(a,b); //<---returns 36! why? GePrint(RealToString(dot));
So the answer is correct.
But you problem is this:
LVector a = (2, 3, 4); //the same as LVector a = LVector(4);
So here is the code that work as expected:
LVector a(2, 3, 4); //or LVector a = LVector(2,3,4); LVector b(1,-2, 3); // Calculating the dot product myself by hand // 2*1 + 3*-2 + 4*3 // 8 <--The answer LReal dot = Dot(a,b); //<---returns 8! GePrint(RealToString(dot));
-
On 22/11/2013 at 12:35, xxxxxxxx wrote:
Oh. I get it now.
Thanks Remo.-ScottA