I have a Vector function which takes two Vectors and and attempts to "project" these vectors together. The method used is to separate the larger of the two vectors (the larger value calculated via magnitude) and then take the larger vector's magnitude and obtain the cosine of it, while multiplying the lesser of the vectors by the magnitude of the larger times its cosine divided by the lesser's magnitude. I hope this makes sense. For those which are having trouble understanding this, I'll paste some code...
float projectVector(const Vector3f& v, const Vector3f& n) {
float nmagnitude = n.computeMagnitude(),
vmagnitude = v.computeMagnitude(),
II, T;
if (nmagnitude > vmagnitude) {
II = (nmagnitude * cosf(nmagnitude)) / vmagnitude;
T = nmagnitude - II;
} else {
II = (vmagnitude * cosf(vmagnitude)) / nmagnitude;
T = vmagnitude - II;
}
float total = T + II;
}
I'm studying this from the 3D Math Primer for Graphics and Game Development book. The main reason why I'm asking here and not SO is because this is dealing with mathematical theory, and I need to know if my theory is correct, or if I'm on the right track by what I'm doing.
So, am I doing this correctly?
ais used with cos are used to createc. The question is, what exactly is the value ofacalculated from? I know it's a vector, but is it calculating its magnitude as its value, or adding itsx, ycoordinates together? – about blank Jan 9 '12 at 16:45