]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/PlanesOperations.cxx
install, doxy and direction
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / PlanesOperations.cxx
1
2 #include "PlanesOperations.h"
3
4 /********************************************************************************************
5 ** Start of data viewmanagerData
6 *********************************************************************************************/
7
8 PlanesOperations::PlanesOperations(){   
9 }
10
11
12 PlanesOperations::~PlanesOperations(){
13
14 }
15
16
17 double* PlanesOperations::getCrossProduct(double* vect0,double* vect1){
18         double* vectCross;
19         vectCross = new double[3];
20         vectCross[0] = vect0[1]*vect1[2]-(vect0[2]*vect1[1]);
21         vectCross[1] = -(vect0[0]*vect1[2]-(vect0[2]*vect1[0]));
22         vectCross[2] = vect0[0]*vect1[1]-(vect0[1]*vect1[0]);
23
24         return vectCross;
25 }
26 /**
27 **      Returns the magnitud of the given vector
28 **/
29 double PlanesOperations::getMagnitud(double* vect){
30
31         double mag;
32
33         mag = sqrt(pow(vect[0],2) + pow(vect[1],2) + pow(vect[2],2));
34
35         std::cout<<"mag "<<mag <<std::endl;
36
37         return mag;
38
39 }
40 /**
41 **      returns the unitary vector of the given vector
42 **      u = 1/|vect| . vect
43 **/
44 double* PlanesOperations::getNormal(double* vect){
45
46         double* vectnorm;
47         double mag = getMagnitud(vect);
48
49         vectnorm = new double[3];
50         
51
52         if(mag!=0){
53                 vectnorm[0] = vect[0]/mag;
54                 vectnorm[1] = vect[1]/mag;
55                 vectnorm[2] = vect[2]/mag;
56         }else{
57                 vectnorm[0] = 0;
58                 vectnorm[1] = 0;
59                 vectnorm[2] = 0;
60         }
61
62         return vectnorm;
63
64
65 }
66
67 double* PlanesOperations::makeVector(double podouble0[3], double podouble1[3]){
68         double *vect;
69         vect = new double[3];
70
71         vect[0]= podouble1[0]-podouble0[0];
72         vect[1]= podouble1[1]-podouble0[1];
73         vect[2]= podouble1[2]-podouble0[2];
74
75         return vect;
76
77 }