5 #ifndef _TINYHEPTRANSFORM_H_ 6 #define _TINYHEPTRANSFORM_H_ 51 #include "GeoModelKernel/GeoDefinitions.h" 65 virtual operator ::Transform3D()
const = 0;
74 virtual operator ::Transform3D()
const {
75 return ::HepReflectX3D();
84 virtual operator ::Transform3D()
const {
85 return ::HepReflectY3D();
94 virtual operator ::Transform3D()
const {
95 return ::HepReflectZ3D();
107 virtual operator ::Transform3D()
const {
108 return ::HepTranslateX3D(_a);
124 virtual operator ::Transform3D()
const {
125 return ::HepTranslateY3D(_a);
141 virtual operator ::Transform3D()
const {
142 return ::HepTranslateZ3D(_a);
158 virtual operator ::Transform3D()
const {
159 return ::HepScaleX3D(_a);
175 virtual operator ::Transform3D()
const {
176 return ::HepScaleY3D(_a);
192 virtual operator ::Transform3D()
const {
193 return ::HepScaleZ3D(_a);
210 virtual operator ::Transform3D()
const {
211 return ::HepRotateX3D(_a);
227 virtual operator ::Transform3D()
const {
228 return ::HepRotateY3D(_a);
244 virtual operator ::Transform3D()
const {
245 return ::HepRotateZ3D(_a);
263 m.getAngleAxis(angle, axis);
265 ax=axis.x(); ay = axis.y(); az=axis.z();
269 inline HepRotate3D(
double a,
const Vector3D<double> & v) {
272 ax=axis.x(); ay=axis.y(); az=axis.z();
277 const Vector3D & p2) {
279 const Rotation3D & m = tmp.rotation();
282 m.getAngleAxis(angle, axis);
284 ax=axis.x(); ay = axis.y(); az=axis.z();
288 const Vector3D & fr2,
289 const Vector3D & to1,
290 const Vector3D & to2) {
292 const Rotation3D & m = tmp.rotation();
295 m.getAngleAxis(angle, axis);
297 ax=axis.x(); ay = axis.y(); az=axis.z();
300 virtual operator ::Transform3D()
const {
301 return ::HepRotate3D(sqrt(ax*ax+ay*ay+az*az), Vector3D<double> (ax,ay,az));
314 ax(v.x()),ay(v.y()), az(v.z()){}
317 ax(dx),ay(dy),az(dz) {}
319 virtual operator ::Transform3D()
const {
320 return ::HepTranslate3D(ax,ay,az);
334 inline HepScale3D (
double sx,
double sy,
double sz):
335 ax(sx),ay(sy),az(sz) {}
337 virtual operator ::Transform3D()
const {
338 return ::HepScale3D(ax,ay,az);
349 inline HepReflect3D(
double a,
double b,
double c,
double d) {
350 double mag = sqrt(a*a+b*b+c*c);
359 const Vector3D & point) {
360 Normal3D<double> nNorm=normal;
362 double d = nNorm*point;
366 virtual operator ::Transform3D()
const {
367 double mag = sqrt(ax*ax+ay*ay+az*az);
368 return ::HepReflect3D(ax/mag,ay/mag,az/mag ,mag);
381 tx(0),ty(0), tz(0), rx(0), ry(0), rz(0) {}
387 Translate3D translate;
389 source.getDecomposition(scale, rotate, translate);
390 const double EPS=5E-5;
391 if (fabs(scale.xx()-1.0)>EPS || fabs(scale.yy()-1.0)>EPS || fabs(scale.zz()-1.0)>EPS) {
393 throw std::range_error(
"tiny::HepProperTransform3D detects an improper transformation (scaling or reflection)");
397 Rotation3D rotation( HepRep3x3(rotate.xx(), rotate.xy(), rotate.xz(),
398 rotate.yx(), rotate.yy(), rotate.yz(),
399 rotate.zx(), rotate.zy(), rotate.zz()));
401 rotation.getAngleAxis(angle, axis);
403 rx=axis.x(); ry = axis.y(); rz=axis.z();
414 Translate3D translate;
416 source.getDecomposition(scale, rotate, translate);
417 const double EPS=5E-5;
418 if (fabs(scale.xx()-1.0)>EPS || fabs(scale.yy()-1.0)>EPS || fabs(scale.zz()-1.0)>EPS) {
419 throw std::range_error(
"tiny::HepProperTransform3D detects an improper transformation (scaling or reflection)");
423 Rotation3D rotation( HepRep3x3(rotate.xx(), rotate.xy(), rotate.xz(),
424 rotate.yx(), rotate.yy(), rotate.yz(),
425 rotate.zx(), rotate.zy(), rotate.zz()));
427 rotation.getAngleAxis(angle, axis);
429 rx=axis.x(); ry = axis.y(); rz=axis.z();
437 virtual operator ::Transform3D()
const {
438 return ::Transform3D(CLHEP::Rotation3D(Vector3D(rx,ry,rz),sqrt(rx*rx+ry*ry+rz*rz)),
455 tx(0),ty(0), tz(0), rx(0), ry(0), rz(0), sx(0), sy(0), sz(0) {}
461 Translate3D translate;
463 source.getDecomposition(scale, rotate, translate);
466 Rotation3D rotation( HepRep3x3(rotate.xx(), rotate.xy(), rotate.xz(),
467 rotate.yx(), rotate.yy(), rotate.yz(),
468 rotate.zx(), rotate.zy(), rotate.zz()));
470 rotation.getAngleAxis(angle, axis);
472 rx=axis.x(); ry = axis.y(); rz=axis.z();
484 inline const Transform3D & operator = (const ::Transform3D & source) {
487 Translate3D translate;
489 source.getDecomposition(scale, rotate, translate);
492 Rotation3D rotation( HepRep3x3(rotate.xx(), rotate.xy(), rotate.xz(),
493 rotate.yx(), rotate.yy(), rotate.yz(),
494 rotate.zx(), rotate.zy(), rotate.zz()));
496 rotation.getAngleAxis(angle, axis);
498 rx=axis.x(); ry = axis.y(); rz=axis.z();
511 virtual operator ::Transform3D()
const {
512 return ::Transform3D(CLHEP::Rotation3D(Vector3D(rx,ry,rz),sqrt(rx*rx+ry*ry+rz*rz)),
513 Vector3D(tx,ty,tz))*Scale3D(sx,sy,sz);