/usr/include/ignition/math2/ignition/math/Angle.hh is in libignition-math2-dev 2.9.0+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | /*
* Copyright (C) 2012-2014 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_MATH_ANGLE_HH_
#define IGNITION_MATH_ANGLE_HH_
#include <iostream>
#include <ignition/math/Helpers.hh>
/// \brief Macro that converts radians to degrees
/// \param[in] radians
/// \return degrees
#define IGN_RTOD(r) ((r) * 180 / IGN_PI)
/// \brief Converts degrees to radians
/// \param[in] degrees
/// \return radians
#define IGN_DTOR(d) ((d) * IGN_PI / 180)
/// \brief Macro that normalizes an angle in the range -Pi to Pi
/// \param[in] angle
/// \return the angle, in range
#define IGN_NORMALIZE(a) (atan2(sin(a), cos(a)))
namespace ignition
{
namespace math
{
/// \class Angle Angle.hh ignition/math/Angle.hh
/// \brief An angle and related functions.
class IGNITION_VISIBLE Angle
{
/// \brief math::Angle(0)
public: static const Angle Zero;
/// \brief math::Angle(IGN_PI)
public: static const Angle Pi;
/// \brief math::Angle(IGN_PI * 0.5)
public: static const Angle HalfPi;
/// \brief math::Angle(IGN_PI * 2)
public: static const Angle TwoPi;
/// \brief Constructor
public: Angle();
/// \brief Copy Constructor
/// \param[in] _radian Radians
// cppcheck-suppress noExplicitConstructor
public: Angle(double _radian);
/// \brief Copy constructor
/// \param[in] _angle Angle to copy
public: Angle(const Angle &_angle);
/// \brief Destructor
public: virtual ~Angle();
/// \brief Set the value from an angle in radians
/// \param[in] _radian Radian value
public: void Radian(double _radian);
/// \brief Set the value from an angle in degrees
/// \param[in] _degree Degree value
public: void Degree(double _degree);
/// \brief Get the angle in radians
/// \return double containing the angle's radian value
public: double Radian() const;
/// \brief Get the angle in degrees
/// \return double containing the angle's degree value
public: double Degree() const;
/// \brief Normalize the angle in the range -Pi to Pi
public: void Normalize();
/// \brief Return the angle's radian value
/// \return double containing the angle's radian value
public: double operator()() const;
/// \brief Dereference operator
/// \return Double containing the angle's radian value
public: inline double operator*() const
{
return value;
}
/// \brief Substraction, result = this - _angle
/// \param[in] _angle Angle for substraction
/// \return the new angle
public: Angle operator-(const Angle &_angle) const;
/// \brief Addition operator, result = this + _angle
/// \param[in] _angle Angle for addition
/// \return the new angle
public: Angle operator+(const Angle &_angle) const;
/// \brief Multiplication operator, result = this * _angle
/// \param[in] _angle Angle for multiplication
/// \return the new angle
public: Angle operator*(const Angle &_angle) const;
/// \brief Division, result = this / _angle
/// \param[in] _angle Angle for division
/// \return the new angle
public: Angle operator/(const Angle &_angle) const;
/// \brief Subtraction set, this = this - _angle
/// \param[in] _angle Angle for subtraction
/// \return angle
public: Angle operator-=(const Angle &_angle);
/// \brief Addition set, this = this + _angle
/// \param[in] _angle Angle for addition
/// \return angle
public: Angle operator+=(const Angle &_angle);
/// \brief Multiplication set, this = this * _angle
/// \param[in] _angle Angle for multiplication
/// \return angle
public: Angle operator*=(const Angle &_angle);
/// \brief Division set, this = this / _angle
/// \param[in] _angle Angle for division
/// \return angle
public: Angle operator/=(const Angle &_angle);
/// \brief Equality operator, result = this == _angle
/// \param[in] _angle Angle to check for equality
/// \return true if this == _angle
public: bool operator==(const Angle &_angle) const;
/// \brief Inequality
/// \param[in] _angle Angle to check for inequality
/// \return true if this != _angle
public: bool operator!=(const Angle &_angle) const;
/// \brief Less than operator
/// \param[in] _angle Angle to check
/// \return true if this < _angle
public: bool operator<(const Angle &_angle) const;
/// \brief Less or equal operator
/// \param[in] _angle Angle to check
/// \return true if this <= _angle
public: bool operator<=(const Angle &_angle) const;
/// \brief Greater than operator
/// \param[in] _angle Angle to check
/// \return true if this > _angle
public: bool operator>(const Angle &_angle) const;
/// \brief Greater or equal operator
/// \param[in] _angle Angle to check
/// \return true if this >= _angle
public: bool operator>=(const Angle &_angle) const;
/// \brief Stream insertion operator. Outputs in degrees
/// \param[in] _out output stream
/// \param[in] _a angle to output
/// \return The output stream
public: friend std::ostream &operator<<(std::ostream &_out,
const ignition::math::Angle &_a)
{
_out << _a.Radian();
return _out;
}
/// \brief Stream extraction operator. Assumes input is in radians
/// \param in input stream
/// \param pt angle to read value into
/// \return The input stream
public: friend std::istream &operator>>(std::istream &_in,
ignition::math::Angle &_a)
{
// Skip white spaces
_in.setf(std::ios_base::skipws);
_in >> _a.value;
return _in;
}
/// The angle in radians
private: double value;
};
}
}
#endif
|