using System.Drawing; using System.Drawing.Drawing2D; // initialize a Matrix object with a rotation transformation Matrix rotationMatrix = new Matrix(); rotationMatrix.Rotate(30); // define an array of points to be transformed PointF[] points = { new PointF(0, 0), new PointF(50, 0), new PointF(50, 50) }; // apply the transformation to the points array rotationMatrix.TransformPoints(points); // the resulting transformed points will be: // (0,0), (43.3,-25), (18.7,43.3)
using System.Drawing; using System.Drawing.Drawing2D; // initialize a Matrix object with a scaling transformation Matrix scaleMatrix = new Matrix(); scaleMatrix.Scale(2, 3); // define another array of points to be transformed PointF[] points2 = { new PointF(10, 10), new PointF(100, 50), new PointF(50, 100) }; // apply the transformation to the points2 array scaleMatrix.TransformPoints(points2); // the resulting transformed points will be: // (20,30), (200,150), (100,300)In both examples, we are using the TransformPoints method of the Matrix class to apply a transformation (rotation and scaling, respectively) to an array of points. The resulting transformed points are returned in the same array. The package library used is the System.Drawing.Drawing2D library, part of the .NET framework.