Sign in to follow this  
gameplayprogammer

Vector Projection...Why does this work???

Recommended Posts

Been trying to work out where i am going wrong, projecting one vector onto another does not work unless i half the dot product, why? this is the formula i am using....projectionVector = (V dot N) * N, where N = the projection normal, V = the vector being projected. ...currently i have this line.... m_vPointOfContact = m_vPos + (m_vShotDir * (fDotProd*.5f)); ...and that works...but shouldn't it be just this... m_vPointOfContact = m_vPos + (m_vShotDir * fDotProd);

// m_vShotDir is a normalized vector in the direction you are going to shoot.

//  dir to obj
Vector3 vDirToObj = vObjPos - m_vPos;

//  now project the vector to the obj 
float fDotProd = m_vShotDir.Dot(vDirToObj);
m_vPointOfContact = m_vPos + (m_vShotDir * (fDotProd*.5f));


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this