Vectors/VectorAlgebra2D.hpp
Go to the documentation of this file.
00001 
00002 //
00003 // Thor C++ Library
00004 // Copyright (c) 2011-2015 Jan Haller
00005 // 
00006 // This software is provided 'as-is', without any express or implied
00007 // warranty. In no event will the authors be held liable for any damages
00008 // arising from the use of this software.
00009 // 
00010 // Permission is granted to anyone to use this software for any purpose,
00011 // including commercial applications, and to alter it and redistribute it
00012 // freely, subject to the following restrictions:
00013 // 
00014 // 1. The origin of this software must not be misrepresented; you must not
00015 //    claim that you wrote the original software. If you use this software
00016 //    in a product, an acknowledgment in the product documentation would be
00017 //    appreciated but is not required.
00018 // 
00019 // 2. Altered source versions must be plainly marked as such, and must not be
00020 //    misrepresented as being the original software.
00021 // 
00022 // 3. This notice may not be removed or altered from any source distribution.
00023 //
00025 
00042 
00043 #ifndef THOR_VECTORALGEBRA2D_HPP
00044 #define THOR_VECTORALGEBRA2D_HPP
00045 
00046 #include <Thor/Math/Trigonometry.hpp>
00047 
00048 #include <SFML/System/Vector2.hpp>
00049 
00050 #include <cassert>
00051 
00052 
00053 namespace thor
00054 {
00055 
00058 
00061 template <typename T>
00062 T                           length(const sf::Vector2<T>& vector);
00063 
00066 template <typename T>
00067 T                           squaredLength(const sf::Vector2<T>& vector);
00068 
00072 template <typename T>
00073 void                        setLength(sf::Vector2<T>& vector, T newLength);
00074 
00077 template <typename T>
00078 sf::Vector2<T>              unitVector(const sf::Vector2<T>& vector);
00079 
00084 template <typename T>
00085 T                           polarAngle(const sf::Vector2<T>& vector);
00086 
00089 template <typename T>
00090 void                        setPolarAngle(sf::Vector2<T>& vector, T newAngle);
00091 
00094 template <typename T>
00095 void                        rotate(sf::Vector2<T>& vector, T angle);
00096 
00099 template <typename T>
00100 sf::Vector2<T>              rotatedVector(const sf::Vector2<T>& vector, T angle);
00101 
00105 template <typename T>
00106 sf::Vector2<T>              perpendicularVector(const sf::Vector2<T>& vector);
00107 
00108 // ---------------------------------------------------------------------------------------------------------------------------
00109 
00110 
00115 template <typename T>
00116 T                           signedAngle(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00117 
00120 template <typename T>
00121 T                           dotProduct(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00122 
00126 template <typename T>
00127 T                           crossProduct(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00128 
00131 template <typename T>
00132 sf::Vector2<T>              cwiseProduct(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00133 
00137 template <typename T>
00138 sf::Vector2<T>              cwiseQuotient(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00139 
00143 template <typename T>
00144 sf::Vector2<T>              projectedVector(const sf::Vector2<T>& vector, const sf::Vector2<T>& axis);
00145 
00147 
00148 } // namespace thor
00149 
00150 #include <Thor/Vectors/Detail/VectorAlgebra2D.inl>
00151 #endif // THOR_VECTORALGEBRA2D_HPP