YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Vec2D.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026-2026 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_MATH_VEC2D_H
7#define YARP_MATH_VEC2D_H
8
9#include <yarp/math/api.h>
10
11#include <yarp/sig/Matrix.h>
12#include <yarp/sig/Vector.h>
13
17
18template <typename T>
20{
21 static_assert(
22 std::is_same_v<T, int> || std::is_same_v<T, size_t> || std::is_same_v<T, double>,
23 "vec2D<T>: T must be int, size_t or double"
24 );
25};
26
27namespace yarp::math
28{
29 template <typename Derived>
30 Derived operator*(const yarp::sig::Matrix& lhs, const Derived& rhs);
31
32 template <typename Derived, typename Scalar>
33 class YARP_math_API Vec2DCommon
34 {
35 public:
40 Scalar norm() const;
41
46 std::string PrintToString(int precision = -1, int width = -1) const;
47
48 Vec2DCommon() = default;
49 Vec2DCommon(const yarp::sig::Vector& v);
50 explicit operator yarp::sig::Vector() const;
51
52 bool operator==(const Derived& other) const;
53 bool operator!=(const Derived& other) const;
54 Derived operator+(const Derived& other) const;
55 Derived operator-(const Derived& other) const;
56 Derived operator*(const Derived& other) const;
57 Derived operator+=(const Derived& rhs);
58 Derived operator-=(const Derived& rhs);
59 };
60}
61
62namespace yarp::math
63{
64 class YARP_math_API Vec2DOfDouble : public yarp::sig::Vec2DOfDoubleData, public yarp::math::Vec2DCommon<Vec2DOfDouble, double>
65 {
66 public:
68 using yarp::math::Vec2DCommon<Vec2DOfDouble, double>::Vec2DCommon;
69 };
70
71 class YARP_math_API Vec2DOfInt : public yarp::sig::Vec2DOfIntData, public yarp::math::Vec2DCommon<Vec2DOfInt, int>
72 {
73 public:
75 using yarp::math::Vec2DCommon<Vec2DOfInt, int>::Vec2DCommon;
76 };
77
78 class YARP_math_API Vec2DOfSizet : public yarp::sig::Vec2DOfSizetData, public yarp::math::Vec2DCommon<Vec2DOfSizet, size_t>
79 {
80 public:
82 using yarp::math::Vec2DCommon<Vec2DOfSizet, size_t>::Vec2DCommon;
83 };
84}
85
86
87template <>
91
92template <>
96
97template <>
101
102namespace yarp::math {
103template <typename T>
105}
106
107#endif // YARP_MATH_VEC2D_H
bool operator==(const struct v4l2_control &left, const struct v4l2_control &right)
Definition CApiMock.h:65
size_t size_t
contains the definition of a Matrix type
contains the definition of a Vector type
A class for a Matrix.
Definition Matrix.h:40
Vector operator+(const Vector &a, const double &s)
Mathematical operations.
Definition math.cpp:27
Vector operator-(const Vector &a, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition math.cpp:82
Vector operator*(double k, const Vector &b)
Scalar-vector product operator (defined in Math.h).
Definition math.cpp:143
Vector & operator-=(Vector &a, const double &s)
Subtraction operator between a vector and a scalar (defined in Math.h).
Definition math.cpp:98
Vector & operator+=(Vector &a, const double &s)
Addition operator between a scalar and a vector (defined in Math.h).
Definition math.cpp:38
typename vec2D_selector< T >::type Vec2D
Definition Vec2D.h:104
Derived operator*(const yarp::sig::Matrix &lhs, const Derived &rhs)
Definition Vec2D.cpp:109
#define YARP_math_API
Definition api.h:17