rotateZ: Z-Axis Vector Rotation Transform
Matrix-based rotation around the Z-axis
The rotateZ functions provide Z-axis rotation transformations for 3D and 4D vectors using matrix operations. These functions generate rotation matrices that rotate vectors around the Z-axis by a specified angle.
The mathematical foundation uses a 4D rotation matrix:
This matrix rotates points in the XY-plane while preserving the Z-coordinate. The rotation follows the right-hand rule, where positive angles rotate counterclockwise when viewed from the positive Z-axis.
Available Functions
Function | Input Types | Description |
---|---|---|
rotateZVec3 | vec3, float | Rotate 3D vector around Z-axis |
rotateZVec3Center | vec3, float, vec3 | Rotate 3D vector around Z-axis with custom center |
rotateZVec4 | vec4, float | Rotate 4D vector around Z-axis |
rotateZVec4Center | vec4, float, vec4 | Rotate 4D vector around Z-axis with custom center |
ライブエディター
const fragment = () => { const angle = iTime.mul(1.5) const pos = vec3(uv.sub(0.5).mul(2), 0) const rotated = rotateZVec3(pos, angle) const color = rotated.xy.add(0.5).abs() return vec4(color, rotated.x.mul(0.5).add(0.5), 1) }