Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-04-05 10:52:39 +0000
committerStijn Buys <ingar@osirion.org>2008-04-05 10:52:39 +0000
commit25d2c764443723eb7a3dd5f8bf0b76586c1ff10b (patch)
treeb9cc681a3ff20900b32ce287505d018e0a7ae35f /src/math
parent49e268d1b4244948e49a11612501a743e311fbaf (diff)
Makefile.am updates, math::Axis, improved VertexArray, r_arraysize
Diffstat (limited to 'src/math')
-rw-r--r--src/math/Makefile.am4
-rw-r--r--src/math/axis.cc54
-rw-r--r--src/math/axis.h52
-rw-r--r--src/math/color.h2
4 files changed, 109 insertions, 3 deletions
diff --git a/src/math/Makefile.am b/src/math/Makefile.am
index a622ba7..465f9b0 100644
--- a/src/math/Makefile.am
+++ b/src/math/Makefile.am
@@ -1,9 +1,9 @@
METASOURCES = AUTO
-libmath_la_SOURCES = color.cc functions.cc plane3f.cc vector3f.cc
+libmath_la_SOURCES = axis.cc color.cc functions.cc plane3f.cc vector3f.cc
libmath_la_LDFLAGS = -avoid-version -no-undefined -lm
noinst_LTLIBRARIES = libmath.la
-noinst_HEADERS = color.h functions.h mathlib.h plane3f.h vector3f.h
+noinst_HEADERS = axis.h color.h functions.h mathlib.h plane3f.h vector3f.h
INCLUDES = -I$(top_srcdir)/src
diff --git a/src/math/axis.cc b/src/math/axis.cc
new file mode 100644
index 0000000..7bd5262
--- /dev/null
+++ b/src/math/axis.cc
@@ -0,0 +1,54 @@
+/*
+ math/axis.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+// project headers
+#include "math/axis.h"
+
+namespace math
+{
+
+Axis::Axis()
+{
+ clear();
+}
+
+Axis::Axis(const Axis & other) {
+ assign(other);
+}
+
+void Axis::clear()
+{
+ axis_vector[0] = Vector3f(1.0f, 0.0f, 0.0f);
+ axis_vector[1] = Vector3f(0.0f, 1.0f, 0.0f);
+ axis_vector[2] = Vector3f(0.0f, 0.0f, 1.0f);
+}
+
+void Axis::assign(const Axis & other) {
+ for (size_t i=0; i < 3; i++) {
+ axis_vector[i].assign(other.axis_vector[i]);
+ }
+}
+
+Axis & Axis::operator=(const Axis & other) {
+ assign(other);
+ return *this;
+}
+
+// alter heading, rotate around Z-axis (positive is left)
+void Axis::direction(const float angle) {
+ for (size_t i=0; i < 3; i++) {
+ //axis_vector[i].rotate(axis_vector[2], angle);
+ }
+}
+
+// alter heading, rotate around negative Y-axis (positive is up)
+void Axis::pitch(const float pitch) {
+ for (size_t i=0; i < 3; i++) {
+ //axis_vector[i].rotate(axis_vector[1], -angle);
+ }
+}
+
+}
diff --git a/src/math/axis.h b/src/math/axis.h
new file mode 100644
index 0000000..73474ef
--- /dev/null
+++ b/src/math/axis.h
@@ -0,0 +1,52 @@
+/*
+ math/axis.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_MATH_AXIS_H__
+#define __INCLUDED_MATH_AXIS_H__
+
+#include <iostream>
+
+#include "math/vector3f.h"
+
+namespace math
+{
+
+/// a local coordinates system
+class Axis {
+public:
+ Axis();
+ Axis(const Axis & other);
+
+ void clear();
+
+ void assign(const Axis & other);
+
+ /// global coordinates of the X-axis in the local coordinates system
+ inline Vector3f const & forward() { return axis_vector[0]; }
+
+ /// global coordinates of the Y-axis in the local coordinates system
+ inline Vector3f const & left() { return axis_vector[1]; }
+
+ /// global coordinates of the Z-axis in the local coordinates system
+ inline Vector3f const & up() { return axis_vector[2]; }
+
+ inline Vector3f const operator[](size_t index) { return axis_vector[index]; }
+
+ Axis & operator=(const Axis & other);
+
+ /// alter heading, rotate around Z-axis (positive is left)
+ void direction(const float angle);
+
+ /// alter heading, rotate around negative Y-axis (positive is up)
+ void pitch(const float angle);
+
+private:
+ Vector3f axis_vector[3];
+};
+
+}
+
+#endif // __INCLUDED_MATH_AXIS_H__
diff --git a/src/math/color.h b/src/math/color.h
index 5684770..7fa0d68 100644
--- a/src/math/color.h
+++ b/src/math/color.h
@@ -1,5 +1,5 @@
/*
- common/color.h
+ math/color.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/