14#include "TGLIncludes.h"
103 Int_t zeroMagAxisInd = -1;
104 for (
UInt_t i = 0; i<3; i++) {
110 if (!fixZeroMagAxis && zeroMagAxisInd == -1) {
112 fixZeroMagAxis =
kTRUE;
113 }
else if (fixZeroMagAxis) {
121 if (fixZeroMagAxis) {
203 if (diff.
X() < 0.0 || diff.
Y() < 0.0 || diff.
Z() < 0.0) {
204 Error(
"TGLBoundingBox::SetAligned",
"low/high vertex range error");
224 if (nbPnts < 1 || !pnts) {
233 for (
UInt_t p = 1; p < nbPnts; p++) {
234 for (
UInt_t i = 0; i < 3; i++) {
235 if (pnts[3*p + i] < low[i]) {
236 low[i] = pnts[3*p + i] ;
238 if (pnts[3*p + i] > high[i]) {
239 high[i] = pnts[3*p + i] ;
289 Scale(factor, factor, factor);
316 fVertex[0] += -xOffset - yOffset - zOffset;
317 fVertex[1] += xOffset - yOffset - zOffset;
318 fVertex[2] += xOffset + yOffset - zOffset;
319 fVertex[3] += -xOffset + yOffset - zOffset;
321 fVertex[4] += -xOffset - yOffset + zOffset;
322 fVertex[5] += xOffset - yOffset + zOffset;
323 fVertex[6] += xOffset + yOffset + zOffset;
324 fVertex[7] += -xOffset + yOffset + zOffset;
372 static std::vector<UInt_t> faceIndexes[
kFaceCount];
406 return faceIndexes[face];
415 assert(planeSet.empty());
459 Int_t verticesInsidePlane = 8;
462 verticesInsidePlane--;
466 if ( verticesInsidePlane == 0 ) {
468 }
else if ( verticesInsidePlane == 8 ) {
500 Double_t aSphereRadius = aHL[0] < aHL[1] ? aHL[0] : aHL[1];
501 if (aHL[2] < aSphereRadius) {
502 aSphereRadius = aHL[2];
509 if (bSphereRadius + parentT.
Mag() < aSphereRadius) {
522 for (i=0 ; i<3 ; i++) {
523 for (k=0; k<3; k++) {
524 roaT[i][k] =
Dot(
a.Axis(i),
b.Axis(k));
526 if (
fabs(roaT[i][k]) < 1
e-14) {
531 Double_t norm =
sqrt(roaT[i][0]*roaT[i][0] + roaT[i][1]*roaT[i][1] + roaT[i][2]*roaT[i][2]);
532 roaT[i][0] /= norm; roaT[i][1] /= norm; roaT[i][2] /= norm;
540 for (i=0; i<3; i++) {
542 rb = bHL[0]*
fabs(roaT[i][0]) + bHL[1]*
fabs(roaT[i][1]) + bHL[2]*
fabs(roaT[i][2]);
546 else if (ra < t + rb)
551 for (k=0; k<3; k++) {
552 ra = aHL[0]*
fabs(roaT[0][k]) + aHL[1]*
fabs(roaT[1][k]) + aHL[2]*
fabs(roaT[2][k]);
554 t =
fabs(aT[0]*roaT[0][k] + aT[1]*roaT[1][k] + aT[2]*roaT[2][k]);
557 else if (ra < t + rb)
564 ra = aHL[1]*
fabs(roaT[2][0]) + aHL[2]*
fabs(roaT[1][0]);
565 rb = bHL[1]*
fabs(roaT[0][2]) + bHL[2]*
fabs(roaT[0][1]);
566 t =
fabs(aT[2]*roaT[1][0] - aT[1]*roaT[2][0]);
569 else if (ra < t + rb)
573 ra = aHL[1]*
fabs(roaT[2][1]) + aHL[2]*
fabs(roaT[1][1]);
574 rb = bHL[0]*
fabs(roaT[0][2]) + bHL[2]*
fabs(roaT[0][0]);
575 t =
fabs(aT[2]*roaT[1][1] - aT[1]*roaT[2][1]);
578 else if (ra < t + rb)
582 ra = aHL[1]*
fabs(roaT[2][2]) + aHL[2]*
fabs(roaT[1][2]);
583 rb = bHL[0]*
fabs(roaT[0][1]) + bHL[1]*
fabs(roaT[0][0]);
584 t =
fabs(aT[2]*roaT[1][2] - aT[1]*roaT[2][2]);
587 else if (ra < t + rb)
591 ra = aHL[0]*
fabs(roaT[2][0]) + aHL[2]*
fabs(roaT[0][0]);
592 rb = bHL[1]*
fabs(roaT[1][2]) + bHL[2]*
fabs(roaT[1][1]);
593 t =
fabs(aT[0]*roaT[2][0] - aT[2]*roaT[0][0]);
596 else if (ra < t + rb)
600 ra = aHL[0]*
fabs(roaT[2][1]) + aHL[2]*
fabs(roaT[0][1]);
601 rb = bHL[0]*
fabs(roaT[1][2]) + bHL[2]*
fabs(roaT[1][0]);
602 t =
fabs(aT[0]*roaT[2][1] - aT[2]*roaT[0][1]);
605 else if (ra < t + rb)
609 ra = aHL[0]*
fabs(roaT[2][2]) + aHL[2]*
fabs(roaT[0][2]);
610 rb = bHL[0]*
fabs(roaT[1][1]) + bHL[1]*
fabs(roaT[1][0]);
611 t =
fabs(aT[0]*roaT[2][2] - aT[2]*roaT[0][2]);
614 else if (ra < t + rb)
618 ra = aHL[0]*
fabs(roaT[1][0]) + aHL[1]*
fabs(roaT[0][0]);
619 rb = bHL[1]*
fabs(roaT[2][2]) + bHL[2]*
fabs(roaT[2][1]);
620 t =
fabs(aT[1]*roaT[0][0] - aT[0]*roaT[1][0]);
623 else if (ra < t + rb)
627 ra = aHL[0]*
fabs(roaT[1][1]) + aHL[1]*
fabs(roaT[0][1]);
628 rb = bHL[0]*
fabs(roaT[2][2]) + bHL[2]*
fabs(roaT[2][0]);
629 t =
fabs(aT[1]*roaT[0][1] - aT[0]*roaT[1][1]);
632 else if (ra < t + rb)
636 ra = aHL[0]*
fabs(roaT[1][2]) + aHL[1]*
fabs(roaT[0][2]);
637 rb = bHL[0]*
fabs(roaT[2][1]) + bHL[1]*
fabs(roaT[2][0]);
638 t =
fabs(aT[1]*roaT[0][2] - aT[0]*roaT[1][2]);
641 else if (ra < t + rb)
656 glVertex3dv(
fVertex[0].CArr());
657 glVertex3dv(
fVertex[1].CArr());
658 glVertex3dv(
fVertex[2].CArr());
659 glVertex3dv(
fVertex[3].CArr());
660 glVertex3dv(
fVertex[7].CArr());
661 glVertex3dv(
fVertex[6].CArr());
662 glVertex3dv(
fVertex[5].CArr());
663 glVertex3dv(
fVertex[4].CArr());
666 glVertex3dv(
fVertex[1].CArr());
667 glVertex3dv(
fVertex[5].CArr());
668 glVertex3dv(
fVertex[2].CArr());
669 glVertex3dv(
fVertex[6].CArr());
670 glVertex3dv(
fVertex[0].CArr());
671 glVertex3dv(
fVertex[3].CArr());
672 glVertex3dv(
fVertex[4].CArr());
673 glVertex3dv(
fVertex[7].CArr());
690 glVertex3dv(
fVertex[4].CArr());
691 glVertex3dv(
fVertex[7].CArr());
692 glVertex3dv(
fVertex[6].CArr());
693 glVertex3dv(
fVertex[5].CArr());
696 glVertex3dv(
fVertex[0].CArr());
697 glVertex3dv(
fVertex[1].CArr());
698 glVertex3dv(
fVertex[2].CArr());
699 glVertex3dv(
fVertex[3].CArr());
702 glVertex3dv(
fVertex[0].CArr());
703 glVertex3dv(
fVertex[3].CArr());
704 glVertex3dv(
fVertex[7].CArr());
705 glVertex3dv(
fVertex[4].CArr());
708 glVertex3dv(
fVertex[6].CArr());
709 glVertex3dv(
fVertex[2].CArr());
710 glVertex3dv(
fVertex[1].CArr());
711 glVertex3dv(
fVertex[5].CArr());
714 glVertex3dv(
fVertex[3].CArr());
715 glVertex3dv(
fVertex[2].CArr());
716 glVertex3dv(
fVertex[6].CArr());
717 glVertex3dv(
fVertex[7].CArr());
720 glVertex3dv(
fVertex[4].CArr());
721 glVertex3dv(
fVertex[5].CArr());
722 glVertex3dv(
fVertex[1].CArr());
723 glVertex3dv(
fVertex[0].CArr());
779 for (
UInt_t i = 0; i<8; i++) {
780 std::cout <<
"[" << i <<
"] (" <<
fVertex[i].
X() <<
"," <<
fVertex[i].
Y() <<
"," <<
fVertex[i].
Z() <<
")" << std::endl;
784 std::cout <<
"Volume: " <<
Volume() << std::endl;
void Error(const char *location, const char *msgfmt,...)
std::vector< TGLPlane > TGLPlaneSet_t
TGLVector3 Cross(const TGLVector3 &v1, const TGLVector3 &v2)
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Double_t Min(UInt_t index) const
Find minimum vertex value for axis of index X(0), Y(1), Z(2)
Double_t fDiagonal
box volume - cached for speed
TGLPlane GetNearPlane() const
Return the near-plane.
TGLVector3 Extents() const
TGLVertex3 Center() const
void Set(const TGLVertex3 vertex[8])
Set a bounding box from provided 8 vertices.
void SetEmpty()
Set bounding box empty - all vertices at (0,0,0)
void PlaneSet(TGLPlaneSet_t &planeSet) const
Fill out supplied plane set vector with TGLPlane objects representing six faces of box.
const std::vector< UInt_t > & FaceVertices(EFace face) const
return a vector of face vertices y | | |________x / 3----—2 / /| /| z 7----—6 | | 0--—|-1 |/ |/ 4----...
void Transform(const TGLMatrix &matrix)
Transform all vertices with matrix.
TGLVector3 fAxesNorm[3]
box axes in global frame - cached for speed
void MergeAligned(const TGLBoundingBox &other)
Expand current bbox so that it includes other's bbox.
void Translate(const TGLVector3 &offset)
Translate all vertices by offset.
TGLVertex3 MinAAVertex() const
Find minimum vertex values.
TGLBoundingBox()
Construct an empty bounding box.
void Scale(Double_t factor)
Isotropically scale bounding box along it's LOCAL axes, preserving center.
TGLVector3 fAxes[3]
max box diagonal - cached for speed
void SetAligned(const TGLVertex3 &lowVertex, const TGLVertex3 &highVertex)
Set ALIGNED box from two low/high vertices.
TGLVertex3 MaxAAVertex() const
Find maximum vertex values.
void UpdateCache()
normalised box axes in global frame - cached for speed
Double_t Max(UInt_t index) const
Find maximum vertex value for axis of index X(0), Y(1), Z(2)
const TGLVector3 & Axis(UInt_t i, Bool_t normalised=kTRUE) const
void ExpandAligned(const TGLVertex3 &point)
Expand current bbox so that it includes the point.
Double_t fVolume
the 8 bounding box vertices
virtual ~TGLBoundingBox()
Destroy bounding box.
void Dump() const
Output to std::cout the vertices, center and volume of box.
Rgl::EOverlap Overlap(const TGLPlane &plane) const
Find overlap (Inside, Outside, Partial) of plane c.f. bounding box.
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
16 component (4x4) transform matrix - column MAJOR as per GL.
void TransformVertex(TGLVertex3 &vertex) const
Transform passed 'vertex' by this matrix - converts local frame to parent.
3D plane class - of format Ax + By + Cz + D = 0
Double_t DistanceTo(const TGLVertex3 &vertex) const
Distance from plane to vertex.
3 component (x/y/z) vector class.
3 component (x/y/z) vertex class.
void Dump() const
Output vertex component values to std::cout.
void Minimum(const TGLVertex3 &other)
void Maximum(const TGLVertex3 &other)
void Set(Double_t x, Double_t y, Double_t z)
T Mag(const SVector< T, D > &rhs)
Vector magnitude (Euclidian norm) Compute : .
EvaluateInfo init(std::vector< RooRealProxy > parameters, std::vector< ArrayWrapper * > wrappers, std::vector< double * > arrays, size_t begin, size_t batchSize)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)