Game Development Community

Question About Vector Math

by Brian Wilson · in Torque Game Builder · 06/29/2011 (1:02 pm) · 3 replies

So I understand how to operate on most Vector scenarios as it pertains to TGB, including dot products and doing the math involving two vectors. But recently I was looking at some sample C++ code and saw something like this:

float a = 2.0f * (vA) * vB;

...where vA and vB are both vectors. Would this just be a vector scalar? Would the torquescript equiv be:

%a = VectorMult(VectorScale(%vA,2),%vB);

...?


#1
06/29/2011 (3:02 pm)
2 vectors can be "multiplied" in only 2 ways: the dot product or the cross product. Since the final answer is defined as a scalar value (float a), then the multiplication between the vectors represents the dot product of vA and vB.

In Torque script,
%a = 2 * VectorDot( vA , vB )
#2
07/03/2011 (1:45 pm)
Thanks Alain. The type slipped right past me.
#3
07/03/2011 (3:51 pm)
Glad to help.