Transform2d

References
Represents the values in a 2d affine transformation.

This is parallel to C++ ON_Xform2d.

Constructors

Transform2d

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

Transform2d

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

Transform2d

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

Properties

Determinant

#Since v9.0
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.
public double Determinant { get; }

Identity

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

IsIdentity

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

IsTranslation

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

IsValid

#Since v9.0
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.
public bool IsValid { get; }

IsZeroTransformation

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

M00

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

M01

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

M02

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

M10

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

M11

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

M12

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

Nan

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

Unset

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

ZeroTransformation

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

Indexers

this[]

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

Methods

Clone

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

CompareTo

#Since v9.0
Compares this transform with another transform.

M00 has highest value, then M01, etc..

[ConstOperation] public int CompareTo(
other
Another transform.
)
-1 if this < other; 0 if both are equal; 1 otherwise.

Equals

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

Equals

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

FromAffineElements

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

FromAffineElements

#Since v9.0
Creates a transform from an array of six coefficients in (a, b, c, d, tx, ty) order.
public static Transform2d FromAffineElements(
elements
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
Creates a transform from an array of six coefficients in (a, b, c, d, tx, ty) order.
public static Transform2d FromAffineElements(
elements
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
Gets the six coefficients used by the traditional 2d drawing APIs. See the remarks on ToAffineElements().
[ConstOperation] public void GetAffineElements(
out double
a,
M00.
out double
b,
M10.
out double
c,
M01.
out double
d,
M11.
out double
tx,
M02, the X translation.
out double
ty
M12, the Y translation.
)

GetHashCode

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

Multiply

#Since v9.0
Multiplies (combines) two transformations.

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

public static Transform2d Multiply(
a,
First transformation.
b
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
Constructs a new rotation transformation with a specified rotation center.
public static Transform2d Rotation(
angleRadians,
Angle, in radians, of the rotation. A positive angle rotates the X axis towards the Y axis.
rotationCenter
The fixed point of the rotation.
)
A rotation transformation, or Transform2d.Nan if the input is not valid.

Rotation

#Since v9.0
Constructs a new rotation transformation with the origin as the rotation center.
public static Transform2d Rotation(
angleRadians
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
Constructs a new rotation transformation from the sine and cosine of an angle and a specified rotation center.
public static Transform2d Rotation(
sinAngle,
The sine of the rotation angle.
cosAngle,
The cosine of the rotation angle.
rotationCenter
The fixed point of the rotation.
)
A rotation transformation, or Transform2d.Nan if the input is not valid.

Rotation

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

Scale

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

Scale

#Since v9.0
Constructs a new non-uniform scaling transformation with a specified anchor point.
public static Transform2d Scale(
anchor,
The fixed point of the scaling.
xScaleFactor,
The scaling factor along the world X axis.
yScaleFactor
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
Gets the six coefficients used by the traditional 2d drawing APIs as an array in (a, b, c, d, tx, ty) order.
[ConstOperation] public double[] ToAffineElements()
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

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

ToTransform

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

Translation

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

Translation

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

TryGetInverse

#Since v9.0
Attempts to get the inverse transform of this transform.
[ConstOperation] public bool TryGetInverse(
inverseTransform
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
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.
public static bool TryGetTransform2d(
transform,
The 4x4 transformation to convert.
zeroTolerance,
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
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
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.
public static bool TryGetTransform2d(
transform,
The 4x4 transformation to convert.
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.