source: Sophya/trunk/SophyaLib/Samba/unitvector.cc@ 502

Last change on this file since 502 was 262, checked in by ansari, 26 years ago

Ajout de fichiers de calcul de geometrie Vector3d, UnitVector, Circle, de Benoit Revenu Reza 23/04/99

File size: 1.2 KB
Line 
1#include <math.h>
2#include "unitvector.h"
3
4UnitVector::UnitVector() : Vector3d(1.,0.,0.)
5{
6}
7
8UnitVector::UnitVector(double x, double y, double z) : Vector3d(x,y,z)
9{
10 this->Normalize();
11}
12
13UnitVector::UnitVector(double theta, double phi) : Vector3d(theta,phi)
14{
15 this->Normalize();
16}
17
18UnitVector::UnitVector(const Vector3d& v) : Vector3d(v)
19{
20 this->Normalize();
21}
22
23Vector3d& UnitVector::operator=(const Vector3d& v)
24{
25 Setxyz(v.X(),v.Y(),v.Z());
26 this->Normalize();
27 return *this;
28}
29
30Vector3d& 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
37Vector3d& 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
44Vector3d UnitVector::operator+(const Vector3d& v) const
45{
46 return UnitVector(_x+v.X(),_y+v.Y(),_z+v.Z());
47}
48
49Vector3d UnitVector::operator-(const Vector3d& v) const
50{
51 return UnitVector(_x-v.X(),_y-v.Y(),_z-v.Z());
52}
53
54void 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}
Note: See TracBrowser for help on using the repository browser.