VectorAlgebra3D.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 
35 
36 #ifndef THOR_VECTORALGEBRA3D_HPP
37 #define THOR_VECTORALGEBRA3D_HPP
38 
40 
41 #include <SFML/System/Vector2.hpp>
42 #include <SFML/System/Vector3.hpp>
43 
44 #include <cassert>
45 
46 
47 namespace thor
48 {
49 
52 
55 template <typename T>
56 T length(const sf::Vector3<T>& vector);
57 
60 template <typename T>
61 T squaredLength(const sf::Vector3<T>& vector);
62 
65 template <typename T>
66 sf::Vector3<T> unitVector(const sf::Vector3<T>& vector);
67 
72 template <typename T>
73 T polarAngle(const sf::Vector3<T>& vector);
74 
79 template <typename T>
80 T elevationAngle(const sf::Vector3<T>& vector);
81 
82 // ---------------------------------------------------------------------------------------------------------------------------
83 
84 
87 template <typename T>
88 T dotProduct(const sf::Vector3<T>& lhs, const sf::Vector3<T>& rhs);
89 
92 template <typename T>
93 sf::Vector3<T> crossProduct(const sf::Vector3<T>& lhs, const sf::Vector3<T>& rhs);
94 
98 template <typename T>
99 sf::Vector3<T> cwiseProduct(const sf::Vector3<T>& lhs, const sf::Vector3<T>& rhs);
100 
105 template <typename T>
106 sf::Vector3<T> cwiseQuotient(const sf::Vector3<T>& lhs, const sf::Vector3<T>& rhs);
107 
108 // ---------------------------------------------------------------------------------------------------------------------------
109 
110 
113 template <typename T>
114 sf::Vector3<T> toVector3(const sf::Vector2<T>& vector2);
115 
117 
118 } // namespace thor
119 
120 #include <Thor/Vectors/Detail/VectorAlgebra3D.inl>
121 #endif // THOR_VECTORALGEBRA3D_HPP
T dotProduct(const sf::Vector3< T > &lhs, const sf::Vector3< T > &rhs)
Computes the dot product of two 3D vectors.
sf::Vector3< T > toVector3(const sf::Vector2< T > &vector2)
Constructs a 3D vector from a 2D vector by setting the Z component to zero.
T elevationAngle(const sf::Vector3< T > &vector)
Returns the elevation angle of vector.
sf::Vector3< T > cwiseProduct(const sf::Vector3< T > &lhs, const sf::Vector3< T > &rhs)
Returns the component-wise product of lhs and rhs.
Definition: Animator.hpp:42
sf::Vector3< T > cwiseQuotient(const sf::Vector3< T > &lhs, const sf::Vector3< T > &rhs)
Returns the component-wise quotient of lhs and rhs.
Class template thor::TrigonometricTraits and some trigonometry-related functions and constants...
sf::Vector3< T > crossProduct(const sf::Vector3< T > &lhs, const sf::Vector3< T > &rhs)
Computes the cross product of two 3D vectors.
T squaredLength(const sf::Vector3< T > &vector)
Returns the square of vector's length.
T polarAngle(const sf::Vector3< T > &vector)
Returns the angle between the projection of vector onto the XY-plane and the X-axis.
sf::Vector3< T > unitVector(const sf::Vector3< T > &vector)
Returns a vector with same direction as the argument, but with length 1.
T length(const sf::Vector3< T > &vector)
Returns the length of the 3D vector.