rotation.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // This file is part of libgvectors.
00004 // libgvectors is a C++ library intended for visualizing mathematical vectors.
00005 // Copyright (C) 2007  Rafael Ostertag
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
00020 // USA.
00021 //
00022 // $Id: rotation_8h-source.html,v 1.1 2007-09-08 19:02:36 rafi Exp $
00023 //
00024 // File:   rotation.h
00025 // Author: Rafael Ostertag
00026 //
00027 // Created on July 1, 2007, 3:28 PM
00028 //
00029 
00039 #ifndef _ROTATION_H
00040 #define _ROTATION_H
00041 
00042 #include <gvenums.h>
00043 
00044 namespace GVectors {
00045     
00046     // A forward declaration to a \a Matrix4x4 class.
00047     class Matrix4x4;
00048     
00056     class Rotation {
00057     private:
00064         double rot_x;
00071         double rot_y;
00078         double rot_z;
00097         bool wrap_at_2pi;
00116         bool always_positive;
00117         
00119         void wrap(double& v);
00121         void make_positive(double& v);
00122         
00124         void wrap_all();
00126         void make_all_positive();
00127         
00128     public:
00130         Rotation();
00132         Rotation(double x0, double y0, double z0, Angle_Type at=ANG_RAD);
00134         ~Rotation();
00136         Rotation(const Rotation &r);
00137         
00139         void setX(double x, Angle_Type at=ANG_RAD);
00141         void X(double x, Angle_Type at=ANG_RAD);
00143         void setY(double y, Angle_Type at=ANG_RAD);
00145         void Y(double y, Angle_Type at=ANG_RAD);
00147         void setZ(double z, Angle_Type at=ANG_RAD);
00149         void Z(double z, Angle_Type at=ANG_RAD);
00151         void set(double x, double y, double z, Angle_Type at=ANG_RAD);
00152         
00154         double getX(Angle_Type at=ANG_RAD) const;
00156         double X(Angle_Type at=ANG_RAD) const;
00158         double getY(Angle_Type at=ANG_RAD) const;
00160         double Y(Angle_Type at=ANG_RAD) const;
00162         double getZ(Angle_Type at=ANG_RAD) const;
00164         double Z(Angle_Type at=ANG_RAD) const;
00166         void get(double &x_, double &y_, double &z_, Angle_Type at=ANG_RAD) const;
00167         
00169         void get_matrix(Matrix4x4& mx, Matrix4x4& my, Matrix4x4& mz) const;
00171         void get_inverse_matrix(Matrix4x4& mx, Matrix4x4& my, Matrix4x4& mz) const;
00172         
00174         void incX_by(double i, Angle_Type at=ANG_RAD);
00176         void incY_by(double i, Angle_Type at=ANG_RAD);
00178         void incZ_by(double i, Angle_Type at=ANG_RAD);
00179         
00181         void decX_by(double i, Angle_Type at=ANG_RAD);
00183         void decY_by(double i, Angle_Type at=ANG_RAD);
00185         void decZ_by(double i, Angle_Type at=ANG_RAD);
00186         
00188         void set_wrap_at_2pi(bool w=true);
00201         inline bool get_wrap_at_2PI() const { return wrap_at_2pi; }
00202         
00204         void set_always_positive(bool a=true);
00217         inline bool get_always_positive() const { return always_positive; }
00218         
00220         const Rotation& operator=(const Rotation& r);
00222         Rotation operator+(const Rotation& r) const;
00224         Rotation operator-(const Rotation& r) const;
00226         const Rotation& operator+=(const Rotation& r);
00228         const Rotation& operator-=(const Rotation& r);
00229     };
00230 }
00231 
00232 #endif  /* _ROTATION_H */

Generated on Sat Sep 8 19:37:29 2007 for libgvectors by  doxygen 1.4.7