5#include "CLHEP/Geometry/Point3D.h"
6#include "CLHEP/Geometry/Vector3D.h"
7#include "CLHEP/Geometry/Normal3D.h"
8#include "CLHEP/Geometry/Transform3D.h"
9#include "CLHEP/Units/PhysicalConstants.h"
17 if (del < 0) del = -del;
18 return del < 0.000001;
24#define CHECK(point,type) \
27 assert(p00.x() == 0 && p00.y() == 0 && p00.z() == 0); \
31 point p02(4.,5.,6.); \
32 assert(p01.x() == 1 && p01.y() == 2 && p01.z() == 3); \
33 assert(p02.x() == 4 && p02.y() == 5 && p02.z() == 6); \
36 float farray[] = {1,2,3}; \
37 type darray[] = {4,5,6}; \
38 point p03(farray); assert(p03 == point(1,2,3)); \
39 point p04(darray); assert(p04 == point(4,5,6)); \
42 const point p05(1,2,3); \
43 const type * a = p05; \
44 assert(a[0] == 1 && a[1] == 2 && a[2] == 3); \
47 assert(a[0] == 4 && a[1] == 5 && a[2] == 6); \
51 b[2] = 9; assert(p06 == point(7,8,9)); \
54 point p10(p01); assert(p10 == point(1,2,3)); \
55 point p11(Point3D <float>(1,2,3)); assert(p11 == point(1,2,3)); \
56 point p12(Vector3D<float>(4,5,6)); assert(p12 == point(4,5,6)); \
57 point p13(Normal3D<float>(7,8,9)); assert(p13 == point(7,8,9)); \
58 point p14(Point3D <type> (1,2,3)); assert(p14 == point(1,2,3)); \
59 point p15(Vector3D<type> (4,5,6)); assert(p15 == point(4,5,6)); \
60 point p16(Normal3D<type> (7,8,9)); assert(p16 == point(7,8,9)); \
64 p20 = Point3D <float>(1,2,3); assert(p20 == point(1,2,3)); \
65 p20 = Vector3D<float>(4,5,6); assert(p20 == point(4,5,6)); \
66 p20 = Normal3D<float>(7,8,9); assert(p20 == point(7,8,9)); \
67 p20 = Point3D <type> (1,2,3); assert(p20 == point(1,2,3)); \
68 p20 = Vector3D<type> (4,5,6); assert(p20 == point(4,5,6)); \
69 p20 = Normal3D<type> (7,8,9); assert(p20 == point(7,8,9)); \
73 p21 += point(1,2,3); assert(p21 == point(2,4,6)); \
74 p21 += Point3D <float>(1,1,1); assert(p21 == point(3,5,7)); \
75 p21 += Vector3D<float>(1,1,1); assert(p21 == point(4,6,8)); \
76 p21 += Normal3D<float>(1,1,1); assert(p21 == point(5,7,9)); \
77 p21 -= point(1,2,3); assert(p21 == point(4,5,6)); \
78 p21 -= Point3D <type>(1,1,1); assert(p21 == point(3,4,5)); \
79 p21 -= Vector3D<type>(1,1,1); assert(p21 == point(2,3,4)); \
80 p21 -= Normal3D<type>(1,1,1); assert(p21 == point(1,2,3)); \
81 p21 *= 2; assert(p21 == point(2,4,6)); \
82 p21 /= 2; assert(p21 == point(1,2,3)); \
83 p21 *= 2.0f; assert(p21 == point(2,4,6)); \
84 p21 /= 2.0f; assert(p21 == point(1,2,3)); \
85 p21 *= 2.0; assert(p21 == point(2,4,6)); \
86 p21 /= 2.0; assert(p21 == point(1,2,3)); \
90 assert(p22(0) == 1 && p22(1) == 2 && p22(2) == 3); \
91 assert(p22[0] == 1 && p22[1] == 2 && p22[2] == 3); \
94 p22(2) = 6; assert(p22 == point(4,5,6)); \
97 p22[2] = 9; assert(p22 == point(7,8,9)); \
103 p30.setZ(3); assert(p30 == point(1,2,3)); \
105 assert(p30.x() == 4 && p30.y() == 5 && p30.z() == 6); \
108 point p40(12,16,1); assert(p40.perp2() == 400); \
109 assert(p40.perp() == 20); \
110 assert(p40.rho() == 20); \
111 p40.setPerp(5); assert(p40 == point(3,4,1)); \
113 p40.setPerp(5); assert(p40 == point(0,0,1)); \
116 point p50(2,3,6); assert(p50.mag2() == 49); \
117 assert(p50.mag() == 7); \
118 assert(p50.r() == 7); \
119 assert(p50.getR() == 7); \
120 point p51(0,0,1); assert(p51.phi() == 0); \
121 point p52(2,4,5); assert(EQUAL(p52.phi() ,std::atan2(2.,1.))); \
122 assert(EQUAL(p52.getPhi() ,std::atan2(2.,1.))); \
123 point p53(0,0,0); assert(p53.theta() == 0); \
124 assert(p53.cosTheta() == 1); \
125 point p54(3,4,10); assert(EQUAL(p54.theta() ,std::atan2(1.,2.))); \
126 assert(EQUAL(p54.getTheta(),std::atan2(1.,2.))); \
127 assert(EQUAL(p54.cosTheta(),std::sqrt(0.8))); \
129 p55.setMag(14); assert(p55 == point(4,6,12)); \
130 p55.setR(7); assert(p55 == point(2,3,6)); \
132 p56.setPhi(CLHEP::pi/6); assert(EQUAL(p56.getPhi(),CLHEP::pi/6)); \
133 assert(EQUAL(p56.mag() ,p55.mag())); \
134 assert(EQUAL(p56.theta() ,p55.theta())); \
136 p57.setTheta(CLHEP::pi/3); assert(EQUAL(p57.cosTheta(),0.5)); \
137 assert(EQUAL(p57.mag() ,p55.mag())); \
138 assert(EQUAL(p57.phi() ,p55.phi())); \
143 p61.setEta(2); assert(EQUAL(p61.pseudoRapidity(),2)); \
144 assert(EQUAL(p61.getEta() ,2)); \
145 assert(EQUAL(p61.eta() ,2)); \
146 assert(EQUAL(p61.mag() ,7)); \
147 assert(EQUAL(p61.phi(),p60.phi())); \
150 point p70(1,2,3); assert(p70.dot(p70) == p70.mag2()); \
151 point p71( 1,2, 3); \
152 point p72(-3,2,-1); assert(p71.cross(p72) == point(-8,-8,8)); \
153 point p73(3,4,0); assert(p73.perp2(point(0,1,0)) == 9); \
154 assert(p73.perp (point(1,0,0)) == 4); \
156 point p75(1,1,0); assert(EQUAL(p74.angle(p75),CLHEP::pi/4)); \
157 assert(EQUAL(p75.angle(p00),CLHEP::pi/2)); \
161 point p81 = p80.unit(); assert(EQUAL(p81.mag() ,1)); \
162 point p82 = p80.orthogonal(); assert(EQUAL(p82.dot(p81),0)); \
165 point p90(2,0.5,std::sqrt(3.)/2); \
166 p90.rotateX(CLHEP::pi/6); assert(p90.x() == 2); \
167 assert(EQUAL(p90.y(),0)); \
168 assert(EQUAL(p90.z(),1)); \
169 point p91(std::sqrt(3.)/2,2,0.5); \
170 p91.rotateY(CLHEP::pi/6); assert(EQUAL(p91.x(),1)); \
171 assert(p91.y() == 2); \
172 assert(EQUAL(p91.z(),0)); \
173 point p92(0.5,std::sqrt(3.)/2,2); \
174 p92.rotateZ(CLHEP::pi/6); assert(EQUAL(p92.x(),0)); \
175 assert(EQUAL(p92.y(),1)); \
176 assert(p92.z() == 2); \
177 point p93(1,1,std::sqrt(2.)); \
178 p93.rotate(CLHEP::pi,Vector3D<float>(-1,-1,std::sqrt(2.))); \
179 assert(EQUAL(p93.x(),-1)); \
180 assert(EQUAL(p93.y(),-1)); \
181 assert(EQUAL(p93.z(),-std::sqrt(2.))); \
184 point p100(1,1,std::sqrt(2.)); \
186 m = Rotate3D(CLHEP::pi,Vector3D<float>(-1,-1,std::sqrt(2.))); \
187 p100.transform(m); assert(EQUAL(p100.x(),-1)); \
188 assert(EQUAL(p100.y(),-1)); \
189 assert(EQUAL(p100.z(),-std::sqrt(2.))); \
194 std::cout << p110 << std::endl; \
197 point p120(-1,-2,-3); \
198 p120 = +p120; assert(p120 == point(-1,-2,-3)); \
199 p120 = -p120; assert(p120 == point(1,2,3)); \
201 p121 = p121 + Point3D <float>(1,1,1); assert(p121 == point(2,3,4));\
202 p121 = p121 + Vector3D<float>(1,1,1); assert(p121 == point(3,4,5));\
203 p121 = p121 + Normal3D<float>(1,1,1); assert(p121 == point(4,5,6));\
204 p121 = p121 - Point3D <type> (1,1,1); assert(p121 == point(3,4,5));\
205 p121 = p121 - Vector3D<type> (1,1,1); assert(p121 == point(2,3,4));\
206 p121 = p121 - Normal3D<type> (1,1,1); assert(p121 == point(1,2,3));\
207 p121 = p121 * 2; assert(p121 == point(2,4,6)); \
208 p121 = p121 / 2; assert(p121 == point(1,2,3)); \
209 p121 = p121 * 2.0f; assert(p121 == point(2,4,6)); \
210 p121 = p121 / 2.0f; assert(p121 == point(1,2,3)); \
211 p121 = p121 * 2.0; assert(p121 == point(2,4,6)); \
212 p121 = p121 / 2.0; assert(p121 == point(1,2,3)); \
213 p121 = 2 * p121; assert(p121 == point(2,4,6)); \
214 p121 = 0.5f * p121; assert(p121 == point(1,2,3)); \
215 p121 = 2.0 * p121; assert(p121 == point(2,4,6)); \
216 assert(p121 * p121 == p121.mag2()); \
217 assert(p121 * Point3D <float>(1,1,1) == 12); \
218 assert(p121 * Vector3D<float>(1,1,1) == 12); \
219 assert(p121 * Normal3D<float>(1,1,1) == 12); \
220 assert(p121 == Point3D <float>(2,4,6)); \
221 assert(p121 == Vector3D<float>(2,4,6)); \
222 assert(p121 == Normal3D<float>(2,4,6)); \
223 assert(p121 != Point3D <type> (3,4,6)); \
224 assert(p121 != Vector3D<type> (2,5,6)); \
225 assert(p121 != Normal3D<type> (2,4,7)); \
#define CHECK(point, type)
bool EQUAL(double a, double b)