0% found this document useful (0 votes)
75 views2 pages

Exercise 2: M DX Dy M M M

The document discusses matrix multiplication routines for 4x4 matrices used in computer graphics and visualization. It provides examples of common matrix operations like translation, scaling, and rotation around the x, y, and z axes. It recommends implementing functions for these basic operations that take parameters like the translation amounts or rotation angles. The document also discusses options for libraries that can perform these operations but notes it is not difficult to code the multiplications directly using a data type like a 4x4 float array to represent the matrices.

Uploaded by

fiskmoos
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views2 pages

Exercise 2: M DX Dy M M M

The document discusses matrix multiplication routines for 4x4 matrices used in computer graphics and visualization. It provides examples of common matrix operations like translation, scaling, and rotation around the x, y, and z axes. It recommends implementing functions for these basic operations that take parameters like the translation amounts or rotation angles. The document also discusses options for libraries that can perform these operations but notes it is not difficult to code the multiplications directly using a data type like a 4x4 float array to represent the matrices.

Uploaded by

fiskmoos
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ume University Department of Computing Science Computer Graphics and Visualization Pedher Johansson pedher@cs.umu.

se

Exercise 2 2 !"# !#!"

Sid ! $2%

Exercise 2

Matrix multiplication routines

Introduction
In following assignments, we will need a way to do simple matrix multiplications in our software. The matrices are 44 and usually structured which we can use to reduce the number of operations. Some of the operations we need is shown below. In the lecture about transformations we will cover and deduce these matrices, but you can prepare and start to see how these operations can be done in C or C++. Below each operation you can see a proposed function header with a given set of parameters. This may of course be altered and complemented. Translation dx 1 dy M MV M MV 1 dz 1 translate(dx,dy,dz) Scaling M MV Rotation around z-axis cos ( z ) sin ( z ) M MV sin ( z ) cos ( z) rotatez(a) Rotation around y-axis

[ [

[ [ [

1 1

M MV

sx sy sz 1

cos ( y ) 1 sin ( y )

sin ( y ) cos ( y ) 1

M MV

M MV

scale(sx,sy,sz)

] ]

M MV

rotatey(a) Rotation around x-axis 1 cos ( x ) sin ( x ) sin ( x ) cos ( x ) 1 M MV M MV

rotatex(a) A simple search on the web will give several hits for libraries that handles this, both general libraries and specialized for computer graphics. Boost uBlas is a general numeric library and is installed on CS

Sid 2 $2%

(http://www.boost.org/doc/libs/1_42_0/libs/numeric/ublas/doc/index.htm). Another library is Generic Graphics Toolkit, GGT (http://ggt.sourceforge.net/). However, small routines to do the multiplications yourself is not difficult (but do some basic testing and sanity checks). First thing is to define your data type, either in C or C++ or to use those provided by a library. In workshop 1 and its given code, the following definitions is used for 2D-data and a 4x4 matrix. typedef struct { float x; float y; } vec2; typedef float mat4[16];

Matrix routines
It doesn't matter if you like to use C or C++, build your own or use existing libraries, but find a way to do basic matrix operations as described and find a representation that seems efficient. Consider the following It should be fast to copy a matrix and vector to a vector buffer. Use float (not double). Other routines that may come in handy (but certainly not necessarily) are matrix-vector multiplication, cross-product. Matrices are always 44. Vectors if multiplied with a matrix is always 41. A vertex (a coordinate) are typically 3D, or 4D (with the 4th element set to 1) and implemented as a struct (or object), and it should be possible to copy them directly into an array buffer (for speed).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy