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
originRectangleA rectangle to cut part from.
scissorRectangle?A sector that is to be cut from this one or null if
originshould 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
matrixMatrix3x2Matrix instance to decompose.
translationVector2Translation matrix component.
rotationfloatRotation matrix component.
scaleVector2Scale 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
rQuaternionQuaternion to get rotation from.
yawfloatYaw rotation component (around Y axis).
pitchfloatPitch rotation component (around X axis).
rollfloatRoll 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
rotationQuaternionQuaternion 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)
public static Point ToPoint(this Vector2 vector)
Parameters
vectorVector2The vector to get coordinates from.
Returns
ToPointF(Vector2)
public static PointF ToPointF(this Vector2 vector)
Parameters
vectorVector2The vector to get coordinates from.
Returns
ToVector(Point)
Get the vector representation of the specified Point.
public static Vector2 ToVector(this Point point)
Parameters
pointPointThe point to get vector for.
Returns
ToVector(PointF)
Get the vector representation of the specified PointF.
public static Vector2 ToVector(this PointF point)
Parameters
pointPointFThe point to get vector for.
Returns
XY(Vector3)
public static Vector2 XY(this Vector3 vector)
Parameters
vectorVector3The vector to get X and Y components from.
Returns
XY(Vector4)
public static Vector2 XY(this Vector4 vector)
Parameters
vectorVector4The vector to get X and Y components from.
Returns
XYZ(Vector4)
public static Vector3 XYZ(this Vector4 vector)
Parameters
vectorVector4The vector to get X, Y and Z components from.