Translate() public method

public Translate ( double x, double y ) : void
x double
y double
return void
Exemplo n.º 1
0
        /// <summary>
        ///  given a List of 2D vectors, a position and  orientation
        ///  this function transforms the 2D vectors into the object's world space
        ///
        /// </summary>
        /// <param name="points"></param>
        /// <param name="pos"></param>
        /// <param name="forward"></param>
        /// <param name="side"></param>
        /// <returns></returns>
        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 = new List <Vector2D>();

            // make deep copy of buffer
            for (int pointIndex = 0; pointIndex < points.Count; pointIndex++)
            {
                TranVector2Ds.Add(new Vector2D(points[pointIndex]));
            }

            //create a transformation matrix
            Matrix2D matTransform = new Matrix2D();

            //rotate
            matTransform.Rotate(forward, side);

            //and translate
            matTransform.Translate(pos.X, pos.Y);

            //now transform the object's vertices
            matTransform.TransformVector2Ds(TranVector2Ds);

            return(TranVector2Ds);
        }
Exemplo n.º 2
0
        public static void DrawVector(Graphics g, Vector2D position, Vector2D lookAt)
        {
            Matrix2D mat = new Matrix2D();

            mat.Translate(position.X, position.Y);

            Vector2D lookAtCopy = new Vector2D(position.X + lookAt.X, position.Y + lookAt.Y);

            //lookAtCopy *= .5;

            //mat.TransformVector2Ds(lookAtCopy);

            g.DrawLine(_currentPen, new Point((int)position.X, (int)position.Y), new Point((int)lookAtCopy.X, (int)lookAtCopy.Y));
        }
Exemplo n.º 3
0
        /// <summary>
        ///  Transforms a point from the agent's local space into world space
        ///
        /// </summary>
        /// <param name="point"></param>
        /// <param name="AgentHeading"></param>
        /// <param name="AgentSide"></param>
        /// <param name="AgentPosition"></param>
        /// <returns></returns>
        public static Vector2D PointToWorldSpace(Vector2D point,
                                                 Vector2D AgentHeading,
                                                 Vector2D AgentSide,
                                                 Vector2D AgentPosition)
        {
            //make a copy of the point
            Vector2D TransPoint = new Vector2D(point);

            //create a transformation matrix
            Matrix2D matTransform = new Matrix2D();

            //rotate
            //matTransform.Rotate(AgentHeading, AgentSide);

            //and translate
            matTransform.Translate(AgentPosition.X, AgentPosition.Y);

            //now transform the vertices
            matTransform.TransformVector2Ds(TransPoint);

            return(TransPoint);
        }
Exemplo n.º 4
0
        /// <summary>
        ///  given a List of 2D vectors, a position, orientation and scale,
        ///  this function transforms the 2D vectors into the object's world space
        /// 
        /// </summary>
        /// <param name="points"></param>
        /// <param name="pos"></param>
        /// <param name="forward"></param>
        /// <param name="side"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        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 = new List<Vector2D>();
            
            // make deep copy of buffer
            for (int pointIndex = 0; pointIndex < points.Count; pointIndex++)
            {
                TranVector2Ds.Add(new Vector2D(points[pointIndex]));
            }

            //create a transformation matrix
            Matrix2D matTransform = new Matrix2D();

            //scale
            if ((scale.X != 1.0) || (scale.Y != 1.0))
            {
                matTransform.Scale((float)scale.X, (float)scale.Y);
            }

            //rotate
            matTransform.Rotate(forward, side);

            //matTransform.Rotate(190.0 * (3.14159 / 180));

            //and translate
            matTransform.Translate(pos.X, pos.Y);

            //now transform the object's vertices
            matTransform.TransformVector2Ds(TranVector2Ds);

            return TranVector2Ds;
        }
Exemplo n.º 5
0
        public static void DrawVector(Graphics g, Vector2D position, Vector2D lookAt)
        {
            Matrix2D mat = new Matrix2D();

            mat.Translate(position.X, position.Y);

            Vector2D lookAtCopy = new Vector2D(position.X + lookAt.X, position.Y + lookAt.Y);
            //lookAtCopy *= .5;

            //mat.TransformVector2Ds(lookAtCopy);

            g.DrawLine(_currentPen, new Point((int)position.X, (int)position.Y), new Point((int)lookAtCopy.X, (int)lookAtCopy.Y));
        }
Exemplo n.º 6
0
        /// <summary>
        ///  Transforms a point from the agent's local space into world space
        /// 
        /// </summary>
        /// <param name="point"></param>
        /// <param name="AgentHeading"></param>
        /// <param name="AgentSide"></param>
        /// <param name="AgentPosition"></param>
        /// <returns></returns>
        public static Vector2D PointToWorldSpace(Vector2D point,
                                            Vector2D AgentHeading,
                                            Vector2D AgentSide,
                                            Vector2D AgentPosition)
        {
            //make a copy of the point
            Vector2D TransPoint = new Vector2D(point);

            //create a transformation matrix
            Matrix2D matTransform = new Matrix2D();

            //rotate
            //matTransform.Rotate(AgentHeading, AgentSide);

            //and translate
            matTransform.Translate(AgentPosition.X, AgentPosition.Y);

            //now transform the vertices
            matTransform.TransformVector2Ds(TransPoint);

            return TransPoint;
        }