This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
SDi-STOMP/Vector2D.h

42 lines
743 B
C++

#ifndef VECTOR2D_H
#define VECTOR2D_H
#include <cmath>
class Vector2D {
public:
typedef struct {
double x;
double y;
} Point;
Vector2D() = default;
Vector2D(Point point);
Vector2D(double lenght, double angle);
~Vector2D() = default;
static Point CreatePoint(double x, double y);
double x() {return point_.x;}
double y() {return point_.y;}
Point point() {return point_;}
double lenght() {return lenght_;}
double angle() {return angle_;}
void normalize(double max);
Vector2D reverse();
Vector2D operator +(Vector2D v) const;
Vector2D operator -(Vector2D v) const;
private:
Point point_;
double lenght_;
double angle_;
};
#endif //VECTOR2D_H