PolarVector2.hpp
Go to the documentation of this file.
1 //
3 // Thor C++ Library
4 // Copyright (c) 2011-2015 Jan Haller
5 //
6 // This software is provided 'as-is', without any express or implied
7 // warranty. In no event will the authors be held liable for any damages
8 // arising from the use of this software.
9 //
10 // Permission is granted to anyone to use this software for any purpose,
11 // including commercial applications, and to alter it and redistribute it
12 // freely, subject to the following restrictions:
13 //
14 // 1. The origin of this software must not be misrepresented; you must not
15 // claim that you wrote the original software. If you use this software
16 // in a product, an acknowledgment in the product documentation would be
17 // appreciated but is not required.
18 //
19 // 2. Altered source versions must be plainly marked as such, and must not be
20 // misrepresented as being the original software.
21 //
22 // 3. This notice may not be removed or altered from any source distribution.
23 //
25 
28 
29 #ifndef THOR_POLARVECTOR2_HPP
30 #define THOR_POLARVECTOR2_HPP
31 
34 
35 
36 namespace thor
37 {
38 
41 
44 template <typename T>
45 struct PolarVector2
46 {
47  T r;
48  T phi;
49 
52  PolarVector2();
53 
57  PolarVector2(T radius, T angle);
58 
62  PolarVector2(const sf::Vector2<T>& vector);
63 
66  operator sf::Vector2<T> () const;
67 };
68 
72 
76 template <typename T>
77 T length(const PolarVector2<T>& vector);
78 
82 template <typename T>
83 T polarAngle(const PolarVector2<T>& vector);
84 
86 
87 } // namespace thor
88 
89 #include <Thor/Vectors/Detail/PolarVector2.inl>
90 #endif // THOR_POLARVECTOR2_HPP
T polarAngle(const sf::Vector2< T > &vector)
Returns the polar angle.
Algebraic operations on two-dimensional vectors (dot product, vector length and angles, ...)
Definition: Animator.hpp:42
Class template thor::TrigonometricTraits and some trigonometry-related functions and constants...
T phi
Angle in degrees.
Definition: PolarVector2.hpp:48
T r
Radius.
Definition: PolarVector2.hpp:47
PolarVector2< float > PolarVector2f
Type definition for float polar vectors.
Definition: PolarVector2.hpp:71
T length(const sf::Vector2< T > &vector)
Returns the length of the 2D vector.
PolarVector2()
Default constructor.
Vector in polar coordinate system.
Definition: ToString.hpp:63