Yuari
Documentation
Docs/Data types/CFrame constructors

CFrame constructors

Identity constant and rotation constructors from an axis, a basis or Euler angles.

Syntax

CFrame.identity -> CFrame
CFrame.fromAxisAngle(axis: Vector3, angle: number) -> CFrame
CFrame.fromMatrix(position: Vector3, vX: Vector3, vY: Vector3, vZ?: Vector3) -> CFrame
CFrame.fromEulerAnglesXYZ(rx: number, ry: number, rz: number) -> CFrame
CFrame.fromEulerAnglesYXZ(rx: number, ry: number, rz: number) -> CFrame

Parameters

ParameterTypeDescription
axisVector3Rotation axis; normalized internally, must not be zero-length.
anglenumberRotation in radians.
positionVector3Translation of the resulting CFrame.
vX vY vZVector3Basis columns. vZ defaults to vX × vY.
rx ry rznumberEuler angles in radians.

Returns

TypeDescription
CFrameThe constructed CFrame.

Description

CFrame.identity is a ready-made zero-rotation CFrame at the origin.

fromEulerAnglesXYZ is the same function as CFrame.Angles, applied in X, Y, Z order; fromEulerAnglesYXZ applies Y first, then X, then Z.

fromMatrix orthonormalizes the supplied columns, so slightly non-orthogonal input is accepted; a degenerate basis raises an error.

Example

local cf = CFrame.fromAxisAngle(Vector3.new(0, 1, 0), math.rad(90))
print(cf.LookVector.X)  -- -1

local m = CFrame.fromMatrix(Vector3.new(0, 5, 0), Vector3.new(1, 0, 0), Vector3.new(0, 1, 0))
print(m.Position)

Notes

  • CFrame.identity — A shared constant value; treat it as read-only.
  • fromAxisAngle zero axis — Raises "axis is zero-length".