> For the complete documentation index, see [llms.txt](https://vopwn55.gitbook.io/powerlang-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vopwn55.gitbook.io/powerlang-docs/libraries/special-types/cframe.md).

# CFrame

The CFrame type represents both a position and a rotation matrix in the game world. This library helps perform operations with CFrames.

| **Function**                                                           | **Description**                                                                                                                                                               |
| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `new(Position: Vector3, Rotation: Vector3)`                            | Constructs a new `CFrame` from position and rotation vectors. Takes 2 arguments: `Position` (Vector3) and `Rotation` (Vector3), returns a `CFrame`.                           |
| `split(CFrame: CFrame)`                                                | Splits a `CFrame` into its position and rotation components. Requires 1 argument: `CFrame`, and returns `Position` (Vector3) and `Rotation` (Vector3).                        |
| `lerp(StartCFrame: CFrame, GoalCFrame: CFrame, Alpha: number)`         | Performs linear interpolation between two `CFrame` values. Takes 3 arguments: `StartCFrame`, `GoalCFrame`, and `Alpha` (number), returns the resulting `CFrame`.              |
| `inverse(CFrame: CFrame)`                                              | Returns the inverse of the given `CFrame`. Takes 1 argument: `CFrame`, and returns the inverted `CFrame`.                                                                     |
| `toObjectSpace(CFrame: CFrame, ObjectCFrame: CFrame)`                  | Converts a `CFrame` to object space relative to another `CFrame`. Requires 2 arguments: `CFrame` and `ObjectCFrame`, returns the resulting `CFrame`.                          |
| `toWorldSpace(CFrame: CFrame, ObjectCFrame: CFrame)`                   | Converts a `CFrame` to world space relative to another `CFrame`. Requires 2 arguments: `CFrame` and `ObjectCFrame`, returns the resulting `CFrame`.                           |
| `direction(CFrame: CFrame, Direction: string)`                         | Gets the specified direction vector (forward, backward, left, etc.) from the `CFrame`. Requires 2 arguments: `CFrame` and `Direction` (string), returns the direction vector. |
| `Angles(rx: number, ry: number, rz: number)`                           | Constructs a `CFrame` using Euler angles. Takes 3 arguments: `rx`, `ry`, and `rz` (rotations around the x, y, and z axes), returns the resulting `CFrame`.                    |
| `toEulerAnglesXYZ(CFrame: CFrame)`                                     | Converts a `CFrame` to its corresponding Euler angles. Requires 1 argument: `CFrame`, returns the rotation angles `rx`, `ry`, and `rz`.                                       |
| `fromMatrix(Position: Vector3, vX: Vector3, vY: Vector3, vZ: Vector3)` | Constructs a `CFrame` from a position vector and three directional vectors. Takes 4 arguments: `Position`, `vX`, `vY`, and `vZ`, returns the resulting `CFrame`.              |
| `fromAxisAngle(v: Vector3, r: number)`                                 | Constructs a `CFrame` from an axis and a rotation angle. Takes 2 arguments: `v` (axis vector) and `r` (rotation angle), returns the resulting `CFrame`.                       |
