Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
667 khor 1
/* ----------------------------------------------------------------------- *
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 * Copyright (C) the authors and DTU Informatics
4
 * For license and list of authors, see ../../doc/intro.pdf
5
 * ----------------------------------------------------------------------- */
6
 
7
#include "Mat3x3f.h"
8
 
9
namespace CGLA {
10
	Mat3x3f rotation_Mat3x3f(Axis axis, float angle)
11
	{
12
		Mat3x3f m(0.0f);
13
 
14
		switch(axis)
15
			{
16
			case XAXIS:
17
				m[0][0] = 1.0f;
18
				m[1][1] = cos(angle);
19
				m[1][2] = sin(angle);
20
				m[2][1] = -sin(angle);
21
				m[2][2] = cos(angle);
22
				break;
23
			case YAXIS:
24
				m[0][0] = cos(angle);
25
				m[0][2] = -sin(angle);
26
				m[2][0] = sin(angle);
27
				m[2][2] = cos(angle);
28
				m[1][1] = 1.0f;
29
				break;
30
			case ZAXIS:
31
				m[0][0] = cos(angle);
32
				m[0][1] = sin(angle);
33
				m[1][0] = -sin(angle);
34
				m[1][1] = cos(angle);
35
				m[2][2] = 1.0f;
36
				break;
37
			}
38
 
39
		return m;
40
	}
41
 
42
	Mat3x3f scaling_Mat3x3f(const Vec3f& v)
43
	{
44
		Mat3x3f m(0.0f);
45
		m[0][0] = v[0];
46
		m[1][1] = v[1];
47
		m[2][2] = v[2];
48
		return m;
49
	}
50
 
51
 
52
}