-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.cpp
More file actions
46 lines (41 loc) · 749 Bytes
/
vector.cpp
File metadata and controls
46 lines (41 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "vector.h"
#ifndef INCLUDED_MATH
#include <math.h>
#define INCLUDED_MATH
#endif
#define SQ(x) ((x)*(x))
#define PI 3.141592
Vector::Vector(){
x = 0;
y = 0;
z = 0;
}
Vector::Vector(int scalar, int xyangle, int xzangle){
y = scalar*sin(xyangle*PI/180);
double r = scalar*cos(xyangle*PI/180);
z = r*sin(xzangle*PI/180);
x = r*cos(xzangle*PI/180);
}
Vector::Vector(const Vector &o){
x = o.getx();
y = o.gety();
z = o.getz();
}
Vector::Vector(double xx, double yy, double zz){
x = xx;
y = yy;
z = zz;
}
double Vector::getScalar(){
return sqrt(SQ(getx())+SQ(gety())+SQ(getz()));
}
Vector::~Vector(){}
double Vector::getx() const{
return x;
}
double Vector::gety() const{
return y;
}
double Vector::getz() const{
return z;
}