]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/PlanesOperations.cxx
7ea40d138993d1891bd89e6a6075fcd1b96914ad
[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
13 PlanesOperations::~PlanesOperations()
14 {
15
16 }
17
18
19 double* PlanesOperations::getCrossProduct(double* vect0,double* vect1)
20 {
21         double* vectCross;
22         vectCross = new double[3];
23         vectCross[0] = vect0[1]*vect1[2]-(vect0[2]*vect1[1]);
24         vectCross[1] = -(vect0[0]*vect1[2]-(vect0[2]*vect1[0]));
25         vectCross[2] = vect0[0]*vect1[1]-(vect0[1]*vect1[0]);
26
27         return vectCross;
28 }
29 /**
30 **      Returns the magnitud of the given vector
31 **/
32 double PlanesOperations::getMagnitud(double* vect)
33 {
34         double mag;
35
36         mag = sqrt(pow(vect[0],2) + pow(vect[1],2) + pow(vect[2],2));
37
38         std::cout<<"mag "<<mag <<std::endl;
39
40         return mag;
41 }
42 /**
43 **      returns the unitary vector of the given vector
44 **      u = 1/|vect| . vect
45 **/
46 double* PlanesOperations::getNormal(double* vect)
47 {
48
49         double* vectnorm;
50         double mag = getMagnitud(vect);
51
52         vectnorm = new double[3];
53         
54         if(mag!=0){
55                 vectnorm[0] = vect[0]/mag;
56                 vectnorm[1] = vect[1]/mag;
57                 vectnorm[2] = vect[2]/mag;
58         }else{
59                 vectnorm[0] = 0;
60                 vectnorm[1] = 0;
61                 vectnorm[2] = 0;
62         }
63         return vectnorm;
64 }
65
66 double* PlanesOperations::makeVector(double podouble0[3], double podouble1[3])
67 {
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