VectorDot not working
by Matthew Cooke · in Torque Game Engine · 02/13/2004 (7:20 am) · 6 replies
Hi everybody.
I'm playing around with vectors and I'm having problems computing the dot product of two vectors.
should result in
but typing the above into the console results in
Which is the magnitude of the dot product.
Has anyone else noticed this?
What I'm trying to do is to take a vector and remove it's z value. i.e
But as the VectorDot function seems to be broken it's not working. Can anyone think of a fix or work around for this?
Many thanks
Matt
I'm playing around with vectors and I'm having problems computing the dot product of two vectors.
echo(VectorDot("2 4 8", "0.5 0.5 0.25"));should result in
1 2 2
but typing the above into the console results in
5
Which is the magnitude of the dot product.
Has anyone else noticed this?
What I'm trying to do is to take a vector and remove it's z value. i.e
%foo=VectorDot(%vector, "1 1 0");
But as the VectorDot function seems to be broken it's not working. Can anyone think of a fix or work around for this?
Many thanks
Matt
#2
James is correct; a "Dot Product" returns you a scalar which is the cosine of the angle between the two input vectors multiplied by the product of their length whereas a "Cross Product" returns a vector of the same order as the two input vectors which is perpendicular to the two input vectors.
The "Dot Product" is also called the inner or scalar product whereas the "Cross Product" is also called the outer or vector product.
Hey, maybe you knew this already but someone else reading it may not and besides, I've got my teachers cap on today. :)
- Melv.
02/13/2004 (8:31 am)
Matthew,James is correct; a "Dot Product" returns you a scalar which is the cosine of the angle between the two input vectors multiplied by the product of their length whereas a "Cross Product" returns a vector of the same order as the two input vectors which is perpendicular to the two input vectors.
The "Dot Product" is also called the inner or scalar product whereas the "Cross Product" is also called the outer or vector product.
Hey, maybe you knew this already but someone else reading it may not and besides, I've got my teachers cap on today. :)
- Melv.
#3
Also, for idiots like me:
02/13/2004 (9:48 am)
I learned something. :PAlso, for idiots like me:
dot(x,y) = x[0]*y[0] + x[1]*y[1] + x[2]*y[2] + ... + x[n]*y[n];
#4
Whoops.
Thank you for clearing that up.
Well, to be honest I didn't know what the dot product was. I was going from the alpha docs which as it's alpha is probably a bad idea.
www.garagegames.com/docs/alpha/ch05s07.html#chapter.scripting.vectors.vectordot
It's just this function seemed to do what I wanted it to rather elegantly, so I used it without actually understanding it.
So how can I do what I want to do, ie set a vectors z portion to zero?
Any help appriciated.
Matt
02/13/2004 (9:49 am)
Ah. (Blank look.)Whoops.
Thank you for clearing that up.
Well, to be honest I didn't know what the dot product was. I was going from the alpha docs which as it's alpha is probably a bad idea.
www.garagegames.com/docs/alpha/ch05s07.html#chapter.scripting.vectors.vectordot
Quote:
The VectorDot function "multiplies" the x, y, and z components of two vectors together. This can be useful for calculating resultant velocities after collisions.
%foo = VectorDot("2 4 8", "0.5 0.5 0.25");
The program above will return %foo as "1 2 2".
It's just this function seemed to do what I wanted it to rather elegantly, so I used it without actually understanding it.
So how can I do what I want to do, ie set a vectors z portion to zero?
Any help appriciated.
Matt
#6
http://www.garagegames.com/mg/forums/result.thread.php?qt=15258
02/13/2004 (1:59 pm)
Thanks for the help everyone. If finally sorted my BIG problem with this tiny snippit I adapted fromhttp://www.garagegames.com/mg/forums/result.thread.php?qt=15258
%foo = getWord(%vector, 0) SPC getWord(%vector, 1) SPC "0";
Associate James Urquhart
I do not ever recall the dot product of 2 vectors returning a vector.
Then again, there could be an alternate version i have not seen myself before :)
In your example case, the result is 5.
Perhaps you are thinking of the cross product?