| 
    modm API documentation
    
   | 
 
Class for handling common vector operations (2D) More...
#include <modm/math/geometry/vector2.hpp>
Public Typedefs | |
| typedef GeometricTraits< T >::WideType | WideType | 
| typedef GeometricTraits< T >::FloatType | FloatType | 
Public Member Functions | |
| Vector () | |
| Default-Constructor.  More... | |
| Vector (const T &inX, const T &inY) | |
| Vector (const Vector< T, 1 > &inX, const Vector< T, 1 > &inY) | |
| Vector (const T &inX, const Vector< T, 1 > &inY) | |
| Vector (const Vector< T, 1 > &inX, const T &inY) | |
| Vector (T inVal) | |
| Vector (const Matrix< T, 2, 1 > &rhs) | |
| void | setX (const T &value) | 
| void | setY (const T &value) | 
| void | set (const T &x, const T &y) | 
| const T & | getX () const | 
| const T & | getY () const | 
| T | getLength () const | 
| Calculate length of the vector.  | |
| WideType | getLengthSquared () const | 
| Calculate squared length of the vector.  More... | |
| float | getAngle () const | 
| Calculate the absolute angle.  More... | |
| Vector & | normalize () | 
| Normalize length to 1.  More... | |
| Vector | normalized () const | 
| Vector & | scale (float length) | 
Scale the vector to length.  | |
| Vector | scaled (float length) const | 
| Vector & | rotate (float phi) | 
| Vector & | translate (const Vector &vector) | 
| Move the point in x and y direction.  | |
| WideType | getDistanceTo (const Vector &other) const | 
| float | getAngleTo (const Vector &other) const | 
| WideType | dot (const Vector &other) const | 
| Calculate the dot-product.  More... | |
| WideType | cross (const Vector &other) const | 
| Calculate the cross-product.  More... | |
| template<typename U > | |
| Vector< U, 2 > | convert () const | 
| Convert between Point-objects with different base-types.  | |
| Vector | toOrthogonalVector () const | 
| Returns a perpendicular copy of the vector.  More... | |
| Vector | perpendicular () const | 
| Vector & | operator= (const Matrix< T, 2, 1 > &rhs) | 
| bool | operator== (const Vector &rhs) const | 
| bool | operator!= (const Vector &rhs) const | 
| bool | operator< (const Vector &rhs) const | 
| bool | operator<= (const Vector &rhs) const | 
| bool | operator> (const Vector &rhs) const | 
| bool | operator>= (const Vector &rhs) const | 
| const T & | operator[] (uint8_t index) const | 
| T & | operator[] (uint8_t index) | 
| T * | ptr () | 
| const T * | ptr () const | 
| Vector | operator- () const | 
| Vector | operator- (const Vector &rhs) const | 
| Vector | operator+ (const Vector &rhs) const | 
| T | operator* (const Vector &rhs) const | 
| T | operator^ (const Vector &rhs) const | 
| Vector | operator* (float rhs) const | 
| Vector | operator/ (float rhs) const | 
| Vector & | operator+= (const Vector &rhs) | 
| Vector & | operator-= (const Vector &rhs) | 
| Vector & | operator*= (const T &rhs) | 
| Vector & | operator/= (const T &rhs) | 
| Vector & | operator~ () | 
| Matrix< T, 2, 1 > & | asMatrix () | 
| const Matrix< T, 2, 1 > & | asMatrix () const | 
| Matrix< T, 1, 2 > & | asTransposedMatrix () | 
| const Matrix< T, 1, 2 > & | asTransposedMatrix () const | 
| bool | hasNan () const | 
| bool | hasInf () const | 
Static Public Member Functions | |
| static int_fast8_t | ccw (const Vector &a, const Vector &b, const Vector &c) | 
| Check if three points are in a counter-clock wise direction.  More... | |
Public Attributes | |
| T | x | 
| T | y | 
Friends | |
| class | Location2D< T > | 
| template<typename U > | |
| IOStream & | operator<< (IOStream &os, const Vector< U, 2 > &c) | 
| Stream operator for modm::Vector<U, 2>  | |
| template<typename U > | |
| Vector< U, 2 > | operator* (float scale, const Vector< U, 2 > &vector) | 
| Scalar multiplication.  | |
Class for handling common vector operations (2D)
Operations:
Adapted from the implementation of Gaspard Petit (gaspardpetit@gmail.com) and heavily modified.
| modm::Vector< T, 2 >::Vector | ( | ) | 
Default-Constructor.
Creates a Vector with coordinates (0, 0).
      
  | 
  static | 
Check if three points are in a counter-clock wise direction.
Check if we move counter-clock wise if we move from the first point to the second and the third.
If all three points are in a line there are three possibilities: 1) strait line: third point behind the second (returns 1) 2) last point between the other two (returns 0) 3) third point before the first one (returns -1)
This definition is useful for inclusion or intersection testing.
| WideType modm::Vector< T, 2 >::cross | ( | const Vector< T, 2 > & | other | ) | const | 
Calculate the cross-product.
In 2D there is no clear definition of this operation.
This implementation is the most common one and will return the magnitude of the vector that would result from a regular 3D cross product of the input vectors, taking their Z values implicitly as 0 (i.e. treating the 2D space as a plane in the 3D space). The 3D cross product will be perpendicular to that plane, and thus have 0 X & Y components (thus the scalar returned is the Z value of the 3D cross product vector).
Other implementations take no arguments and returns a vector perpendicular to the input vector. This can be reached with the toOrthogonalVector() method, which returns a perpendicular copy of the vector.
| WideType modm::Vector< T, 2 >::dot | ( | const Vector< T, 2 > & | other | ) | const | 
Calculate the dot-product.
Also known as the scalar product.
| float modm::Vector< T, 2 >::getAngle | ( | ) | const | 
Calculate the absolute angle.
| WideType modm::Vector< T, 2 >::getLengthSquared | ( | ) | const | 
Calculate squared length of the vector.
This method is considerably faster than getLength() because it doesn't need to calculate the square root.
| Vector& modm::Vector< T, 2 >::normalize | ( | ) | 
Normalize length to 1.
| Vector modm::Vector< T, 2 >::toOrthogonalVector | ( | ) | const | 
Returns a perpendicular copy of the vector.