-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVector.cpp
36 lines (34 loc) · 1 KB
/
Vector.cpp
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
//---------------------------------------------------------------------------
#pragma hdrstop
#include "Vector.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
/* --- Êîíñòðóêòîð --- */
Vector::Vector(double &x, double &y){set(x,y);}
//---------------------------------------------------------------------------
void Vector::set(double &x, double &y){
this->x = x;
this->y = y;
this->mod = sqrt(x*x + y*y);
if(x!=0){
this->arg = atan(y/x);
if(x<0) this->arg+=M_PI;
}
else
this->arg = 0;
}
//---------------------------------------------------------------------------
void Vector::set_amp(double &A, double &arg){
this->mod = A;
this->arg = arg;
this->x = A*cos(arg);
this->y = A*sin(arg);
}
//---------------------------------------------------------------------------
void Vector::rotate(double &angle){
arg +=angle;
x = mod*cos(arg);
y = mod*sin(arg);
arg = atan(y/x);
if(x<0) arg+=M_PI;// ïðèâîäèì óãîë
}