[262] | 1 | #include <math.h>
|
---|
| 2 | #include "unitvector.h"
|
---|
| 3 |
|
---|
| 4 | UnitVector::UnitVector() : Vector3d(1.,0.,0.)
|
---|
| 5 | {
|
---|
| 6 | }
|
---|
| 7 |
|
---|
| 8 | UnitVector::UnitVector(double x, double y, double z) : Vector3d(x,y,z)
|
---|
| 9 | {
|
---|
| 10 | this->Normalize();
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | UnitVector::UnitVector(double theta, double phi) : Vector3d(theta,phi)
|
---|
| 14 | {
|
---|
| 15 | this->Normalize();
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | UnitVector::UnitVector(const Vector3d& v) : Vector3d(v)
|
---|
| 19 | {
|
---|
| 20 | this->Normalize();
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | Vector3d& UnitVector::operator=(const Vector3d& v)
|
---|
| 24 | {
|
---|
| 25 | Setxyz(v.X(),v.Y(),v.Z());
|
---|
| 26 | this->Normalize();
|
---|
| 27 | return *this;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | Vector3d& UnitVector::operator+=(const Vector3d& v)
|
---|
| 31 | {
|
---|
| 32 | Setxyz(_x+v.X(),_y+v.Y(),_z+v.Z());
|
---|
| 33 | this->Normalize();
|
---|
| 34 | return *this;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | Vector3d& UnitVector::operator-=(const Vector3d& v)
|
---|
| 38 | {
|
---|
| 39 | Setxyz(_x-v.X(),_y-v.Y(),_z-v.Z());
|
---|
| 40 | this->Normalize();
|
---|
| 41 | return *this;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | Vector3d UnitVector::operator+(const Vector3d& v) const
|
---|
| 45 | {
|
---|
| 46 | return UnitVector(_x+v.X(),_y+v.Y(),_z+v.Z());
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | Vector3d UnitVector::operator-(const Vector3d& v) const
|
---|
| 50 | {
|
---|
| 51 | return UnitVector(_x-v.X(),_y-v.Y(),_z-v.Z());
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | void UnitVector::Print(ostream& os) const
|
---|
| 55 | {
|
---|
| 56 | os << "UnitVector : (X,Y,Z)= (" << _x << ", " << _y << ", " << _z
|
---|
| 57 | << ") Theta,Phi= " << _theta << ", " << _phi << "\n"
|
---|
| 58 | << "norme =" << this->Norm() << endl;
|
---|
| 59 | }
|
---|