メインコンテンツまでスキップ

rotateY: Y-Axis Vector Rotation Transform

Matrix-based rotation around the Y-axis

The rotateY functions provide Y-axis rotation transformations for 3D and 4D vectors using matrix operations. These functions generate rotation matrices that rotate vectors around the Y-axis by a specified angle.

The mathematical foundation uses a 4D rotation matrix:

Ry(θ)=(cosθ0sinθ00100sinθ0cosθ00001)R_y(\theta) = \begin{pmatrix} \cos\theta & 0 & -\sin\theta & 0 \\ 0 & 1 & 0 & 0 \\ \sin\theta & 0 & \cos\theta & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}

This matrix rotates points in the XZ-plane while preserving the Y-coordinate. The rotation follows the right-hand rule, where positive angles rotate counterclockwise when viewed from the positive Y-axis.

Available Functions

FunctionInput TypesDescription
rotateYVec3vec3, floatRotate 3D vector around Y-axis
rotateYVec3Centervec3, float, vec3Rotate 3D vector around Y-axis with custom center
rotateYVec4vec4, floatRotate 4D vector around Y-axis
rotateYVec4Centervec4, float, vec4Rotate 4D vector around Y-axis with custom center
ライブエディター
const fragment = () => {
      const angle = iTime
      const pos = vec3(uv.x, uv.y, 0).sub(0.5).mul(2.5)
      const rotated = rotateYVec3(pos, angle)
      const intensity = rotated.z.add(1).mul(0.5)
      const color = vec3(intensity, rotated.x.add(0.5), rotated.y.add(0.5))
      return vec4(color, 1)
}