14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13 Three-Dimensional Scenes 453<br />

Using the Matrix Stack<br />

Similar is the Mult Matrix command<br />

Mult Matrix(m)<br />

When the Mult Matrix command is issued, the matrix on the top of the current matrix stack is multiplied<br />

by m.<br />

The following matrices perform some simple commands.<br />

Translation:<br />

[1 0 0 x<br />

0 1 0 y<br />

0 0 1 z<br />

0 0 0 1]<br />

In the following rotation matrices, c = cos(angle) and s=sin(angle).<br />

Rotation about x-axis:<br />

[1 0 0 0<br />

0 c -s 0<br />

0 -s c 0<br />

0 0 0 1]<br />

Rotation about y-axis:<br />

[c 0 s 0<br />

0 1 0 0<br />

-s 0 c 0<br />

0 0 0 1]<br />

Rotation about z-axis:<br />

[c -s 0 0<br />

s c 0 0<br />

0 0 1 0<br />

0 0 0 1]<br />

For example, here are two equivalent (except for the translation being opposite) ways to translate and rotate<br />

a display list.<br />

// first way uses matrix<br />

gl

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!