File: Maths.cpp

package info (click to toggle)
0ad 0.0.23.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 78,292 kB
  • sloc: cpp: 245,166; ansic: 200,249; python: 13,754; sh: 6,104; perl: 4,620; makefile: 977; xml: 810; java: 533; ruby: 229; erlang: 46; pascal: 30; sql: 21; tcl: 4
file content (88 lines) | stat: -rw-r--r-- 2,114 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Copyright (C) 2009 Wildfire Games.
 * This file is part of 0 A.D.
 *
 * 0 A.D. is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * 0 A.D. is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "precompiled.h"

#include "Maths.h"

#include "FCollada.h"


void DumpMatrix(const FMMatrix44& m)
{
	Log(LOG_INFO, "\n[%f %f %f %f]\n[%f %f %f %f]\n[%f %f %f %f]\n[%f %f %f %f]",
		m.m[0][0], m.m[0][1], m.m[0][2], m.m[0][3],
		m.m[1][0], m.m[1][1], m.m[1][2], m.m[1][3],
		m.m[2][0], m.m[2][1], m.m[2][2], m.m[2][3],
		m.m[3][0], m.m[3][1], m.m[3][2], m.m[3][3]
	);
}

FMMatrix44 DecomposeToScaleMatrix(const FMMatrix44& m)
{
	FMVector3 scale, rotation, translation;
	float inverted;
	m.Decompose(scale, rotation, translation, inverted);
	return FMMatrix44::ScaleMatrix(scale);
}

/*
FMMatrix44 operator+ (const FMMatrix44& a, const FMMatrix44& b)
{
	FMMatrix44 r;
	for (int x = 0; x < 4; ++x)
		for (int y = 0; y < 4; ++y)
			r[x][y] = a[x][y] + b[x][y];
	return r;
}

FMMatrix44 operator/ (const FMMatrix44& a, const float b)
{
	FMMatrix44 r;
	for (int x = 0; x < 4; ++x)
		for (int y = 0; y < 4; ++y)
			r[x][y] = a[x][y] / b;
	return r;
}

FMMatrix44 QuatToMatrix(float x, float y, float z, float w)
{
	FMMatrix44 r;

	r[0][0] = 1.0f - (y*y*2 + z*z*2);
	r[1][0] = x*y*2 - w*z*2;
	r[2][0] = x*z*2 + w*y*2;
	r[3][0] = 0;

	r[0][1] = x*y*2 + w*z*2;
	r[1][1] = 1.0f - (x*x*2 + z*z*2);
	r[2][1] = y*z*2 - w*x*2;
	r[3][1] = 0;

	r[0][2] = x*z*2 - w*y*2;
	r[1][2] = y*z*2 + w*x*2;
	r[2][2] = 1.0f - (x*x*2 + y*y*2);
	r[3][2] = 0;

	r[0][3] = 0;
	r[1][3] = 0;
	r[2][3] = 0;
	r[3][3] = 1;

	return r;
}
*/