New to Telerik UI for WinForms? Start a free 30-day trial

RadMatrix

Struct

Represents a light-weight 3*3 Matrix to be used for GDI+ transformations.

Definition

Namespace:Telerik.WinControls.Layouts

Assembly:Telerik.WinControls.dll

Syntax:

C#
public struct RadMatrix

Constructors

Initializes a new RadMatrix, using the specified parameters.

C#
public RadMatrix(float m11, float m12, float m21, float m22, float dx, float dy)
Parameters:m11float

The matrix element at row 1, column 1.

m12float

The matrix element at row 1, column 2.

m21float

The matrix element at row 2, column 1.

m22float

The matrix element at row 2, column 2.

dxfloat

The X-axis translation component.

dyfloat

The Y-axis translation component.

Initializes a new RadMatrix, scaling it by the provided parameters, at the specified origin.

C#
public RadMatrix(float scaleX, float scaleY, PointF origin)
Parameters:scaleXfloat

The X-axis scale factor.

scaleYfloat

The Y-axis scale factor.

originPointF

The origin point for scaling.

Initializes a new RadMatrix, scaling it by the provided parameters, at the origin (0, 0).

C#
public RadMatrix(float scaleX, float scaleY)
Parameters:scaleXfloat

The X-axis scale factor.

scaleYfloat

The Y-axis scale factor.

Initializes a new RadMatrix, rotated by the specified angle (in degrees) at the provided origin.

C#
public RadMatrix(float angle, PointF origin)
Parameters:anglefloat

The rotation angle in degrees.

originPointF

The origin point for rotation.

Initializes a new RadMatrix, rotated by the specified angle (in degrees) at origin (0, 0).

C#
public RadMatrix(float angle)
Parameters:anglefloat

The rotation angle in degrees.

Initializes a new RadMatrix, using the elements of the specified GDI+ Matrix instance.

C#
public RadMatrix(Matrix gdiMatrix)
Parameters:gdiMatrixMatrix

The GDI+ Matrix to copy elements from.

Initializes a new RadMatrix, applying the specified X and Y values as DX and DY members of the matrix.

C#
public RadMatrix(PointF offset)
Parameters:offsetPointF

The point containing the X and Y offset values.

Copy constructor.

C#
public RadMatrix(RadMatrix source)
Parameters:sourceRadMatrix

The source RadMatrix to copy from.

Fields

The factor for converting degrees to radians.

C#
public const float DegreeToRadian = 0.017453294

The X translation added to the transformed point's X coordinate.

C#
public float DX

The Y translation added to the transformed point's Y coordinate.

C#
public float DY

The zero matrix, which maps every point to the origin.

C#
public static readonly RadMatrix Empty

The matrix that leaves transformed points unchanged.

C#
public static readonly RadMatrix Identity

The coefficient multiplying the input X coordinate in the output X coordinate.

C#
public float M11

The coefficient multiplying the input X coordinate in the output Y coordinate.

C#
public float M12

The coefficient multiplying the input Y coordinate in the output X coordinate.

C#
public float M21

The coefficient multiplying the input Y coordinate in the output Y coordinate.

C#
public float M22

The single-precision approximation of pi used by the angle conversion constants.

C#
public const float PI = 3.141593

The factor for converting radians to degrees.

C#
public const float RadianToDegree = 57.295773

Twice the single-precision pi approximation used by this type.

C#
public const float TwoPI = 6.283186

Properties

Gets the determinant - [(M11 * M22) - (M12 * M21)] - of this Matrix.

C#
public float Determinant { get; }

Gets all the six fields of the matrix as an array.

C#
public float[] Elements { get; }

Determines whether the current matrix is empty.

C#
public bool IsEmpty { get; }

Determines whether this matrix equals to the Identity one.

C#
public bool IsIdentity { get; }

Determines whether this matrix may be inverted. That is to have non-zero determinant.

C#
public bool IsInvertible { get; }

Gets the rotation (in degrees) applied to this matrix.

C#
public float Rotation { get; }

Gets the scale by the X axis, provided by this matrix.

C#
public float ScaleX { get; }

Gets the scale by the Y axis, provided by this matrix.

C#
public float ScaleY { get; }

Methods

Prepends the inverse of another matrix to this matrix.

C#
public void Divide(RadMatrix m)
Parameters:mRadMatrix

The matrix to invert and apply.

If m has a zero determinant, its inverse becomes Empty; prepending it zeroes this matrix's linear components while preserving its existing DX and DY.

Determines whether this matrix's components equal the six values in an array.

C#
public bool Equals(float[] elements)
Parameters:elementsfloat[]

The matrix components in GDI+ element order.

Returns:

bool

true when all six components are exactly equal.

Exceptions: ArgumentException

elements does not contain exactly six values.

Determines whether the six components equal those of a GDI+ matrix.

C#
public bool Equals(Matrix gdiMatrix)
Parameters:gdiMatrixMatrix

The matrix to compare.

Returns:

bool

true when all six components are exactly equal.

Determines whether the specified object is a RadMatrix with identical components.

C#
public override bool Equals(object obj)
Parameters:objobject

The object to compare with this matrix.

Returns:

bool

true when obj is a matrix with exactly matching components.

Overrides: ValueType.Equals(object)

Combines the hash codes of all six matrix components.

C#
public override int GetHashCode()
Returns:

int

A hash code for this matrix.

Overrides: ValueType.GetHashCode()

Replaces this matrix with its inverse, or with Empty when its determinant is zero.

C#
public void Invert()

Multiplies this matrix by another using the requested composition order.

C#
public void Multiply(RadMatrix m, MatrixOrder order)
Parameters:mRadMatrix

The matrix to multiply by.

orderMatrixOrder

Selects m * this for Prepend or this * m for Append.

Prepends another matrix to this matrix.

C#
public void Multiply(RadMatrix m)
Parameters:mRadMatrix

The matrix to multiply by.

Calculates the Euclidean distance between two floating-point points.

C#
public static float PointsDistance(PointF pt1, PointF pt2)
Parameters:pt1PointF

The first point.

pt2PointF

The second point.

Returns:

float

The distance between the points.

Restores this matrix to Identity.

C#
public void Reset()

Applies a rotation about the origin using the specified matrix composition order.

C#
public void Rotate(float angle, MatrixOrder order)
Parameters:anglefloat

The rotation angle in degrees.

orderMatrixOrder

Whether the rotation is prepended or appended to this matrix.

Prepends a rotation about the origin.

C#
public void Rotate(float angle)
Parameters:anglefloat

The rotation angle in degrees.

Applies a rotation around the specified point using the requested matrix composition order.

C#
public void RotateAt(float angle, PointF origin, MatrixOrder order)
Parameters:anglefloat

The rotation angle in degrees.

originPointF

The point that remains fixed by the rotation.

orderMatrixOrder

Whether the rotation is prepended or appended to this matrix.

Prepends a rotation around the specified point.

C#
public void RotateAt(float angle, PointF origin)
Parameters:anglefloat

The rotation angle in degrees.

originPointF

The point that remains fixed by the rotation.

Applies a scale transformation using the specified matrix composition order.

C#
public void Scale(float scaleX, float scaleY, MatrixOrder order)
Parameters:scaleXfloat

The scale factor along the X axis.

scaleYfloat

The scale factor along the Y axis.

orderMatrixOrder

Whether the scale is prepended or appended to this matrix.

Prepends a scale transformation about the origin.

C#
public void Scale(float scaleX, float scaleY)
Parameters:scaleXfloat

The scale factor along the X axis.

scaleYfloat

The scale factor along the Y axis.

Creates a GDI+ matrix with the same six transformation components.

C#
public Matrix ToGdiMatrix()
Returns:

Matrix

A new Matrix containing this matrix's components.

Formats the translation offset of this matrix.

C#
public override string ToString()
Returns:

string

A string containing DX and DY; the linear transformation components are omitted.

Overrides: ValueType.ToString()

Applies this matrix's linear and translation components to a point.

C#
public PointF TransformPoint(PointF point)
Parameters:pointPointF

The point to transform.

Returns:

PointF

The transformed point.

Transforms each point in the supplied array in place.

C#
public void TransformPoints(PointF[] points)
Parameters:pointsPointF[]

The points to transform.

Transforms the top-left and bottom-right corners of a rectangle.

C#
public RectangleF TransformRectangle(RectangleF bounds)
Parameters:boundsRectangleF

The rectangle to transform.

Returns:

RectangleF

A rectangle formed from the transformed diagonal corners; this is not an axis-aligned bounding box for rotations or shears.

Applies a translation using the specified matrix composition order.

C#
public void Translate(float dx, float dy, MatrixOrder order)
Parameters:dxfloat

The horizontal offset.

dyfloat

The vertical offset.

orderMatrixOrder

Whether the translation is prepended or appended to this matrix.

Prepends a translation by the specified offsets.

C#
public void Translate(float dx, float dy)
Parameters:dxfloat

The horizontal offset.

dyfloat

The vertical offset.

Operators

Determines whether any component of two matrices differs.

C#
public static bool operator !=(RadMatrix a, RadMatrix b)
Parameters:aRadMatrix

The first matrix.

bRadMatrix

The second matrix.

Returns:

bool

true when the components are not exactly equal.

Multiplies two matrices to compose their affine transformations.

C#
public static RadMatrix operator *(RadMatrix a, RadMatrix b)
Parameters:aRadMatrix

The left-hand matrix.

bRadMatrix

The right-hand matrix.

Returns:

RadMatrix

The product of a and b.

Determines whether all six components of two matrices are exactly equal.

C#
public static bool operator ==(RadMatrix a, RadMatrix b)
Parameters:aRadMatrix

The first matrix.

bRadMatrix

The second matrix.

Returns:

bool

true when the components match exactly.