Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evangelia| Vector.h| Vector added #398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions Vector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <iostream>
#include <math.h>
using namespace std;

class Vector
{
private:
double x;
double y;


public:
Vector()
{
x = 0.0;
y = 0.0;
}
Vector(double in_x,double in_y)
{
x = in_x;
y = in_y;
}
void SetX(double in_x)
{
x =in_x;
}
void SetY(double in_y)
{
y = in_y;
}
double GetX() const
{
return x;
}
double GetY() const
{
return y;
}
float magnitude()
{
return sqrt(pow(x,2) + pow(y,2));

}
float angle()
{
return atan(y/x);
}
float angleD()
{
return (atan(y/x) * 180)/M_PI;

}
void multiply(double f)
{
x = x*f;
y = y*f;
}
Vector add(Vector v)
{
Vector k;
k.x = v.x + x;
k.y = v.y + y;
return k;
}
Vector clone()
{
Vector c;
c.x = x;
c.y = y;
return c;
}
};