//--------------------------- WorldTransform ----------------------------- // // given a std::vector of 2D vectors, a position, orientation and scale, // this function transforms the 2D vectors into the object's world space //------------------------------------------------------------------------ public static List <Vector2D> WorldTransform(List <Vector2D> points, Vector2D pos, Vector2D forward, Vector2D side, Vector2D scale) { //copy the original vertices into the buffer about to be transformed List <Vector2D> TranVector2Ds = points; //create a transformation matrix C2DMatrix matTransform = new C2DMatrix(); //scale if ((scale.X != 1.0) || (scale.Y != 1.0)) { matTransform.Scale(scale.X, scale.Y); } //rotate matTransform.Rotate(forward, side); //and translate matTransform.Translate(pos.X, pos.Y); //now transform the object's vertices matTransform.TransformVector2Ds(TranVector2Ds); return(TranVector2Ds); }
//--------------------- PointToWorldSpace -------------------------------- // // Transforms a point from the agent's local space into world space //------------------------------------------------------------------------ public static 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); }
//--------------------- PointToWorldSpace -------------------------------- // // Transforms a point from the agent's local space into world space //------------------------------------------------------------------------ public static 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; }
//--------------------------- WorldTransform ----------------------------- // // given a std::vector of 2D vectors, a position and orientation // this function transforms the 2D vectors into the object's world space //------------------------------------------------------------------------ public static List<Vector2D> WorldTransform(List<Vector2D> points, Vector2D pos, Vector2D forward, Vector2D side) { //copy the original vertices into the buffer about to be transformed List<Vector2D> TranVector2Ds = points; //create a transformation matrix C2DMatrix matTransform = new C2DMatrix(); //rotate matTransform.Rotate(forward, side); //and translate matTransform.Translate(pos.X, pos.Y); //now transform the object's vertices matTransform.TransformVector2Ds( TranVector2Ds); return TranVector2Ds; }