/// <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); }
/// <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; }