Bromeon
Vectors/VectorAlgebra2D.hpp
Go to the documentation of this file.
00001 
00002 //
00003 // Thor C++ Library
00004 // Copyright (c) 2011-2012 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 #include <SFML/System/Vector3.hpp>
00050 
00051 #include <cassert>
00052 
00053 
00054 namespace thor
00055 {
00056 
00059 
00062 template <typename T>
00063 T                           Length(const sf::Vector2<T>& vector);
00064 
00067 template <typename T>
00068 T                           SquaredLength(const sf::Vector2<T>& vector);
00069 
00073 template <typename T>
00074 void                        SetLength(sf::Vector2<T>& vector, T newLength);
00075 
00078 template <typename T>
00079 sf::Vector2<T>              UnitVector(const sf::Vector2<T>& vector);
00080 
00085 template <typename T>
00086 T                           PolarAngle(const sf::Vector2<T>& vector);
00087 
00090 template <typename T>
00091 void                        SetPolarAngle(sf::Vector2<T>& vector, T newAngle);
00092 
00095 template <typename T>
00096 void                        Rotate(sf::Vector2<T>& vector, T angle);
00097 
00100 template <typename T>
00101 sf::Vector2<T>              RotatedVector(const sf::Vector2<T>& vector, T angle);
00102 
00106 template <typename T>
00107 sf::Vector2<T>              PerpendicularVector(const sf::Vector2<T>& vector);
00108 
00109 // ---------------------------------------------------------------------------------------------------------------------------
00110 
00111 
00116 template <typename T>
00117 T                           Angle(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00118 
00121 template <typename T>
00122 T                           DotProduct(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00123 
00127 template <typename T>
00128 sf::Vector3<T>              CrossProduct(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00129 
00132 template <typename T>
00133 sf::Vector2<T>              ComponentwiseProduct(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00134 
00138 template <typename T>
00139 sf::Vector2<T>              ComponentwiseQuotient(const sf::Vector2<T>& lhs, const sf::Vector2<T>& rhs);
00140 
00142 
00143 } // namespace thor
00144 
00145 #include <Thor/Detail/VectorAlgebra2D.inl>
00146 #endif // THOR_VECTORALGEBRA2D_HPP