# CSS - rotate3d()

The `rotate3d()` CSS function defines a transformation that moves the element around a fixed axis without deforming it. The amount of movement is defined by the specified angle; if positive, the movement will be clockwise, if negative, it will be counter-clockwise.

## Examples

### Rotating on the X-axis

#### HTML

HTML
```<p>foo</p>
<p class="transformed">bar</p>```

#### CSS

CSS
```p {
width: 50px;
height: 50px;
background-color: teal;
}

.transformed{
transform: rotate3d(1,0,0,60deg);
background-color: blue;
}```

### Rotating on a custom axis

#### HTML

HTML
```<p>foo</p>
<p class="transformed">bar</p>```

#### CSS

CSS
```p {
width: 50px;
height: 50px;
background-color: teal;
}

.transformed{
transform: rotate3d(1, 2, -1, 192deg);
background-color: blue;
}```

## Syntax

CSS
`rotate3d(x, y, z, a)`

## Description

The `rotate3d()` CSS function defines a transformation that moves the element around a fixed axis without deforming it. The amount of movement is defined by the specified angle; if positive, the movement will be clockwise, if negative, it will be counter-clockwise.

In the 3D space, rotations have three degrees of liberty, describing an axis of rotation. The axis of rotation is defined by an [x, y, z] vector and pass by the origin (as defined by the `transform-origin` CSS property. If the vector is not normalized, that is the sum of the square of its three coordinates is not 1, it will be normalized internally. A non-normalizable vector, like the null vector, [0, 0, 0], will cause the rotation not to be applied, without invaliding the whole CSS property.

In opposition to rotations in the plane, the composition of 3D rotations is usually not commutative; it means that the order in which the rotations are applied is crucial.
x
Is a `<number>` describing the x-coordinate of the vector denoting the axis of rotation.
y
Is a `<number>` describing the y-coordinate of the vector denoting the axis of rotation.
z
Is a `<number>` describing the z-coordinate of the vector denoting the axis of rotation.
a
Is an `<angle>` representing the angle of the rotation. A positive angle denotes a clockwise rotation, a negative angle a counter-clockwise one.
Cartesian coordinates on ℝ2 Homogeneous coordinates on ℝℙ2 Cartesian coordinates on ℝ3 Homogeneous coordinates on ℝℙ3
This transform applies to the 3D space and cannot be represented on the plane. $\left(\begin{array}{ccc}1+\left(1-cos\left(a\right)\right)\left({x}^{2}-1\right)& z·sin\left(a\right)+xy\left(1-cos\left(a\right)\right)& -y·sin\left(a\right)+xz·\left(1-cos\left(a\right)\right)\\ -z·sin\left(a\right)+xy·\left(1-cos\left(a\right)\right)& 1+\left(1-cos\left(a\right)\right)\left(y2-1\right)& x·sin\left(a\right)+yz·\left(1-cos\left(a\right)\right)& ysin\left(a\right) + xz\left(1-cos\left(a\right)\right)& -xsin\left(a\right)+yz\left(1-cos\left(a\right)\right)& 1+\left(1-cos\left(a\right)\right)\left(z2-1\right)& t\\ 0& 0& 0& 1\end{array}\right)$