private Vector2D PointToWorldSpace(Vector2D point, Vector2D AgentHeading, Vector2D AgentSide, Vector2D AgentPosition) { //make a copy of the point Vector2D TransPoint = new Vector2D(point.X, point.Y); ; //create a transformation matrix C2DMatrix matTransform = new C2DMatrix(); //rotate matTransform.Rotate(AgentHeading, AgentSide); //and translate matTransform.Translate(AgentPosition.X, AgentPosition.Y); //now transform the vertices matTransform.TransformVector2D(TransPoint); return TransPoint; }
private Vector2D VectorToWorldSpace(Vector2D vec, Vector2D AgentHeading, Vector2D AgentSide) { //make a copy of the point Vector2D TransVec = new Vector2D(vec.X, vec.Y); ; //create a transformation matrix C2DMatrix matTransform = new C2DMatrix(); //rotate matTransform.Rotate(AgentHeading, AgentSide); //now transform the vertices matTransform.TransformVector2D(TransVec); return TransVec; }
private Vector2D PointToLocalSpace(Vector2D point, Vector2D AgentHeading, Vector2D AgentSide, Vector2D AgentPosition) { //make a copy of the point Vector2D TransPoint = new Vector2D(point.X, point.Y); //create a transformation matrix C2DMatrix matTransform = new C2DMatrix(); double Tx = -AgentPosition.Dot(AgentHeading); double Ty = -AgentPosition.Dot(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.TransformVector2D(TransPoint); return TransPoint; }