You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Matrix2d struct represents a 3x3 transformation matrix for 2D geometric transformations. It is used for translation, rotation, scaling, and mirroring operations in the XY plane.
Namespace
Autodesk.AutoCAD.Geometry
Key Properties
Property
Type
Description
Inverse
Matrix2d
Gets the inverse matrix
IsIdentity
bool
Checks if matrix is identity matrix
IsUniscaledOrtho
bool
Checks if matrix is orthogonal with uniform scaling
Static Factory Methods
Method
Description
Identity
Returns identity matrix (no transformation)
Displacement(Vector2d)
Creates translation matrix
Rotation(double, Point2d)
Creates rotation matrix around point
Scaling(double, Point2d)
Creates uniform scaling matrix
Mirroring(Line2d)
Creates mirror transformation across line
Mirroring(Point2d)
Creates mirror transformation across point
Key Methods
Method
Return Type
Description
PreMultiplyBy(Matrix2d)
Matrix2d
Multiplies this matrix by another
PostMultiplyBy(Matrix2d)
Matrix2d
Multiplies another matrix by this
Transpose()
Matrix2d
Returns transposed matrix
Invert()
Matrix2d
Returns inverted matrix
IsEqualTo(Matrix2d)
bool
Checks equality
Code Examples
Example 1: Translation
// Move 10 units in X, 5 in YVector2ddisplacement=newVector2d(10,5);Matrix2dtranslation=Matrix2d.Displacement(displacement);Point2dpt=newPoint2d(0,0);Point2dmoved=pt.TransformBy(translation);ed.WriteMessage($"\nOriginal: ({pt.X}, {pt.Y})");ed.WriteMessage($"\nMoved: ({moved.X}, {moved.Y})");
Example 2: Rotation
// Rotate 45° around origindoubleangle=Math.PI/4;Point2dcenter=newPoint2d(0,0);Matrix2drotation=Matrix2d.Rotation(angle,center);Point2dpt=newPoint2d(10,0);Point2drotated=pt.TransformBy(rotation);ed.WriteMessage($"\nRotated 45°: ({rotated.X:F2}, {rotated.Y:F2})");
Example 3: Scaling
// Scale 2x from originPoint2dscaleBase=newPoint2d(0,0);Matrix2dscale=Matrix2d.Scaling(2.0,scaleBase);Point2dpt=newPoint2d(5,5);Point2dscaled=pt.TransformBy(scale);ed.WriteMessage($"\nScaled: ({scaled.X}, {scaled.Y})");// (10, 10)