Table of Contents

Class MatrixExtensions

Namespace
Icy.Rendering
Assembly
IcyUI.dll

Provides some extensions for the matrices and vectors.

public static class MatrixExtensions
Inheritance
MatrixExtensions
Inherited Members

Methods

Cut(Rectangle, Rectangle?)

Cuts the part of specified rectangle.

public static Rectangle Cut(this Rectangle origin, Rectangle? scissor)

Parameters

origin Rectangle

A rectangle to cut part from.

scissor Rectangle?

A sector that is to be cut from this one or null if origin should be preserved.

Returns

Rectangle

Maximal possible part of the cut rectangle.

Decompose(in Matrix3x2, out Vector2, out float, out Vector2)

Decomposes Matrix 3x2 and gets its parts such as translation, rotation and scale.

public static void Decompose(this in Matrix3x2 matrix, out Vector2 translation, out float rotation, out Vector2 scale)

Parameters

matrix Matrix3x2

Matrix instance to decompose.

translation Vector2

Translation matrix component.

rotation float

Rotation matrix component.

scale Vector2

Scale matrix component.

Remarks

Inverts the specific composition Transform2D's BuildMatrix produces - linear part Rotate(rotation) * Scale(scale), translation applied before both (see Transform2D.Create) - not a generic scale-then-rotate-then-translate decomposition. Scale is recovered from column norms (not row norms, which would assume the opposite Scale * Rotate linear-part order), and the raw matrix translation is then un-scaled/un-rotated to recover the original pre-transform position, since BuildMatrix applies translation before rotation/scale, not after.

DecomposeAngles(Quaternion, out float, out float, out float)

Gets one of the possible angle components from the specified quaternion.

public static void DecomposeAngles(this Quaternion r, out float yaw, out float pitch, out float roll)

Parameters

r Quaternion

Quaternion to get rotation from.

yaw float

Yaw rotation component (around Y axis).

pitch float

Pitch rotation component (around X axis).

roll float

Roll rotation component (around Z axis).

Remarks

Note that there are two possible angle combinations so only one of them will be returned.

GetYawPitchRoll(Quaternion)

Gets one of the possible angle components from the specified quaternion.

public static Vector3 GetYawPitchRoll(this Quaternion rotation)

Parameters

rotation Quaternion

Quaternion to get rotation from.

Returns

Vector3

Vector with yaw-pitch-roll components mapped to XYZ alphabetically.

Remarks

Note that there are two possible angle combinations so only one of them will be returned. Resulting vector components does not represent axes to rotate around.

ToPoint(Vector2)

Gets the Point with the same coordinates as the specified Vector2.

public static Point ToPoint(this Vector2 vector)

Parameters

vector Vector2

The vector to get coordinates from.

Returns

Point

An instance of the Point with the same coordinates as the vector have.

ToPointF(Vector2)

Gets the PointF with the same coordinates as the specified Vector2.

public static PointF ToPointF(this Vector2 vector)

Parameters

vector Vector2

The vector to get coordinates from.

Returns

PointF

An instance of the PointF with the same coordinates as the vector have.

ToVector(Point)

Get the vector representation of the specified Point.

public static Vector2 ToVector(this Point point)

Parameters

point Point

The point to get vector for.

Returns

Vector2

An instance of the Vector2 representing the same coordinates as the point have.

ToVector(PointF)

Get the vector representation of the specified PointF.

public static Vector2 ToVector(this PointF point)

Parameters

point PointF

The point to get vector for.

Returns

Vector2

An instance of the Vector2 representing the same coordinates as the point have.

XY(Vector3)

Gets two-dimensional Vector3 components represented as Vector2.

public static Vector2 XY(this Vector3 vector)

Parameters

vector Vector3

The vector to get X and Y components from.

Returns

Vector2

Instance of the Vector2 struct with X set to vector.X and Y set to vector.Y.

XY(Vector4)

Gets two-dimensional Vector4 components represented as Vector2.

public static Vector2 XY(this Vector4 vector)

Parameters

vector Vector4

The vector to get X and Y components from.

Returns

Vector2

Instance of the Vector2 struct with X set to vector.X and Y set to vector.Y.

XYZ(Vector4)

Gets three-dimensional Vector4 components represented as Vector3.

public static Vector3 XYZ(this Vector4 vector)

Parameters

vector Vector4

The vector to get X, Y and Z components from.

Returns

Vector3

Instance of the Vector3 struct with X set to vector.X, Y set to vector.Y and Z set to vector.Z.