ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

angle.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
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, USA.
00020  *
00021  */
00022 
00023 #ifndef MATH_ANGLE_H
00024 #define MATH_ANGLE_H
00025 
00026 #include "common/scummsys.h"
00027 
00028 namespace Common {
00029 class Debug;
00030 }
00031 
00032 namespace Math {
00033 
00034 class Angle {
00035 public:
00041     Angle(float degrees = 0);
00047     Angle(const Angle &a);
00048 
00054     Angle &normalize(float low);
00055     
00061     Angle &clampDegrees(float mag);
00062 
00069     Angle &clampDegrees(float min, float max);
00070 
00071     void setDegrees(float degrees);
00072     void setRadians(float radians);
00073 
00074     float getDegrees() const;
00075     float getRadians() const;
00076 
00082     float getDegrees(float low) const;
00088     float getRadians(float low) const;
00089 
00090     float getCosine() const;
00091     float getSine() const;
00092     float getTangent() const;
00093 
00094     Angle &operator=(const Angle &a);
00095     Angle &operator=(float degrees);
00096     Angle &operator+=(const Angle &a);
00097     Angle &operator+=(float degrees);
00098     Angle &operator-=(const Angle &a);
00099     Angle &operator-=(float degrees);
00100 
00106     static Angle fromRadians(float radians);
00107 
00108     static Angle arcCosine(float x);
00109     static Angle arcSine(float x);
00110     static Angle arcTangent(float x);
00111     static Angle arcTangent2(float y, float x);
00112 
00113 private:
00114     float _degrees;
00115 
00116 };
00117 
00118 inline Angle operator-(const Angle &a) {
00119     return Angle(-a.getDegrees());
00120 }
00121 
00122 inline Angle operator+(const Angle &a1, const Angle &a2) {
00123     return Angle(a1.getDegrees() + a2.getDegrees());
00124 }
00125 
00126 inline Angle operator-(const Angle &a1, const Angle &a2) {
00127     return Angle(a1.getDegrees() - a2.getDegrees());
00128 }
00129 
00130 inline Angle operator*(const Angle &a1, float f) {
00131     return Angle(a1.getDegrees() * f);
00132 }
00133 inline Angle operator*(float f, const Angle &a2) {
00134     return Angle(a2.getDegrees() * f);
00135 }
00136 
00137 inline Angle operator/(const Angle &a1, float f) {
00138     return Angle(a1.getDegrees() / f);
00139 }
00140 inline Angle operator/(float f, const Angle &a2) {
00141     return Angle(a2.getDegrees() / f);
00142 }
00143 
00144 
00145 inline bool operator==(const Angle &a1, const Angle &a2) {
00146     return fabsf(a1.getDegrees() - a2.getDegrees()) < 0.001;
00147 }
00148 
00149 inline bool operator!=(const Angle &a1, const Angle &a2) {
00150     return !(a1 == a2);
00151 }
00152 
00153 
00154 
00155 inline bool operator<(const Angle &a1, const Angle &a2) {
00156     return a1.getDegrees() < a2.getDegrees();
00157 }
00158 
00159 inline bool operator>(const Angle &a1, const Angle &a2) {
00160     return a1.getDegrees() > a2.getDegrees();
00161 }
00162 
00163 Common::Debug &operator<<(Common::Debug &dbg, const Math::Angle &a);
00164 
00165 }
00166 
00167 #endif


Generated on Sat Jul 13 2019 05:01:20 for ResidualVM by doxygen 1.7.1
curved edge   curved edge