SFML - Simple and Fast Multimedia Library

SFML 3.0.0

- Main Page
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Angle.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
27
28namespace sf
29{
34 class Angle
35{
36public:
43 constexpr Angle() = default;
44
53 [[nodiscard]] constexpr float asDegrees() const;
54
63 [[nodiscard]] constexpr float asRadians() const;
64
96 [[nodiscard]] constexpr Angle wrapSigned() const;
97
129 [[nodiscard]] constexpr Angle wrapUnsigned() const;
130
132 // Static member data
134 // NOLINTNEXTLINE(readability-identifier-naming)
135 static const Angle Zero;
136
137private:
138 friend constexpr Angle degrees(float angle);
139 friend constexpr Angle radians(float angle);
140
150 constexpr explicit Angle(float radians);
151
153 // Member data
155 float m_radians{};
156};
157
168[[nodiscard]] constexpr Angle degrees(float angle);
169
180[[nodiscard]] constexpr Angle radians(float angle);
181
193[[nodiscard]] constexpr bool operator==(Angle left, Angle right);
194
206[[nodiscard]] constexpr bool operator!=(Angle left, Angle right);
207
219[[nodiscard]] constexpr bool operator<(Angle left, Angle right);
220
232[[nodiscard]] constexpr bool operator>(Angle left, Angle right);
233
245[[nodiscard]] constexpr bool operator<=(Angle left, Angle right);
246
258[[nodiscard]] constexpr bool operator>=(Angle left, Angle right);
259
271[[nodiscard]] constexpr Angle operator-(Angle right);
272
283[[nodiscard]] constexpr Angle operator+(Angle left, Angle right);
284
295 constexpr Angle& operator+=(Angle& left, Angle right);
296
307[[nodiscard]] constexpr Angle operator-(Angle left, Angle right);
308
319 constexpr Angle& operator-=(Angle& left, Angle right);
320
331[[nodiscard]] constexpr Angle operator*(Angle left, float right);
332
343[[nodiscard]] constexpr Angle operator*(float left, Angle right);
344
355 constexpr Angle& operator*=(Angle& left, float right);
356
367[[nodiscard]] constexpr Angle operator/(Angle left, float right);
368
379 constexpr Angle& operator/=(Angle& left, float right);
380
391[[nodiscard]] constexpr float operator/(Angle left, Angle right);
392
411[[nodiscard]] constexpr Angle operator%(Angle left, Angle right);
412
423 constexpr Angle& operator%=(Angle& left, Angle right);
424
425 namespace Literals
426{
427
437[[nodiscard]] constexpr Angle operator""_deg(long double angle);
438
448[[nodiscard]] constexpr Angle operator""_deg(unsigned long long int angle);
449
459[[nodiscard]] constexpr Angle operator""_rad(long double angle);
460
470[[nodiscard]] constexpr Angle operator""_rad(unsigned long long int angle);
471
472} // namespace Literals
473} // namespace sf
474
475#include <SFML/System/Angle.inl>
476
477
sf::Angle
Represents an angle value.
Definition Angle.hpp:35
sf::Angle::Angle
constexpr Angle()=default
Default constructor.
sf::Angle::Zero
static const Angle Zero
Predefined 0 degree angle value.
Definition Angle.hpp:135
sf::Angle::asRadians
constexpr float asRadians() const
Return the angle's value in radians.
sf::Angle::operator*
constexpr Angle operator*(Angle left, float right)
Overload of binary operator* to scale an angle value.
sf::Angle::operator%
constexpr Angle operator%(Angle left, Angle right)
Overload of binary operator% to compute modulo of an angle value.
sf::Angle::operator+=
constexpr Angle & operator+=(Angle &left, Angle right)
Overload of binary operator+= to add/assign two angle values.
sf::Angle::operator<=
constexpr bool operator<=(Angle left, Angle right)
Overload of operator<= to compare two angle values.
sf::Angle::operator*=
constexpr Angle & operator*=(Angle &left, float right)
Overload of binary operator*= to scale/assign an angle value.
sf::Angle::operator*
constexpr Angle operator*(float left, Angle right)
Overload of binary operator* to scale an angle value.
sf::Angle::wrapSigned
constexpr Angle wrapSigned() const
Wrap to a range such that -180° <= angle < 180°
sf::Angle::operator-
constexpr Angle operator-(Angle right)
Overload of unary operator- to negate an angle value.
sf::Angle::operator-=
constexpr Angle & operator-=(Angle &left, Angle right)
Overload of binary operator-= to subtract/assign two angle values.
sf::Angle::radians
friend constexpr Angle radians(float angle)
Construct an angle value from a number of radians.
sf::Angle::operator/
constexpr float operator/(Angle left, Angle right)
Overload of binary operator/ to compute the ratio of two angle values.
sf::Angle::degrees
friend constexpr Angle degrees(float angle)
Construct an angle value from a number of degrees.
sf::Angle::operator/=
constexpr Angle & operator/=(Angle &left, float right)
Overload of binary operator/= to scale/assign an angle value.
sf::Angle::operator+
constexpr Angle operator+(Angle left, Angle right)
Overload of binary operator+ to add two angle values.
sf::Angle::operator>=
constexpr bool operator>=(Angle left, Angle right)
Overload of operator>= to compare two angle values.
sf::Angle::operator!=
constexpr bool operator!=(Angle left, Angle right)
Overload of operator!= to compare two angle values.
sf::Angle::operator>
constexpr bool operator>(Angle left, Angle right)
Overload of operator> to compare two angle values.
sf::Angle::operator<
constexpr bool operator<(Angle left, Angle right)
Overload of operator< to compare two angle values.
sf::Angle::wrapUnsigned
constexpr Angle wrapUnsigned() const
Wrap to a range such that 0° <= angle < 360°
sf::Angle::operator==
constexpr bool operator==(Angle left, Angle right)
Overload of operator== to compare two angle values.
sf::Angle::operator-
constexpr Angle operator-(Angle left, Angle right)
Overload of binary operator- to subtract two angle values.
sf::Angle::asDegrees
constexpr float asDegrees() const
Return the angle's value in degrees.
sf::Angle::operator%=
constexpr Angle & operator%=(Angle &left, Angle right)
Overload of binary operator%= to compute/assign remainder of an angle value.
sf::Angle::operator/
constexpr Angle operator/(Angle left, float right)
Overload of binary operator/ to scale an angle value.
sf::Literals
Definition Angle.hpp:426
sf
Definition AudioResource.hpp:36
sf::radians
constexpr Angle radians(float angle)
Construct an angle value from a number of radians.
sf::degrees
constexpr Angle degrees(float angle)
Construct an angle value from a number of degrees.