# Matrix

A Matrix in StereoKit is a 4x4 grid of numbers that is used to represent a transformation for any sort of position or vector! This is an oversimplification of what a matrix actually is, but it’s accurate in this case.

Matrices are really useful for transforms because you can chain together all sorts of transforms into a single Matrix! A Matrix transform really shines when applied to many positions, as the more expensive operations get cached within the matrix values.

Matrices are prominently used within shaders for mesh transforms!

## Instance Methods

Inverse | Creates an inverse matrix! If the matrix takes a point from a -> b, then its inverse takes the point from b -> a. |

TransformDirection | Transforms a point through the Matrix, but excluding translation! This is great for transforming vectors that are -directions- rather than points in space. Use this to transform normals and directions. The same as multiplying (x,y,z,0) with the Matrix. |

TransformPoint | Transforms a point through the Matrix! This is basically just multiplying a vector (x,y,z,1) with the Matrix. |

TransformRay | Shorthand to transform a ray though the Matrix! This properly transforms the position with the point transform method, and the direction with the direction transform method. Does not normalize, nor does it preserve a normalized direction if the Matrix contains scale data. |

## Static Fields and Properties

Matrix Identity | An identity Matrix is the matrix equivalent of ‘1’! Transforming anything by this will leave it at the exact same place. |

## Static Methods

T | Translate. Creates a translation Matrix! |

TRS | Translate, Rotate, Scale. Creates a transform Matrix using all these components! |

TS | Translate, Scale. Creates a transform Matrix using both these components! |