Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include "Vector2d.h"
- #include <iostream>
- #include <cmath>
- #include <cstring>
- using namespace std;
- Vector2d::Vector2d()
- {
- x = 0;
- y = 0;
- }
- Vector2d::Vector2d(double x, double y)
- {
- this->x = x;
- this->y = y;
- }
- Vector2d::Vector2d(double x_1, double x_2, double y_1, double y_2)
- {
- this->x = x_1;
- this->y = y_1;
- this->x = x_2;
- this->y = y_2;
- }
- Vector2d::Vector2d(const Vector2d & v)
- {
- x = v.x;
- y = v.y;
- }
- Vector2d Vector2d::operator+(const Vector2d & v) const
- {
- return Vector2d(x + v.x, y + v.y);
- }
- Vector2d Vector2d::operator-(const Vector2d & v) const
- {
- return Vector2d(x-v.x, y-v.y);
- }
- Vector2d Vector2d::operator*(const Vector2d & v) const
- {
- return Vector2d(x*v.x, y*v.y);
- }
- Vector2d& Vector2d::operator++()
- {
- x++;
- y++;
- return *this;
- }
- Vector2d Vector2d::operator++(int)
- {
- Vector2d temp(x, y);
- x++;
- y++;
- return temp;
- }
- Vector2d & Vector2d::operator--()
- {
- x--;
- y--;
- return *this;
- }
- Vector2d Vector2d::operator--(int)
- {
- Vector2d temp(x, y);
- x--;
- y--;
- return temp;
- }
- const Vector2d & Vector2d::operator+=(const Vector2d &v)
- {
- x += v.x;
- y += v.y;
- return *this;
- }
- const Vector2d & Vector2d::operator-=(const Vector2d &v)
- {
- x -= v.x;
- y -= v.y;
- return *this;
- }
- const Vector2d & Vector2d::operator*=(const Vector2d &v)
- {
- x *= v.x;
- y *= v.y;
- return *this;
- }
- Vector2d::operator string() const
- {
- string s = "(" + to_string(x) + ";" + to_string(y) + ")" ;
- return s;
- }
- Vector2d operator*(double r, Vector2d & v)
- {
- return r*v;
- }
- Vector2d::~Vector2d()
- {
- }
- void Vector2d::print(void)
- {
- std::cout << x << std::endl;
- std::cout << y << std::endl;
- }
- void Vector2d::sum(Vector2d b)
- {
- x = x + b.x;
- y = y + b.y;
- }
- void Vector2d::sub(Vector2d b)
- {
- x = x - b.x;
- y = y - b.y;
- }
- void Vector2d::mult(double b)
- {
- x = x*b;
- y = y*b;
- }
- double Vector2d::scalarMult(Vector2d V)
- {
- x = V.x*x;
- y = V.y*y;
- return (x,y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement