File indexing completed on 2024-04-06 12:04:15
0001 #include <iostream>
0002 #include "DataFormats/GeometrySurface/interface/TkRotation.h"
0003 #include "DataFormats/GeometrySurface/interface/GloballyPositioned.h"
0004 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
0005
0006 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
0007
0008 #include <cmath>
0009
0010 using namespace std;
0011 template <typename T>
0012 void go() {
0013 typedef TkRotation<T> Rotation;
0014 typedef GloballyPositioned<T> Frame;
0015 typedef typename Frame::PositionType Position;
0016 typedef typename Frame::GlobalVector GlobalVector;
0017 typedef typename Frame::GlobalPoint GlobalPoint;
0018 typedef typename Frame::LocalVector LocalVector;
0019 typedef typename Frame::LocalPoint LocalPoint;
0020
0021 std::cout << "size of Rot " << sizeof(Rotation) << std::endl;
0022 std::cout << "size of Pos " << sizeof(Position) << std::endl;
0023 std::cout << "size of Point " << sizeof(GlobalPoint) << std::endl;
0024 std::cout << "size of Frame " << sizeof(Frame) << std::endl;
0025
0026 double a = 0.01;
0027 double ca = cos(a);
0028 double sa = sin(a);
0029
0030 Rotation r1(ca, sa, 0, -sa, ca, 0, 0, 0, 1);
0031 ;
0032 Frame f1(Position(2, 3, 4), r1);
0033 cout << "f1.position() " << f1.position() << endl;
0034 cout << "f1.rotation() " << endl << f1.rotation() << endl;
0035
0036 Rotation r2(GlobalVector(0, 1, 0), GlobalVector(0, 0, 1));
0037 Frame f2(Position(5, 6, 7), r2);
0038 cout << "f2.position() " << f2.position() << endl;
0039 cout << "f2.rotation() " << endl << f2.rotation() << endl;
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 Rotation r3 = r2 * r1.transposed();
0051
0052 GlobalPoint pos2(f2.position());
0053 LocalPoint lp3 = f1.toLocal(pos2);
0054 Frame f3(GlobalPoint(lp3.basicVector()), r3);
0055 cout << "f3.position() " << f3.position() << endl;
0056 cout << "f3.rotation() " << endl << f3.rotation() << endl;
0057
0058
0059 GlobalPoint gp(11, 22, 33);
0060 LocalPoint p_in1 = f1.toLocal(gp);
0061 typename Frame::ToLocal ff1(f1);
0062 LocalPoint p_in2 = f2.toLocal(gp);
0063 LocalPoint p_in3 = f3.toLocal(GlobalPoint(p_in1.basicVector()));
0064 cout << "p_in1 " << p_in1 << endl;
0065 cout << "p_in1 " << ff1.toLocal(gp) << endl;
0066 cout << "p_in2 " << p_in2 << endl;
0067 cout << "p_in3 " << p_in3 << endl;
0068
0069 LocalPoint p_in1_from3(f3.toGlobal(p_in3).basicVector());
0070 cout << "p_in1_from3 + " << p_in1_from3 << endl;
0071
0072 BoundPlane plane(f2.position(), f2.rotation());
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 }
0087
0088 void cyl() {
0089 using T = float;
0090 typedef TkRotation<T> Rotation;
0091 typedef GloballyPositioned<T> Frame;
0092 typedef typename Frame::PositionType Position;
0093 typedef typename Frame::GlobalVector GlobalVector;
0094 typedef typename Frame::GlobalPoint GlobalPoint;
0095 typedef typename Frame::LocalVector LocalVector;
0096 typedef typename Frame::LocalPoint LocalPoint;
0097
0098
0099 {
0100 std::cout << " Trivial Cylinder" << std::endl;
0101 Rotation ll(GlobalVector(1, 0, 0), GlobalVector(0, 1, 0));
0102 Position p0(0, 0, 0);
0103 Cylinder cyl(5., p0, ll);
0104 Plane t = cyl.fastTangent(GlobalPoint(3., 4., 1.));
0105 std::cout << t.position() << '\n' << t.rotation() << std::endl;
0106 std::cout << t.rotation().x() * cyl.rotation().z().cross((t.position() - cyl.position()).basicVector()).unit()
0107 << std::endl;
0108 }
0109
0110 {
0111 std::cout << " rotated, displaced Cylinder" << std::endl;
0112 Rotation ll(Basic3DVector<T>(1, 1, 1), .3);
0113 Cylinder cyl(5.f, Position(2, -1, 3), ll);
0114 Plane t = cyl.fastTangent(LocalPoint(3., 4., 1.));
0115 std::cout << t.position() << '\n' << t.rotation() << std::endl;
0116 std::cout << t.rotation().x() * cyl.rotation().z().cross((t.position() - cyl.position()).basicVector()).unit()
0117 << std::endl;
0118 }
0119 }
0120
0121 int main() {
0122 go<float>();
0123 cyl();
0124 std::cout << std::endl;
0125 go<double>();
0126 }