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
La structure Matrix2d représente une matrice de transformation 3x3 pour les transformations géométriques 2D. Elle est utilisée pour les opérations de translation, rotation, mise à l'échelle et symétrie dans le plan XY.
Namespace
Autodesk.AutoCAD.Geometry
Propriétés Clés
Propriété
Type
Description
Inverse
Matrix2d
Obtient la matrice inverse
IsIdentity
bool
Vérifie si la matrice est une matrice identité
IsUniscaledOrtho
bool
Vérifie si la matrice est orthogonale avec mise à l'échelle uniforme
Méthodes de Fabrique Statiques
Méthode
Description
Identity
Retourne la matrice identité (aucune transformation)
Displacement(Vector2d)
Crée une matrice de translation
Rotation(double, Point2d)
Crée une matrice de rotation autour d'un point
Scaling(double, Point2d)
Crée une matrice de mise à l'échelle uniforme
Mirroring(Line2d)
Crée une transformation de symétrie à travers une ligne
Mirroring(Point2d)
Crée une transformation de symétrie à travers un point
Méthodes Clés
Méthode
Type de Retour
Description
PreMultiplyBy(Matrix2d)
Matrix2d
Multiplie cette matrice par une autre
PostMultiplyBy(Matrix2d)
Matrix2d
Multiplie une autre matrice par celle-ci
Transpose()
Matrix2d
Retourne la matrice transposée
Invert()
Matrix2d
Retourne la matrice inversée
IsEqualTo(Matrix2d)
bool
Vérifie l'égalité
Exemples de Code
Exemple 1: Translation
// Déplacer de 10 unités en X, 5 en 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($"\nDéplacé : ({moved.X}, {moved.Y})");
Exemple 2: Rotation
// Rotation de 45° autour de l'originedoubleangle=Math.PI/4;Point2dcenter=newPoint2d(0,0);Matrix2drotation=Matrix2d.Rotation(angle,center);Point2dpt=newPoint2d(10,0);Point2drotated=pt.TransformBy(rotation);ed.WriteMessage($"\nRotation 45° : ({rotated.X:F2}, {rotated.Y:F2})");
Exemple 3: Mise à l'Échelle
// Mise à l'échelle 2x depuis l'originePoint2dscaleBase=newPoint2d(0,0);Matrix2dscale=Matrix2d.Scaling(2.0,scaleBase);Point2dpt=newPoint2d(5,5);Point2dscaled=pt.TransformBy(scale);ed.WriteMessage($"\nMis à l'échelle : ({scaled.X}, {scaled.Y})");// (10, 10)
Exemple 4: Combinaison de Transformations
// Déplacer, rotation, mise à l'échelleVector2dmove=newVector2d(10,5);Matrix2dtranslation=Matrix2d.Displacement(move);Matrix2drotation=Matrix2d.Rotation(Math.PI/4,newPoint2d(0,0));Matrix2dscale=Matrix2d.Scaling(2.0,newPoint2d(0,0));// Combiner : scale * rotate * translateMatrix2dcombined=translation.PreMultiplyBy(rotation).PreMultiplyBy(scale);Point2dpt=newPoint2d(5,0);Point2dtransformed=pt.TransformBy(combined);ed.WriteMessage($"\nTransformé : ({transformed.X:F2}, {transformed.Y:F2})");
Bonnes Pratiques
Utiliser pour 2D : Préférer Matrix2d à Matrix3d pour les transformations planaires
Ordre de Transformation : L'ordre de multiplication des matrices est important
Combiner les Transformations : Combiner plusieurs transformations pour l'efficacité
Inverse : Utiliser Inverse pour annuler les transformations