---
name: "Rotate"
section: "3"
platform: "linux"
package: "libvolpack1-dev"
version: "1.0b3-10"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Rotate"
---

# Rotate(3)

multiply the current transformation matrix by a rotation matrix

## NAME

vpRotate - multiply the current transformation matrix by a rotation matrix

## SYNOPSIS

\#include \<volpack.h\>

vpResult

**vpRotate(***vpc, axis, degrees***)**

-

  vpContext *\*vpc;*

-

  int *axis;*

-

  double *degrees;*

## ARGUMENTS

- *vpc*

  VolPack context from **vpCreateContext.**

- *axis*

  Rotation axis code (VP\_X\_AXIS, VP\_Y\_AXIS or VP\_Z\_AXIS).

- *degrees*

  Number of degrees to rotate.

## DESCRIPTION

**vpRotate** is used to multiply the current transformation matrix by a 4-by-4 rotation matrix.  The rotation axis must be one of the three principal viewing axes and is specified with one of the following codes: VP\_X\_AXIS	X axis\
 VP\_Y\_AXIS	Y axis\
 VP\_Z\_AXIS	Z axis

The rotation angle is specified in degrees.  A positive angle indicates a clockwise rotation when looking towards the positive direction along the axis.  For an X-axis rotation, the rotation matrix is:

-

  	1	0	0	0\
  \
   	0	cos(d)	sin(d)	0\
  \
   	0	-sin(d)	cos(d)	0\
  \
   	0	0	0	1

where d stands for the *degrees* argument.  For a Y-axis rotation, the rotation matrix is:

-

  	cos(d)	0	-sin(d)	0\
  \
   	0	1	0	0\
  \
   	sin(d)	0	cos(d)	0\
  \
   	0	0	0	1

For a Z-axis rotation, the rotation matrix is:

-

  	cos(d)	sin(d)	0	0\
  \
   	\-sin(d)	cos(d)	0	0\
  \
   	0	0	1	0\
  \
   	0	0	0	1

Use **vpCurrentMatrix** to set the current transformation matrix.  By default, the rotation matrix is post-multiplied (M = M\*R where M is the current matrix and R is the rotation matrix).  The VP\_CONCAT\_MODE option to **vpSeti** can be used to select pre-multiplication.

## STATE VARIABLES

The current matrix concatenation parameters can be retrieved with the following state variable codes (see vpGeti(3)): VP\_CURRENT\_MATRIX, VP\_CONCAT\_MODE.

## ERRORS

The normal return value is VP\_OK.  The following error return value is possible:

- VPERROR\_BAD\_OPTION

  The *axis* argument is invalid.

## SEE ALSO

[VolPack(3)](/VolPack/3.md), vpCreateContext(3), vpCurrentMatrix(3)
