1 #include "VectorMath.h"
5 VectorMath::VectorMath()
10 VectorMath::~VectorMath()
15 /*Sets all the vector points*/
16 void VectorMath::SetData(std::vector<int> pointsX1, std::vector<int> pointsX2, std::vector<int> pointsY1, std::vector<int> pointsY2, std::vector<int> pointsZ1, std::vector<int> pointsZ2)
18 _pointx1a = pointsX1[0];
19 _pointx1b = pointsX1[1];
21 _pointx2a = pointsX2[0];
22 _pointx2b = pointsX2[1];
24 _pointy1a = pointsY1[0];
25 _pointy1b = pointsY1[1];
27 _pointy2a = pointsY2[0];
28 _pointy2b = pointsY2[1];
30 _pointz1a = pointsZ1[0];
31 _pointz1b = pointsZ1[1];
33 _pointz2a = pointsZ2[0];
34 _pointz2b = pointsZ2[1];
37 /*Runs the calculations*/
38 void VectorMath::Run()
41 _origin.push_back(_pointx2a);
42 _origin.push_back(_pointy2a);
43 _origin.push_back(_pointz2a);
45 std::cout << "Vector Math: Origin points: X = " << _pointx2a << " Y = " << _pointy2a << " Z = " << _pointz2a << std::endl;
47 _originReslicer.clear();
48 _originReslicer.push_back(_pointx1a);
49 _originReslicer.push_back(_pointy1a);
50 _originReslicer.push_back(_pointz1a);
52 std::cout << "Vector Math: Origin Reslicer points: X = " << _pointx1a << " Y = " << _pointy1a << " Z = " << _pointz1a << std::endl;
55 _vectorA[0] =(double)(_pointx1b - _pointx1a);
56 _vectorA[1] =(double)(_pointy1b - _pointy1a);
57 _vectorA[2] =(double)(_pointz1b - _pointz1a);
59 double normA = vtkMath::Norm(_vectorA);
61 _vectorA[0] = _vectorA[0]/normA;
62 _vectorA[1] = _vectorA[1]/normA;
63 _vectorA[2] = _vectorA[2]/normA;
66 _vectorB[0] =(double)(_pointx2b - _pointx2a - _pointx1a);
67 _vectorB[1] =(double)(_pointy2b - _pointy2a - _pointy1a);
68 _vectorB[2] =(double)(_pointz2b - _pointz2a - _pointz1a);
70 double normB = vtkMath::Norm(_vectorB);
72 _vectorB[0] = _vectorB[0]/normB;
73 _vectorB[1] = _vectorB[1]/normB;
74 _vectorB[2] = _vectorB[2]/normB;
76 vtkMath::Cross(_vectorA, _vectorB, _result);
78 std::cout << "Data from vector A: X: " << _vectorA[0] << " Y: " << _vectorA[1] << " Z: " << _vectorA[2] << std::endl;
79 std::cout << "Data from vector B: X: " << _vectorB[0] << " Y: " << _vectorB[1] << " Z: " << _vectorB[2] << std::endl;
80 std::cout << "Data from result: X: " << _result[0] << " Y: " << _result[1] << " Z: " << _result[2] << std::endl;
82 double _vectorOrigin[3] = {0,0,0};
84 double distanceA = vtkMath::Distance2BetweenPoints(_vectorOrigin, _vectorA);
85 double distanceB = vtkMath::Distance2BetweenPoints(_vectorOrigin, _vectorA);
87 double proportion = distanceA/distanceB;
98 _angle = acos(vtkMath::Dot(_vectorA, _vectorB));
100 _angle = vtkMath::DegreesFromRadians(_angle);
102 std::cout << "Dot " << vtkMath::Dot(_vectorA, _vectorB) << std::endl;
103 std::cout << "Angle " << (double)_angle << std::endl;
106 /*Returns the origin of the second vector*/
107 std::vector<int> VectorMath::GetOrigin()
112 /*Returns the origin of the first vector*/
113 std::vector<int> VectorMath::GetOriginReslicer()
115 return _originReslicer;
118 /*Returns the cross product of the two vectors*/
119 void VectorMath::GetResult(double result[3])
125 double VectorMath::GetScaleX()
131 double VectorMath::GetScaleY()
137 double VectorMath::GetScaleZ()
142 /*Rotation angle (dot product)*/
143 double VectorMath::GetAngle()