22 int main(
int argc,
char**argv)
33 JParser<> zap(
"Example program to test intersection of straight line with cylinder.");
42 catch(
const exception &error) {
43 FATAL(error.what() << endl);
46 gRandom->SetSeed(seed);
51 const JCylinder3D cylinder(JCircle2D(JVector2D(0.0,0.0), 2.0), -1.0, +1.0);
54 int number_of_errors = 0;
55 int number_of_events = 0;
57 for (
int i = 0; i != numberOfEvents; ++i) {
61 const double x = gRandom->Uniform(-1.0, +1.0);
62 const double y = gRandom->Uniform(-1.0, +1.0);
63 const double z = gRandom->Uniform(-1.0, +1.0);
65 const double dx = gRandom->Uniform(-1.0, +1.0);
66 const double dy = gRandom->Uniform(-1.0, +1.0);
67 const double dz = gRandom->Uniform(-1.0, +1.0);
69 JAxis3D axis(JVector3D(x, y, z), JVersor3D(dx, dy, dz));
74 make_pair(intersection.first - 1*precision,
false),
75 make_pair(2*precision,
true),
76 make_pair(intersection.second - intersection.first - 2*precision,
true),
77 make_pair(2*precision,
false)
84 const int N =
sizeof(path)/
sizeof(path[0]);
88 for (
int i = 0; i != N; ++i) {
90 axis.move(path[i].first);
92 if ((
getDistance(cylinder, axis.getPosition()) < 1e-3*precision) != path[i].second) {
96 pos[i] = axis.getPosition();
101 for (
int i = 0; i != N; ++i) {
102 cout << endl <<
"point[" << noshowpos << setw(1) << i <<
"] = "
103 << showpos <<
FIXED(9,5) << pos[i].getX() <<
' '
104 << showpos <<
FIXED(9,5) << pos[i].getY() <<
' '
105 << showpos <<
FIXED(9,5) << pos[i].getZ() <<
' '
106 << cylinder.getDistance(pos[i]) <<
' '
107 << (cylinder.getDistance(pos[i]) < 1e-3*precision ?
"in" :
"out") << endl;
117 NOTICE(
"Number of errors: " << number_of_errors <<
" out of " << number_of_events <<
" events." << endl);
119 ASSERT(number_of_events > 0);
120 ASSERT(number_of_errors == 0);
Utility class to parse command line options.
Auxiliary data structure for floating point format specification.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
I/O formatting auxiliaries.
#define ASSERT(A)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Utility class to parse command line options.
#define DEBUG(A)
Message macros.
int main(int argc, char *argv[])