<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" "DTD/docbook/docbookx.dtd">
<!--
License Applicability. Except to the extent portions of this file are
made subject to an alternative license as permitted in the SGI Free
Software License B, Version 1.1 (the "License"), the contents of this
file are subject only to the provisions of the License. You may not use
this file except in compliance with the License. You may obtain a copy
of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
http://oss.sgi.com/projects/FreeB
Note that, as provided in the License, the Software is distributed on an
"AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
Original Code. The Original Code is: OpenGL ES Reference Manual,
Version 1.0, released September 2003, developed by Silicon Graphics,
Inc. The Original Code is Copyright (c) 2003 Silicon Graphics, Inc.
Copyright in any portions created by third parties is as indicated
elsewhere herein. All Rights Reserved.
-->
<refentry id="glRotate">
<refmeta>
<refentrytitle>glRotate</refentrytitle>
<manvolnum>3G</manvolnum>
</refmeta>
<refnamediv>
<refdescriptor>glRotate</refdescriptor>
<refname>glRotatef</refname>
<refname>glRotatex</refname>
<refpurpose>multiply the current matrix by a rotation matrix</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>C Specification</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>glRotatef</function></funcdef>
<paramdef>GLfloat <parameter>angle</parameter></paramdef>
<paramdef>GLfloat <parameter>x</parameter></paramdef>
<paramdef>GLfloat <parameter>y</parameter></paramdef>
<paramdef>GLfloat <parameter>z</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>glRotatex</function></funcdef>
<paramdef>GLfixed <parameter>angle</parameter></paramdef>
<paramdef>GLfixed <parameter>x</parameter></paramdef>
<paramdef>GLfixed <parameter>y</parameter></paramdef>
<paramdef>GLfixed <parameter>z</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term>
<parameter>angle</parameter>
</term>
<listitem>
<para>Specifies the angle of rotation, in degrees.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>x</parameter>,
<parameter>y</parameter>,
<parameter>z</parameter>
</term>
<listitem>
<para>Specify the
<parameter>x</parameter>,
<parameter>y</parameter>, and
<parameter>z</parameter>
coordinates of a vector, respectively.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para><function>glRotate</function> produces a rotation of
<parameter>angle</parameter> degrees around the vector
<inlineequation><math>
<mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced>
</math></inlineequation>.
The current matrix (see
<citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>)
is multiplied by a rotation matrix with the product replacing
the current matrix, as if
<citerefentry><refentrytitle>glMultMatrix</refentrytitle></citerefentry>
were called with the following matrix as its argument:</para>
<informalequation><math>
<mrow>
<mo>(</mo>
<mtable class="matrix">
<mtr>
<mtd>
<msup><mi>x</mi><mn>2</mn></msup>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>+</mo><mi>c</mi>
</mtd>
<mtd>
<mi>x</mi><mn>y</mn>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>-</mo><mi>z</mi><mi>s</mi>
</mtd>
<mtd>
<mi>x</mi><mn>z</mn>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>+</mo><mi>y</mi><mi>s</mi>
</mtd>
<mtd><mn>0</mn></mtd>
</mtr>
<mtr>
<mtd>
<mi>x</mi><mn>y</mn>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>+</mo><mi>z</mi><mi>s</mi>
</mtd>
<mtd>
<msup><mi>y</mi><mn>2</mn></msup>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>+</mo><mi>c</mi>
</mtd>
<mtd>
<mi>y</mi><mn>z</mn>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>-</mo><mi>x</mi><mi>s</mi>
</mtd>
<mtd><mn>0</mn></mtd>
</mtr>
<mtr>
<mtd>
<mi>x</mi><mn>z</mn>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>-</mo><mi>y</mi><mi>s</mi>
</mtd>
<mtd>
<mi>y</mi><mn>z</mn>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>+</mo><mi>x</mi><mi>s</mi>
</mtd>
<mtd>
<msup><mi>z</mi><mn>2</mn></msup>
<mo>(</mo><mn>1</mn><mo>-</mo><mi>c</mi><mo>)</mo>
<mo>+</mo><mi>c</mi>
</mtd>
<mtd><mn>0</mn></mtd>
</mtr>
<mtr>
<mtd><mn>0</mn></mtd>
<mtd><mn>0</mn></mtd>
<mtd><mn>0</mn></mtd>
<mtd><mn>1</mn></mtd>
</mtr>
</mtable>
<mo>)</mo>
</mrow>
</math></informalequation>
<para>Where
<inlineequation><math>
<mi>c</mi><mo>=</mo><mo>cos</mo><mfenced><mi>angle</mi></mfenced>
</math></inlineequation>,
<inlineequation><math>
<mi>s</mi><mo>=</mo><mo>sin</mo><mfenced><mi>angle</mi></mfenced>
</math></inlineequation>,
and
<inlineequation><math>
<mo>||</mo><mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced><mo>||</mo>
<mo>=</mo><mn>1</mn>
</math></inlineequation>,
(if not, the GL will normalize this vector).</para>
<para>If the matrix mode is either <constant>GL_MODELVIEW</constant> or
<constant>GL_PROJECTION</constant>, all objects drawn after
<function>glRotate</function> is called are rotated. Use
<citerefentry><refentrytitle>glPushMatrix</refentrytitle></citerefentry>
and
<citerefentry><refentrytitle>glPopMatrix</refentrytitle></citerefentry>
to save and restore the unrotated coordinate system.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>This rotation follows the right-hand rule, so if the vector
<inlineequation><math>
<mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced>
</math></inlineequation>
points toward the user, the rotation will be counterclockwise.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glMultMatrix</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glPushMatrix</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glScale</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glTranslate</refentrytitle></citerefentry>
</para>
</refsect1>
</refentry>