Skip to content
fn

rotate_op

→TensorImplPtr
int rotate_op(const int & input, double angle_deg, double cy, double cx)

Rotate a 4-D image batch around an arbitrary centre.

Applies the standard 2-D rotation matrix

(x′y′)=(cos⁡θ−sin⁡θsin⁡θcos⁡θ)(x−cxy−cy)+(cxcy) \begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix} \begin{pmatrix} x - c_x \\ y - c_y \end{pmatrix} + \begin{pmatrix} c_x \\ c_y \end{pmatrix}

with θ=angle_deg⋅π/180\theta = \text{angle\_deg} \cdot \pi / 180 to each channel of the input independently. Sampling uses bilinear interpolation with zero padding for out-of-bounds destinations. No autograd node is attached — the operation is inference-only.

Parameters

inputTensorImplPtr
4-D image batch of shape (N, C, H, W).
angle_degdouble
Rotation angle in degrees (counter-clockwise).
cydouble
Rotation centre row coordinate (typically (H - 1) / 2).
cxdouble
Rotation centre column coordinate (typically (W - 1) / 2).

Returns

TensorImplPtr

Rotated image batch of shape (N, C, H, W).