Transform2d
References[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 48)]
[Serializable]
public struct Transform2d : IComparable<Transform2d>, IEquatable<Transform2d>, ICloneable
Represents the values in a 2d affine transformation.
This is parallel to C++ ON_Xform2d.
Constructors
Initializes a new transform matrix with a specified value along the diagonal.
Parameters:
| diagonalValue (double) | Value to assign to M00 and M11. The translation is zero. |
Initializes a new transform matrix from its six values.
public Transform2d(Transform2d value)
Initializes a new transform matrix from another transform matrix.
Parameters:
| value (Transform2d) | The transform to copy. |
Properties
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.
Gets a new identity transform matrix. An identity matrix defines no transformation.
Return true if this Transform2d is the identity transform.
True if this transform is a pure translation, that is the linear part is the 2x2 identity.
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.
True if every value is 0. This transformation maps every point to (0,0).
Gets a transform matrix in which every value is not-a-number. The static constructors return this when they are given invalid input.
Gets a transform matrix filled with RhinoMath.UnsetValue.
Gets a transform matrix in which every value is zero. This transformation maps every point to (0,0).
Indexers
this[]
#Gets or sets the matrix value at the given row and column indices.
Methods
Returns a deep copy of the transform. For languages that treat structures as value types, this can be accomplished by a simple assignment.
Returns: A deep copy of this data structure.
Compares this transform with another transform.
M00 has highest value, then M01, etc..
Parameters:
| other (Transform2d) | Another transform. |
Returns: -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.
Parameters:
| obj (object) | Another object. |
Returns: true if obj is a Transform2d and has the same value as this transform; otherwise, false.
Overrides: ValueType.Equals
Determines if another transform equals this transform value.
Parameters:
| other (Transform2d) | Another transform. |
Returns: true if other has the same value as this transform; otherwise, false.
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().
Creates a transform from an array of six coefficients in (a, b, c, d, tx, ty) order.
Parameters:
| elements (double[]) | Six coefficients. This is the layout of Eto.Drawing.IMatrix.Elements. |
Returns: The equivalent transform, or Transform2d.Nan when elements is null or has fewer than six values.
Creates a transform from an array of six coefficients in (a, b, c, d, tx, ty) order.
Parameters:
| elements (float[]) | Six coefficients. This is the layout of Eto.Drawing.IMatrix.Elements. |
Returns: The equivalent transform, or Transform2d.Nan when elements is null or has fewer than six values.
[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().
GetHashCode
#Gets a non-unique hashing code for this transform.
Returns: A number that can be used to hash this transform in a dictionary.
Overrides: ValueType.GetHashCode
Multiplies (combines) two transformations.
This is the same as the * operator between two transformations.
Parameters:
| a (Transform2d) | First transformation. |
| b (Transform2d) | Second transformation. |
Returns: 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.
Constructs a new rotation transformation with a specified rotation center.
Constructs a new rotation transformation with the origin as the rotation center.
Parameters:
| angleRadians (double) | Angle, in radians, of the rotation. A positive angle rotates the X axis towards the Y axis. |
Returns: A rotation transformation, or Transform2d.Nan if the angle is not valid.
Constructs a new rotation transformation from the sine and cosine of an angle and a specified rotation center.
public static Transform2d Rotation(Vector2d startDirection, Vector2d endDirection, Point2d rotationCenter)
Constructs the rotation that maps one direction onto another while fixing a rotation center.
Constructs a new uniform scaling transformation with a specified anchor point.
Constructs a new non-uniform scaling transformation with a specified anchor point.
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.
Returns: Six values.
ToString
#Returns a string representation of this transform.
Returns: A textual representation.
Overrides: ValueType.ToString
Gets the 4x4 transformation that applies this 2d transformation to the x and y coordinates and leaves the z coordinate unchanged.
Returns: The equivalent 4x4 transformation.
Constructs a new translation (move) transformation. Right column is (dx, dy).
Constructs a new translation (move) transformation.
Parameters:
| motion (Vector2d) | Translation (motion) vector. |
Returns: A transform matrix which moves geometry along the motion vector.
Attempts to get the inverse transform of this transform.
Parameters:
| inverseTransform (out Transform2d) | The inverse transform. This out reference will be assigned during this call. |
Returns: 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.
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.
Parameters:
| 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. |
Returns: true on success. On failure transform2d is set to Transform2d.Nan.
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.
Parameters:
| transform (Transform) | The 4x4 transformation to convert. |
| transform2d (out Transform2d) | The 2d transformation. This out reference will be assigned during this call. |
Returns: true on success. On failure transform2d is set to Transform2d.Nan.
Operators
| Operation | Result | Description | ||
|---|---|---|---|---|
| Transform2d | == | Transform2d | bool | Determines if two transformations are equal in value. |
| Transform2d | != | Transform2d | bool | Determines if two transformations are different in value. |
| Transform2d | * | Point2d | Point2d | Multiplies a transformation by a point and gets a new point. |
| Transform2d | * | Transform2d | Transform2d | Multiplies (combines) two transformations. |
| Transform2d | * | Vector2d | Vector2d | Multiplies a transformation by a vector and gets a new vector. |