test_intersection2.cxx
Go to the documentation of this file.
1 #include "WireCellUtil/Point.h"
3 #include "WireCellUtil/Testing.h"
4 
5 #include <iostream>
6 #include <cmath>
7 #include <map>
8 
9 using namespace WireCell;
10 using namespace std;
11 
12 
13 int main()
14 {
15  D3Vector<int> a( 3 , 4 , 5 ) , b ( 4 , 3 , 5 ) , c( -5 , -12 , -13 ) ;
16  cout << "a . b : " << a.dot( b ) << endl ;
17  cout << "a x b : " << a.cross( b ) << endl ;
18  cout << "a . b x c : " << a.triplescal( b , c ) << endl ;
19  cout << "a x b x c : " << a.triplevec( b , c ) << endl ;
20 
21  Ray bounds(Point(0,0,0), Point(1,1,1));
22  Vector direction = Point(1,1,1).norm();
23 
24  for (double x = -1.1; x <= 1; x+=0.5) {
25  for (double y = -1.1; y <= 1; y+=0.5) {
26  for (double z = -1.0; z <= 1; z+=0.5) {
27  Vector point(x,y,z);
28  Ray ray(point, point+direction);
29  Ray hits(Point(-111,-111,-111), Point(-222,-222,-222));
30 
31  int hitmask = box_intersection(bounds, ray, hits);
32  cerr << "RESULT: " << hitmask
33  << " p=" << point
34  << " hits=" << hits << endl;
35  Assert(hitmask >= 0);
36  }
37 
38  }
39  }
40 
41 
42  return 0 ;
43 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
D3Vector< double > Point
A 3D Cartesian point in double precision.
Definition: Point.h:15
STL namespace.
#define Assert
Definition: Testing.h:7
double y
D3Vector norm() const
Return a normalized vector in the direction of this vector.
Definition: D3Vector.h:91
double z
int main()
BoundingBox bounds(int x, int y, int w, int h)
Definition: main.cpp:37
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
Definition: Main.h:22
std::vector< float > Vector
static bool * b
Definition: config.cpp:1043
list x
Definition: train.py:276
int box_intersection(const Ray &bounds, const Ray &ray, Ray &hits)
QTextStream & endl(QTextStream &s)