DeSiGNAR  0.5a
Data Structures General Library
vector2D.H
Go to the documentation of this file.
1 /*
2  This file is part of Designar.
3  Copyright (C) 2017 by Alejandro J. Mujica
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Any user request of this software, write to
19 
20  Alejandro Mujica
21 
22  aledrums@gmail.com
23 */
24 
25 # ifndef DSGVECTOR2D_H
26 # define DSGVECTOR2D_H
27 
28 # include <point2D.H>
29 
30 namespace Designar
31 {
32  class Vector2D : public Point2D
33  {
34  using Base = Point2D;
35  using Base::Base;
36 
37  public:
38  static const Vector2D ZERO;
39 
40  bool is_to_right_from(const Vector2D &) const;
41 
42  bool is_to_right_on_from(const Vector2D &) const;
43 
44  bool is_to_left_from(const Vector2D &) const;
45 
46  bool is_to_left_on_from(const Vector2D &) const;
47 
48  bool is_collinear_with(const Vector2D &) const;
49 
50  bool is_normalized() const;
51 
52  bool is_unitarian() const;
53 
54  real_t square_magnitude() const;
55 
56  real_t magnitude() const;
57 
58  real_t length() const;
59 
60  void normalize();
61 
62  void negate();
63 
64  void scale(double);
65 
66  bool is_opposite(const Vector2D &) const;
67 
68  Vector2D get_opposite() const;
69 
70  real_t angle_with(const Vector2D &) const;
71 
72  void add_scaled_vector(const Vector2D &, real_t);
73 
74  real_t dot_product(const Vector2D &) const;
75 
76  real_t scalar_product(const Vector2D &) const;
77 
78  real_t cross_product(const Vector2D &) const;
79 
80  real_t vector_product(const Vector2D &) const;
81 
82  Vector2D component_product(const Vector2D &) const;
83 
85  Vector2D operator - () const;
86 
89 
91  void operator *= (real_t);
92 
94  friend Vector2D operator * (real_t, const Vector2D &);
95 
97  real_t operator * (const Vector2D &) const;
98 
100  Vector2D operator + (const Vector2D &) const;
101 
103  void operator += (const Vector2D &);
104 
106  Vector2D operator - (const Vector2D &) const;
107 
109  void operator -= (const Vector2D &);
110 
111  static std::tuple<Vector2D, Vector2D>
113  };
114 
115 } // end namespace Designar
116 
117 # endif // DSGVECTOR_2D_H
118 
bool is_to_left_on_from(const Vector2D &) const
Vector2D operator*(real_t) const
Multiplies this by a scalar value.
real_t magnitude() const
static std::tuple< Vector2D, Vector2D > make_orthonormal_basis(const Vector2D &)
real_t cross_product(const Vector2D &) const
void add_scaled_vector(const Vector2D &, real_t)
bool is_to_left_from(const Vector2D &) const
double real_t
Definition: types.H:51
bool is_normalized() const
void operator+=(const Vector2D &)
Accumulative vector addition.
real_t scalar_product(const Vector2D &) const
Vector2D get_opposite() const
bool is_collinear_with(const Vector2D &) const
real_t length() const
Vector2D operator-() const
Performs get_opossite.
real_t square_magnitude() const
bool is_to_right_on_from(const Vector2D &) const
Definition: point2D.H:247
bool is_opposite(const Vector2D &) const
void operator*=(real_t)
Accumulates the product of this by a scalar value.
real_t vector_product(const Vector2D &) const
Definition: array.H:32
void scale(double)
bool is_unitarian() const
bool is_to_right_from(const Vector2D &) const
Vector2D component_product(const Vector2D &) const
static const Vector2D ZERO
Definition: vector2D.H:38
real_t dot_product(const Vector2D &) const
void operator-=(const Vector2D &)
Accumulative vector substraction.
real_t angle_with(const Vector2D &) const
Vector2D operator+(const Vector2D &) const
Performs vector addition.
Definition: vector2D.H:32