//void MatrixMultiply(Matrix mIn) //{ // Matrix mat_temp = new Matrix(); // //first row // mat_temp._11 = (m_Matrix._11 * mIn._11) + (m_Matrix._12 * mIn._21) + (m_Matrix._13 * mIn._31); // mat_temp._12 = (m_Matrix._11 * mIn._12) + (m_Matrix._12 * mIn._22) + (m_Matrix._13 * mIn._32); // mat_temp._13 = (m_Matrix._11 * mIn._13) + (m_Matrix._12 * mIn._23) + (m_Matrix._13 * mIn._33); // //second // mat_temp._21 = (m_Matrix._21 * mIn._11) + (m_Matrix._22 * mIn._21) + (m_Matrix._23 * mIn._31); // mat_temp._22 = (m_Matrix._21 * mIn._12) + (m_Matrix._22 * mIn._22) + (m_Matrix._23 * mIn._32); // mat_temp._23 = (m_Matrix._21 * mIn._13) + (m_Matrix._22 * mIn._23) + (m_Matrix._23 * mIn._33); // //third // mat_temp._31 = (m_Matrix._31 * mIn._11) + (m_Matrix._32 * mIn._21) + (m_Matrix._33 * mIn._31); // mat_temp._32 = (m_Matrix._31 * mIn._12) + (m_Matrix._32 * mIn._22) + (m_Matrix._33 * mIn._32); // mat_temp._33 = (m_Matrix._31 * mIn._13) + (m_Matrix._32 * mIn._23) + (m_Matrix._33 * mIn._33); // m_Matrix = mat_temp; //} public F64Vec2 VectorToWorldSpace(F64Vec2 vec, F64Vec2 AgentHeading, F64Vec2 AgentSide) { //make a copy of the point F64Vec2 TransVec = vec; //F64Vec2 TransVec = new F64Vec2(vec.X, vec.Y); //create a transformation matrix F64Matrix3x3 matTransform = new F64Matrix3x3(); //rotate matTransform.Rotate(AgentHeading, AgentSide); //now transform the vertices matTransform.TransformVector2Ds(ref TransVec); return(TransVec); }
//--------------------- PointToWorldSpace -------------------------------- // // Transforms a point from the agent's local space into world space //------------------------------------------------------------------------ public F64Vec2 PointToWorldSpace(F64Vec2 point, F64Vec2 AgentHeading, F64Vec2 AgentSide, F64Vec2 AgentPosition) { //make a copy of the point F64Vec2 TransPoint = point; //create a transformation matrix F64Matrix3x3 matTransform = new F64Matrix3x3(); //rotate matTransform.Rotate(AgentHeading, AgentSide); //and translate matTransform.Translate(AgentPosition.X, AgentPosition.Y); //now transform the vertices matTransform.TransformVector2Ds(ref TransPoint); return(TransPoint); }
//--------------------- PointToLocalSpace -------------------------------- // //------------------------------------------------------------------------ public F64Vec2 PointToLocalSpace(F64Vec2 point, F64Vec2 AgentHeading, F64Vec2 AgentSide, F64Vec2 AgentPosition) { //make a copy of the point F64Vec2 TransPoint = point; //create a transformation matrix F64Matrix3x3 matTransform = new F64Matrix3x3(); F64 Tx = F64Vec2.Dot(-AgentPosition, AgentHeading); F64 Ty = F64Vec2.Dot(-AgentPosition, AgentSide); //create the transformation matrix matTransform._11(AgentHeading.X); matTransform._12(AgentSide.X); matTransform._21(AgentHeading.Y); matTransform._22(AgentSide.Y); matTransform._31(Tx); matTransform._32(Ty); //now transform the vertices matTransform.TransformVector2Ds(ref TransPoint); return(TransPoint); }