Transform2d

References
Represents the values in a 2d affine transformation.

This is parallel to C++ ON_Xform2d.

Constructors

Transform2d

#Since v9.0
public Transform2d(double diagonalValue)
Initializes a new transform matrix with a specified value along the diagonal.
diagonalValue (double)Value to assign to M00 and M11. The translation is zero.

Transform2d

#Since v9.0
public Transform2d(double m00, double m01, double m02, double m10, double m11, double m12)
Initializes a new transform matrix from its six values.
m00 (double)Value at [0,0].
m01 (double)Value at [0,1].
m02 (double)Value at [0,2], the X translation.
m10 (double)Value at [1,0].
m11 (double)Value at [1,1].
m12 (double)Value at [1,2], the Y translation.

Transform2d

#Since v9.0
public Transform2d(Transform2d value)
Initializes a new transform matrix from another transform matrix.
value (Transform2d)The transform to copy.

Properties

Determinant

#Since v9.0
public double Determinant { get; }
The determinant of the 2x2 linear part of this matrix. Because the bottom row is (0,0,1) this is also the signed area scale factor of the transformation. A negative determinant means the transformation reverses orientation.

Identity

#Since v9.0
public static Transform2d Identity { get; }
Gets a new identity transform matrix. An identity matrix defines no transformation.

IsIdentity

#Since v9.0
public bool IsIdentity { get; }
Return true if this Transform2d is the identity transform.

IsTranslation

#Since v9.0
public bool IsTranslation { get; }
True if this transform is a pure translation, that is the linear part is the 2x2 identity.

IsValid

#Since v9.0
public bool IsValid { get; }
Gets a value indicating whether or not this Transform2d is a valid matrix. A valid transform matrix is not allowed to have any invalid numbers.

IsZeroTransformation

#Since v9.0
public bool IsZeroTransformation { get; }
True if every value is 0. This transformation maps every point to (0,0).

M00

#Since v9.0
public double M00 { get; set; }
Gets or sets this[0,0].

M01

#Since v9.0
public double M01 { get; set; }
Gets or sets this[0,1].

M02

#Since v9.0
public double M02 { get; set; }
Gets or sets this[0,2], the X translation.

M10

#Since v9.0
public double M10 { get; set; }
Gets or sets this[1,0].

M11

#Since v9.0
public double M11 { get; set; }
Gets or sets this[1,1].

M12

#Since v9.0
public double M12 { get; set; }
Gets or sets this[1,2], the Y translation.

Nan

#Since v9.0
public static Transform2d Nan { get; }
Gets a transform matrix in which every value is not-a-number. The static constructors return this when they are given invalid input.

Unset

#Since v9.0
public static Transform2d Unset { get; }
Gets a transform matrix filled with RhinoMath.UnsetValue.

ZeroTransformation

#Since v9.0
public static Transform2d ZeroTransformation { get; }
Gets a transform matrix in which every value is zero. This transformation maps every point to (0,0).

Indexers

this[]

#
public double this[int row, int column] { get; set; }
Gets or sets the matrix value at the given row and column indices.
The new value at [row, column]
row (int)Index of row to access, must be 0 or 1.
column (int)Index of column to access, must be 0, 1 or 2.
The value at [row, column]

Methods

Clone

#Since v9.0
[ConstOperation] public Transform2d Clone()
Returns a deep copy of the transform. For languages that treat structures as value types, this can be accomplished by a simple assignment.
A deep copy of this data structure.

CompareTo

#Since v9.0
[ConstOperation] public int CompareTo(Transform2d other)
Compares this transform with another transform.

M00 has highest value, then M01, etc..

other (Transform2d)Another transform.
-1 if this < other; 0 if both are equal; 1 otherwise.

Equals

#
[ConstOperation] public override bool Equals(object obj)
Determines if another object is a Transform2d and its value equals this transform value.
obj (object)Another object.
true if obj is a Transform2d and has the same value as this transform; otherwise, false.
ValueType.Equals

Equals

#Since v9.0
[ConstOperation] public bool Equals(Transform2d other)
Determines if another transform equals this transform value.
other (Transform2d)Another transform.
true if other has the same value as this transform; otherwise, false.

FromAffineElements

#Since v9.0
public static Transform2d FromAffineElements(double a, double b, double c, double d, double tx, double ty)
Creates a transform from the six coefficients used by the traditional 2d drawing APIs. See the remarks on ToAffineElements().
a (double)Becomes M00.
b (double)Becomes M10.
c (double)Becomes M01.
d (double)Becomes M11.
tx (double)Becomes M02, the X translation.
ty (double)Becomes M12, the Y translation.
The equivalent transform.

FromAffineElements

#Since v9.0
public static Transform2d FromAffineElements(double[] elements)
Creates a transform from an array of six coefficients in (a, b, c, d, tx, ty) order.
elements (double[])Six coefficients. This is the layout of Eto.Drawing.IMatrix.Elements.
The equivalent transform, or Transform2d.Nan when elements is null or has fewer than six values.

FromAffineElements

#Since v9.0
public static Transform2d FromAffineElements(float[] elements)
Creates a transform from an array of six coefficients in (a, b, c, d, tx, ty) order.
elements (float[])Six coefficients. This is the layout of Eto.Drawing.IMatrix.Elements.
The equivalent transform, or Transform2d.Nan when elements is null or has fewer than six values.

GetAffineElements

#Since v9.0
[ConstOperation] public void GetAffineElements(out double a, out double b, out double c, out double d, out double tx, out double ty)
Gets the six coefficients used by the traditional 2d drawing APIs. See the remarks on ToAffineElements().
a (out double)M00.
b (out double)M10.
c (out double)M01.
d (out double)M11.
tx (out double)M02, the X translation.
ty (out double)M12, the Y translation.

GetHashCode

#
[ConstOperation] public override int GetHashCode()
Gets a non-unique hashing code for this transform.
A number that can be used to hash this transform in a dictionary.

Multiply

#Since v9.0
public static Transform2d Multiply(Transform2d a, Transform2d b)
Multiplies (combines) two transformations.

This is the same as the * operator between two transformations.

a (Transform2d)First transformation.
b (Transform2d)Second transformation.
A transformation matrix that combines the effect of both input transformations. The resulting Transform2d gives the same result as though you'd first apply B then A.

Rotation

#Since v9.0
public static Transform2d Rotation(double angleRadians, Point2d rotationCenter)
Constructs a new rotation transformation with a specified rotation center.
angleRadians (double)Angle, in radians, of the rotation. A positive angle rotates the X axis towards the Y axis.
rotationCenter (Point2d)The fixed point of the rotation.
A rotation transformation, or Transform2d.Nan if the input is not valid.

Rotation

#Since v9.0
public static Transform2d Rotation(double angleRadians)
Constructs a new rotation transformation with the origin as the rotation center.
angleRadians (double)Angle, in radians, of the rotation. A positive angle rotates the X axis towards the Y axis.
A rotation transformation, or Transform2d.Nan if the angle is not valid.

Rotation

#Since v9.0
public static Transform2d Rotation(double sinAngle, double cosAngle, Point2d rotationCenter)
Constructs a new rotation transformation from the sine and cosine of an angle and a specified rotation center.
sinAngle (double)The sine of the rotation angle.
cosAngle (double)The cosine of the rotation angle.
rotationCenter (Point2d)The fixed point of the rotation.
A rotation transformation, or Transform2d.Nan if the input is not valid.

Rotation

#Since v9.0
public static Transform2d Rotation(Vector2d startDirection, Vector2d endDirection, Point2d rotationCenter)
Constructs the rotation that maps one direction onto another while fixing a rotation center.
startDirection (Vector2d)A nonzero direction. Its length is ignored.
endDirection (Vector2d)A nonzero direction. Its length is ignored.
rotationCenter (Point2d)The fixed point of the rotation.
A rotation transformation, or Transform2d.Nan if either direction is zero.

Scale

#Since v9.0
public static Transform2d Scale(Point2d anchor, double scaleFactor)
Constructs a new uniform scaling transformation with a specified anchor point.
anchor (Point2d)The fixed point of the scaling.
scaleFactor (double)The scaling factor in both directions.
A transform matrix which scales geometry uniformly around the anchor point.

Scale

#Since v9.0
public static Transform2d Scale(Point2d anchor, double xScaleFactor, double yScaleFactor)
Constructs a new non-uniform scaling transformation with a specified anchor point.
anchor (Point2d)The fixed point of the scaling.
xScaleFactor (double)The scaling factor along the world X axis.
yScaleFactor (double)The scaling factor along the world Y axis.
A transform matrix which scales geometry around the anchor point.
Explicit

ICloneable.Clone

#Since v9.0

ToAffineElements

#Since v9.0
[ConstOperation] public double[] ToAffineElements()
Gets the six coefficients used by the traditional 2d drawing APIs as an array in (a, b, c, d, tx, ty) order.
Remarks: Those APIs map a point (x,y) to (a*x + c*y + tx, b*x + d*y + ty), so the six values are the transpose of the Transform2d value order: a is M00, b is M10, c is M01, d is M11, tx is M02 and ty is M12. Composition order is reversed as well, because those APIs use the row vector convention: A2d * B2d is the equivalent of the platform product B * A.
Six values.

ToString

#
[ConstOperation] public override string ToString()
Returns a string representation of this transform.
A textual representation.

ToTransform

#Since v9.0
[ConstOperation] public Transform ToTransform()
Gets the 4x4 transformation that applies this 2d transformation to the x and y coordinates and leaves the z coordinate unchanged.
The equivalent 4x4 transformation.

Translation

#Since v9.0
public static Transform2d Translation(double dx, double dy)
Constructs a new translation (move) transformation. Right column is (dx, dy).
dx (double)Distance to translate (move) geometry along the world X axis.
dy (double)Distance to translate (move) geometry along the world Y axis.
A transform matrix which moves geometry with the specified distances.

Translation

#Since v9.0
public static Transform2d Translation(Vector2d motion)
Constructs a new translation (move) transformation.
motion (Vector2d)Translation (motion) vector.
A transform matrix which moves geometry along the motion vector.

TryGetInverse

#Since v9.0
[ConstOperation] public bool TryGetInverse(out Transform2d inverseTransform)
Attempts to get the inverse transform of this transform.
inverseTransform (out Transform2d)The inverse transform. This out reference will be assigned during this call.
true on success. If false is returned and this Transform2d is invalid, inverseTransform will be set to this Transform2d. If false is returned and this Transform2d is valid, inverseTransform will be set to a pseudo inverse.

TryGetTransform2d

#Since v9.0
public static bool TryGetTransform2d(Transform transform, double zeroTolerance, out Transform2d transform2d)
Attempts to get the 2d transformation defined by the x and y rows and columns of a 4x4 transformation. This succeeds when transform is affine and maps the world xy plane to itself.
transform (Transform)The 4x4 transformation to convert.
zeroTolerance (double)A value of transform is "zero" if its absolute value is at most zeroTolerance, and is "one" if it differs from 1.0 by at most zeroTolerance.
transform2d (out Transform2d)The 2d transformation. This out reference will be assigned during this call.
true on success. On failure transform2d is set to Transform2d.Nan.

TryGetTransform2d

#Since v9.0
public static bool TryGetTransform2d(Transform transform, out Transform2d transform2d)
Attempts to get the 2d transformation defined by the x and y rows and columns of a 4x4 transformation. This succeeds when transform is affine and maps the world xy plane to itself.
transform (Transform)The 4x4 transformation to convert.
transform2d (out Transform2d)The 2d transformation. This out reference will be assigned during this call.
true on success. On failure transform2d is set to Transform2d.Nan.

Operators

OperationResultDescription
Transform2d==Transform2dboolDetermines if two transformations are equal in value.
Transform2d!=Transform2dboolDetermines if two transformations are different in value.
Transform2d*Point2dPoint2dMultiplies a transformation by a point and gets a new point.
Transform2d*Transform2dTransform2dMultiplies (combines) two transformations.
Transform2d*Vector2dVector2dMultiplies a transformation by a vector and gets a new vector.