Logo ROOT  
Reference Guide
TEveProjections.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TError.h"
13 
14 #include "TEveProjections.h"
15 #include "TEveTrans.h"
16 #include "TEveUtil.h"
17 
18 #include <limits>
19 
20 /** \class TEveProjection
21 \ingroup TEve
22 Base-class for non-linear projections.
23 
24 Enables to define an external center of distortion and a scale to
25 fixate a bounding box of a projected point.
26 */
27 
29 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Constructor.
35 
37  fType (kPT_Unknown),
38  fGeoMode (kGM_Unknown),
39  fName (0),
40  fCenter (),
41  fDisplaceOrigin (kFALSE),
42  fUsePreScale (kFALSE),
43  fDistortion (0.0f),
44  fFixR (300), fFixZ (400),
45  fPastFixRFac (0), fPastFixZFac (0),
46  fScaleR (1), fScaleZ (1),
47  fPastFixRScale (1), fPastFixZScale (1),
48  fMaxTrackStep (5)
49 {
50 }
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// Project float array.
54 
56 {
57  ProjectPoint(v[0], v[1], v[2], d);
58 }
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Project double array.
62 /// This is a bit piggish as we convert the doubles to floats and back.
63 
65 {
66  Float_t x = v[0], y = v[1], z = v[2];
67  ProjectPoint(x, y, z, d);
68  v[0] = x; v[1] = y; v[2] = z;
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// Project TEveVector.
73 
75 {
76  ProjectPoint(v.fX, v.fY, v.fZ, d);
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Project float array, converting it to global coordinate system first if
81 /// transformation matrix is set.
82 
84 {
85  v[0] = p[0]; v[1] = p[1]; v[2] = p[2];
86  if (t)
87  {
88  t->MultiplyIP(v);
89  }
90  ProjectPoint(v[0], v[1], v[2], d);
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Project double array, converting it to global coordinate system first if
95 /// transformation matrix is set.
96 /// This is a bit piggish as we convert the doubles to floats and back.
97 
99 {
100  Float_t x, y, z;
101  if (t)
102  {
103  t->Multiply(p, v);
104  x = v[0]; y = v[1]; z = v[2];
105  }
106  else
107  {
108  x = p[0]; y = p[1]; z = p[2];
109  }
110  ProjectPoint(x, y, z, d);
111  v[0] = x; v[1] = y; v[2] = z;
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Project TEveVector, converting it to global coordinate system first if
116 /// transformation matrix is set.
117 
119 {
120  if (t)
121  {
122  t->MultiplyIP(v);
123  }
124  ProjectPoint(v.fX, v.fY, v.fZ, d);
125 }
126 
127 ////////////////////////////////////////////////////////////////////////////////
128 /// Pre-scale single variable with pre-scale entry dim.
129 
131 {
132  if (!fPreScales[dim].empty())
133  {
134  Bool_t invp = kFALSE;
135  if (v < 0) {
136  v = -v;
137  invp = kTRUE;
138  }
139  vPreScale_i i = fPreScales[dim].begin();
140  while (v > i->fMax)
141  ++i;
142  v = i->fOffset + (v - i->fMin)*i->fScale;
143  if (invp)
144  v = -v;
145  }
146 }
147 
148 ////////////////////////////////////////////////////////////////////////////////
149 /// Pre-scale point (x, y) in projected coordinates for 2D projections:
150 /// - RhoZ ~ (rho, z)
151 /// - RPhi ~ (r, phi), scaling phi doesn't make much sense.
152 
154 {
155  PreScaleVariable(0, x);
156  PreScaleVariable(1, y);
157 }
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 /// Pre-scale point (x, y, z) in projected coordinates for 3D projection.
161 
163 {
164  PreScaleVariable(0, x);
165  PreScaleVariable(1, y);
166  PreScaleVariable(2, z);
167 }
168 
169 ////////////////////////////////////////////////////////////////////////////////
170 /// Add new scaling range for given coordinate.
171 /// Arguments:
172 /// - coord 0 ~ x, 1 ~ y, 2 ~ z
173 /// - value value of input coordinate from which to apply this scale;
174 /// - scale the scale to apply from value onwards.
175 ///
176 /// NOTE: If pre-scaling is combined with center-displaced then
177 /// the scale of the central region should be 1. This limitation
178 /// can be removed but will cost CPU.
179 
181 {
182  static const TEveException eh("TEveProjection::AddPreScaleEntry ");
183 
184  if (coord < 0 || coord > 2)
185  throw (eh + "coordinate out of range.");
186 
187  const Float_t infty = std::numeric_limits<Float_t>::infinity();
188 
189  vPreScale_t& vec = fPreScales[coord];
190 
191  if (vec.empty())
192  {
193  if (value == 0)
194  {
195  vec.push_back(PreScaleEntry_t(0, infty, 0, scale));
196  }
197  else
198  {
199  vec.push_back(PreScaleEntry_t(0, value, 0, 1));
200  vec.push_back(PreScaleEntry_t(value, infty, value, scale));
201  }
202  }
203  else
204  {
205  PreScaleEntry_t& prev = vec.back();
206  if (value <= prev.fMin)
207  throw (eh + "minimum value not larger than previous one.");
208 
209  prev.fMax = value;
210  Float_t offset = prev.fOffset + (prev.fMax - prev.fMin)*prev.fScale;
211  vec.push_back(PreScaleEntry_t(value, infty, offset, scale));
212  }
213 }
214 
215 ////////////////////////////////////////////////////////////////////////////////
216 /// Change scale for given entry and coordinate.
217 ///
218 /// NOTE: If the first entry you created used other value than 0,
219 /// one entry (covering range from 0 to this value) was created
220 /// automatically.
221 
223  Float_t new_scale)
224 {
225  static const TEveException eh("TEveProjection::ChangePreScaleEntry ");
226 
227  if (coord < 0 || coord > 2)
228  throw (eh + "coordinate out of range.");
229 
230  vPreScale_t& vec = fPreScales[coord];
231  Int_t vs = vec.size();
232  if (entry < 0 || entry >= vs)
233  throw (eh + "entry out of range.");
234 
235  vec[entry].fScale = new_scale;
236  Int_t i0 = entry, i1 = entry + 1;
237  while (i1 < vs)
238  {
239  PreScaleEntry_t e0 = vec[i0];
240  vec[i1].fOffset = e0.fOffset + (e0.fMax - e0.fMin)*e0.fScale;
241  i0 = i1++;
242  }
243 }
244 
245 ////////////////////////////////////////////////////////////////////////////////
246 /// Clear all pre-scaling information.
247 
249 {
250  fPreScales[0].clear();
251  fPreScales[1].clear();
252  fPreScales[2].clear();
253 }
254 
255 ////////////////////////////////////////////////////////////////////////////////
256 /// Set distortion.
257 
259 {
260  fDistortion = d;
261  fScaleR = 1.0f + fFixR*fDistortion;
262  fScaleZ = 1.0f + fFixZ*fDistortion;
265 }
266 
267 ////////////////////////////////////////////////////////////////////////////////
268 /// Set fixed radius.
269 
271 {
272  fFixR = r;
273  fScaleR = 1 + fFixR*fDistortion;
275 }
276 
277 ////////////////////////////////////////////////////////////////////////////////
278 /// Set fixed radius.
279 
281 {
282  fFixZ = z;
283  fScaleZ = 1 + fFixZ*fDistortion;
285 }
286 
287 ////////////////////////////////////////////////////////////////////////////////
288 /// Set 2's-exponent for relative scaling beyond FixR.
289 
291 {
292  fPastFixRFac = x;
294 }
295 
296 ////////////////////////////////////////////////////////////////////////////////
297 /// Get projected center.
298 
300 {
301  static TEveVector zero;
302 
303  if (fDisplaceOrigin)
304  return zero.Arr();
305  else
306  return fCenter.Arr();
307 }
308 
309 ////////////////////////////////////////////////////////////////////////////////
310 /// Set flag to displace for center.
311 /// This options is useful if want to have projected center
312 /// at (0, 0) position in projected coordinates and want to dismiss
313 /// gap around projected center in RhoZ projection.
314 
316 {
317  fDisplaceOrigin = x;
318  // update projected center
320 }
321 
322 ////////////////////////////////////////////////////////////////////////////////
323 /// Set 2's-exponent for relative scaling beyond FixZ.
324 
326 {
327  fPastFixZFac = x;
329 }
330 
331 ////////////////////////////////////////////////////////////////////////////////
332 /// Find break-point on both sides of the discontinuity.
333 /// They still need to be projected after the call.
334 /// This is an obsolete version of the method that required manual
335 /// specification of precision -- this lead to (infrequent) infinite loops.
336 
338 {
339  static Bool_t warnedp = kFALSE;
340 
341  if (!warnedp)
342  {
343  Warning("BisectBreakPoint", "call with eps_sqr argument is obsolete - please use the new signature.");
344  warnedp = kTRUE;
345  }
346 
347  BisectBreakPoint(vL, vR, kFALSE);
348 }
349 
350 ////////////////////////////////////////////////////////////////////////////////
351 /// Find break-point on both sides of the discontinuity.
352 /// If project_result is true, the resulting break points will be projected
353 /// with given depth value.
354 
356  Bool_t project_result, Float_t depth)
357 {
358  TEveVector vM, vLP, vMP;
359  Int_t n_loops = TMath::CeilNint(TMath::Log2(1e12 * (vL-vR).Mag2() / (0.5f*(vL+vR)).Mag2()) / 2);
360  while (--n_loops >= 0)
361  {
362  vM.Mult(vL + vR, 0.5f);
363  vLP.Set(vL); ProjectPoint(vLP.fX, vLP.fY, vLP.fZ, 0);
364  vMP.Set(vM); ProjectPoint(vMP.fX, vMP.fY, vMP.fZ, 0);
365 
366  if (IsOnSubSpaceBoundrary(vMP))
367  {
368  vL.Set(vM);
369  vR.Set(vM);
370  break;
371  }
372 
373  if (AcceptSegment(vLP, vMP, 0.0f))
374  {
375  vL.Set(vM);
376  }
377  else
378  {
379  vR.Set(vM);
380  }
381  }
382 
383  if (project_result)
384  {
385  ProjectVector(vL, depth);
386  ProjectVector(vR, depth);
387  }
388 }
389 
390 ////////////////////////////////////////////////////////////////////////////////
391 /// Method previously used by TEveProjectionAxesGL. Now obsolete.
392 
394 {
395  ::Warning("TEveProjection::GetLimits", "method is obsolete");
396 
397  return 0;
398 }
399 
400 ////////////////////////////////////////////////////////////////////////////////
401 /// Get vector for axis in a projected space.
402 
404 {
405  for (Int_t i=0; i<3; i++)
406  {
407  vec[i] = (i==screenAxis) ? 1.0f : 0.0f;
408  }
409 }
410 
411 ////////////////////////////////////////////////////////////////////////////////
412 /// Get center ortogonal to given axis index.
413 
415 {
416  TEveVector dirVec;
417  SetDirectionalVector(i, dirVec);
418 
419  TEveVector dirCenter;
420  dirCenter.Mult(dirVec, fCenter.Dot(dirVec));
421  centerOO = fCenter - dirCenter;
422 
423 
424  return centerOO;
425 }
426 
427 ////////////////////////////////////////////////////////////////////////////////
428 /// Inverse projection.
429 
431 {
432  static const TEveException eH("TEveProjection::GetValForScreenPos ");
433 
434  static const int kMaxSteps = 5000;
435  static const int kMaxVal = 10;
436 
437  Float_t xL, xM, xR;
438  TEveVector vec;
439 
440  TEveVector dirVec;
441  SetDirectionalVector(axisIdx, dirVec);
442 
443  TEveVector zero;
444  if (fDisplaceOrigin) zero = fCenter;
445 
446  TEveVector zeroProjected = zero;
447  ProjectVector(zeroProjected, 0.f);
448 
449  // search from -/+ infinity according to sign of screen value
450  if (sv > zeroProjected[axisIdx])
451  {
452  xL = 0;
453  xR = kMaxVal;
454 
455  int cnt = 0;
456  while (cnt < kMaxSteps)
457  {
458  vec.Mult(dirVec, xR);
459  if (fDisplaceOrigin) vec += fCenter;
460 
461  ProjectVector(vec, 0);
462  if (vec[axisIdx] >= sv) break;
463  xL = xR; xR *= 2;
464 
465  if (++cnt >= kMaxSteps)
466  throw eH + Form("positive projected %f, value %f,xL, xR ( %f, %f)\n", vec[axisIdx], sv, xL, xR);
467  }
468  }
469  else if (sv < zeroProjected[axisIdx])
470  {
471  xR = 0;
472  xL = -kMaxVal;
473 
474  int cnt = 0;
475  while (cnt < kMaxSteps)
476  {
477  vec.Mult(dirVec, xL);
478  if (fDisplaceOrigin) vec += fCenter;
479 
480  ProjectVector(vec, 0);
481  if (vec[axisIdx] <= sv) break;
482  xR = xL; xL *= 2;
483  if (++cnt >= kMaxSteps)
484  throw eH + Form("negative projected %f, value %f,xL, xR ( %f, %f)\n", vec[axisIdx], sv, xL, xR);
485  }
486  }
487  else
488  {
489  return 0.0f;
490  }
491 
492  // printf("search for value %f in rng[%f, %f] \n", sv, xL, xR);
493  int cnt = 0;
494  do
495  {
496  //printf("search value with bisection xL=%f, xR=%f; vec[axisIdx]=%f, sv=%f\n", xL, xR, vec[axisIdx], sv);
497  xM = 0.5f * (xL + xR);
498  vec.Mult(dirVec, xM);
499  if (fDisplaceOrigin) vec += fCenter;
500  ProjectVector(vec, 0);
501  if (vec[axisIdx] > sv)
502  xR = xM;
503  else
504  xL = xM;
505  if (++cnt >= kMaxSteps)
506  throw eH + Form("can't converge %f %f, l/r %f/%f, idx=%d\n", vec[axisIdx], sv, xL, xR, axisIdx);
507 
508  } while (TMath::Abs(vec[axisIdx] - sv) >= fgEps);
509 
510 
511  return xM;
512 }
513 
514 ////////////////////////////////////////////////////////////////////////////////
515 /// Project point on given axis and return projected value.
516 
518 {
519  TEveVector pos = dirVec*x;
520 
521  if (fDisplaceOrigin)
522  pos += fCenter;
523 
524  ProjectVector(pos , 0.f);
525 
526  return pos[i];
527 }
528 
529 ////////////////////////////////////////////////////////////////////////////////
530 /// Project point on given axis and return projected value.
531 
533 {
534  TEveVector dirVec;
535  SetDirectionalVector(i, dirVec);
536  TEveVector oCenter;
537  // GetOrthogonalCenter(i, oCenter);
538  return GetScreenVal(i, x, dirVec, oCenter);
539 }
540 
541 /** \class TEveRhoZProjection
542 \ingroup TEve
543 Transformation from 3D to 2D. X axis represent Z coordinate. Y axis have value of
544 radius with a sign of Y coordinate.
545 */
546 
548 
549 ////////////////////////////////////////////////////////////////////////////////
550 /// Constructor.
551 
554 {
555  fType = kPT_RhoZ;
556  fName = "RhoZ";
557 }
558 
559 ////////////////////////////////////////////////////////////////////////////////
560 /// Project point.
561 
563  Float_t d, EPProc_e proc)
564 {
565  using namespace TMath;
566 
567  if (fDisplaceOrigin) {
568  x -= fCenter.fX;
569  y -= fCenter.fY;
570  z -= fCenter.fZ;
571  }
572  if (proc == kPP_Plane || proc == kPP_Full)
573  {
574  // project
575  y = Sign((Float_t)Sqrt(x*x+y*y), y);
576  x = z;
577  }
578  if (proc == kPP_Distort || proc == kPP_Full)
579  {
580  if (fUsePreScale)
581  PreScalePoint(y, x);
582 
583  // distort
584 
585  if (!fDisplaceOrigin) {
586  x -= fProjectedCenter.fX;
587  y -= fProjectedCenter.fY;
588  }
589 
590  if (x > fFixZ)
591  x = fFixZ + fPastFixZScale*(x - fFixZ);
592  else if (x < -fFixZ)
593  x = -fFixZ + fPastFixZScale*(x + fFixZ);
594  else
595  x = x * fScaleZ / (1.0f + Abs(x)*fDistortion);
596 
597  if (y > fFixR)
598  y = fFixR + fPastFixRScale*(y - fFixR);
599  else if (y < -fFixR)
600  y = -fFixR + fPastFixRScale*(y + fFixR);
601  else
602  y = y * fScaleR / (1.0f + Abs(y)*fDistortion);
603 
604  if (!fDisplaceOrigin) {
605  x += fProjectedCenter.fX;
606  y += fProjectedCenter.fY;
607  }
608  }
609  z = d;
610 }
611 
612 ////////////////////////////////////////////////////////////////////////////////
613 /// Set center of distortion (virtual method).
614 
616 {
617  fCenter = v;
618 
619  if (fDisplaceOrigin)
620  {
621  fProjectedCenter.Set(0.f, 0.f, 0.f);
622  }
623  else
624  {
625  Float_t r = TMath::Sqrt(v.fX*v.fX + v.fY*v.fY);
628  fProjectedCenter.fZ = 0;
629  }
630 }
631 
632 ////////////////////////////////////////////////////////////////////////////////
633 /// Get direction in the unprojected space for axis index in the
634 /// projected space.
635 /// This is virtual method from base-class TEveProjection.
636 
638 {
639  if (screenAxis == 0)
640  vec.Set(0.0f, 0.0f, 1.0f);
641  else if (screenAxis == 1)
642  vec.Set(0.0f, 1.0f, 0.0f);
643 
644 }
645 
646 ////////////////////////////////////////////////////////////////////////////////
647 /// Check if segment of two projected points is valid.
648 ///
649 /// Move slightly one of the points if by shifting it by no more than
650 /// tolerance the segment can become acceptable.
651 
653  Float_t tolerance) const
654 {
656  Bool_t val = kTRUE;
657  if ((v1.fY < a && v2.fY > a) || (v1.fY > a && v2.fY < a))
658  {
659  val = kFALSE;
660  if (tolerance > 0)
661  {
662  Float_t a1 = TMath::Abs(v1.fY - a), a2 = TMath::Abs(v2.fY - a);
663  if (a1 < a2)
664  {
665  if (a1 < tolerance) { v1.fY = a; val = kTRUE; }
666  }
667  else
668  {
669  if (a2 < tolerance) { v2.fY = a; val = kTRUE; }
670  }
671  }
672  }
673  return val;
674 }
675 
676 ////////////////////////////////////////////////////////////////////////////////
677 /// Return sub-space id for the point.
678 /// 0 - upper half-space
679 /// 1 - lower half-space
680 
682 {
683  return v.fY > fProjectedCenter.fY ? 0 : 1;
684 }
685 
686 ////////////////////////////////////////////////////////////////////////////////
687 /// Checks if point is on sub-space boundary.
688 
690 {
691  return v.fY == fProjectedCenter.fY;
692 }
693 
694 /** \class TEveRPhiProjection
695 \ingroup TEve
696 XY projection with distortion around given center.
697 */
698 
700 
701 ////////////////////////////////////////////////////////////////////////////////
702 /// Constructor.
703 
706 {
707  fType = kPT_RPhi;
709  fName = "RhoPhi";
710 }
711 
712 ////////////////////////////////////////////////////////////////////////////////
713 /// Project point.
714 
716  Float_t d, EPProc_e proc)
717 {
718  using namespace TMath;
719 
720  if (fDisplaceOrigin)
721  {
722  x -= fCenter.fX;
723  y -= fCenter.fY;
724  z -= fCenter.fZ;
725  }
726 
727  if (proc != kPP_Plane)
728  {
729  Float_t r, phi;
730  if (fUsePreScale)
731  {
732  r = Sqrt(x*x + y*y);
733  phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
734  PreScalePoint(r, phi);
735  x = r*Cos(phi);
736  y = r*Sin(phi);
737  }
738 
739  if (!fDisplaceOrigin)
740  {
741  x -= fCenter.fX;
742  y -= fCenter.fY;
743  }
744 
745  r = Sqrt(x*x + y*y);
746  phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
747 
748  if (r > fFixR)
749  r = fFixR + fPastFixRScale*(r - fFixR);
750  else if (r < -fFixR)
751  r = -fFixR + fPastFixRScale*(r + fFixR);
752  else
753  r = r * fScaleR / (1.0f + r*fDistortion);
754 
755  x = r*Cos(phi);
756  y = r*Sin(phi);
757 
758  if (!fDisplaceOrigin)
759  {
760  x += fCenter.fX;
761  y += fCenter.fY;
762  }
763  }
764 
765  z = d;
766 }
767 
768 /** \class TEveXZProjection
769 \ingroup TEve
770 XZ projection with distortion around given center.
771 */
772 
774 
775 ////////////////////////////////////////////////////////////////////////////////
776 /// Constructor.
777 
780 {
781  fType = kPT_XZ;
783  fName = "XZ";
784 }
785 
786 ////////////////////////////////////////////////////////////////////////////////
787 /// Project point.
788 
790  Float_t d, EPProc_e proc)
791 {
792  using namespace TMath;
793 
794  if (fDisplaceOrigin)
795  {
796  x -= fCenter.fX;
797  y -= fCenter.fY;
798  z -= fCenter.fZ;
799  }
800 
801  // projection
802  if (proc == kPP_Plane || proc == kPP_Full)
803  {
804  y = z;
805  z = d;
806  }
807  if (proc != kPP_Distort || proc == kPP_Full)
808  {
809  Float_t r, phi;
810  if (fUsePreScale)
811  {
812  r = Sqrt(x*x + y*y);
813  phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
814  PreScalePoint(r, phi);
815  x = r*Cos(phi);
816  y = r*Sin(phi);
817  }
818 
819  if (!fDisplaceOrigin)
820  {
821  x -= fProjectedCenter.fX;
822  y -= fProjectedCenter.fY;
823  }
824 
825  r = Sqrt(x*x + y*y);
826  phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
827 
828  if (r > fFixR)
829  r = fFixR + fPastFixRScale*(r - fFixR);
830  else if (r < -fFixR)
831  r = -fFixR + fPastFixRScale*(r + fFixR);
832  else
833  r = r * fScaleR / (1.0f + r*fDistortion);
834 
835  x = r*Cos(phi);
836  y = r*Sin(phi);
837 
838  if (!fDisplaceOrigin)
839  {
840  x += fProjectedCenter.fX;
841  y += fProjectedCenter.fY;
842  }
843  }
844 }
845 
846 ////////////////////////////////////////////////////////////////////////////////
847 /// Set center of distortion (virtual method).
848 
850 {
851  fCenter = v;
852 
853  if (fDisplaceOrigin)
854  {
855  fProjectedCenter.Set(0.f, 0.f, 0.f);
856  }
857  else
858  {
861  fProjectedCenter.fZ = 0;
862  }
863 }
864 
865 ////////////////////////////////////////////////////////////////////////////////
866 /// Get direction in the unprojected space for axis index in the
867 /// projected space.
868 /// This is virtual method from base-class TEveProjection.
869 
871 {
872  if (screenAxis == 0)
873  vec.Set(1.0f, 0.0f, 0.0f);
874  else if (screenAxis == 1)
875  vec.Set(0.0f, 0.0f, 1.0f);
876 }
877 
878 
879 /** \class TEve3DProjection
880 \ingroup TEve
881 3D scaling projection. One has to use pre-scaling to make any ise of this.
882 */
883 
885 
886 ////////////////////////////////////////////////////////////////////////////////
887 /// Constructor.
888 
891 {
892  fType = kPT_3D;
894  fName = "3D";
895 }
896 
897 ////////////////////////////////////////////////////////////////////////////////
898 /// Project point.
899 
901  Float_t /*d*/, EPProc_e proc)
902 {
903  using namespace TMath;
904 
905  if (proc != kPP_Plane)
906  {
907  if (fUsePreScale)
908  {
909  PreScalePoint(x, y, z);
910  }
911 
912  x -= fCenter.fX;
913  y -= fCenter.fY;
914  z -= fCenter.fZ;
915  }
916 }
TEveProjection::AddPreScaleEntry
void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale)
Add new scaling range for given coordinate.
Definition: TEveProjections.cxx:180
TEveProjection::EPProc_e
EPProc_e
Definition: TEveProjections.h:30
TEveRhoZProjection::fProjectedCenter
TEveVector fProjectedCenter
Definition: TEveProjections.h:162
ROOT::v5::TFastFun::Sqrt
Double_t Sqrt(Double_t x)
Definition: TFormulaPrimitive_v5.cxx:289
TEveProjection::kPT_RPhi
@ kPT_RPhi
Definition: TEveProjections.h:29
TEveProjection::GetLimit
Float_t GetLimit(Int_t i, Bool_t pos)
Method previously used by TEveProjectionAxesGL. Now obsolete.
Definition: TEveProjections.cxx:393
TEveProjection::kPT_RhoZ
@ kPT_RhoZ
Definition: TEveProjections.h:29
TEveProjection::fPastFixZFac
Float_t fPastFixZFac
Definition: TEveProjections.h:68
TEveRPhiProjection::TEveRPhiProjection
TEveRPhiProjection()
Constructor.
Definition: TEveProjections.cxx:704
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TEveTrans
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:27
TEveProjection::PreScaleEntry_t
Definition: TEveProjections.h:34
TEveVectorT::fZ
TT fZ
Definition: TEveVector.h:30
TMath::ATan2
Double_t ATan2(Double_t y, Double_t x)
Definition: TMath.h:679
TEveProjection::fUsePreScale
Bool_t fUsePreScale
Definition: TEveProjections.h:61
Warning
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition: TError.cxx:231
TEveProjection::ClearPreScales
void ClearPreScales()
Clear all pre-scaling information.
Definition: TEveProjections.cxx:248
TMath::Cos
Double_t Cos(Double_t)
Definition: TMath.h:643
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
TEveProjection
Base-class for non-linear projections.
Definition: TEveProjections.h:27
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TEveXZProjection::ProjectPoint
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
Definition: TEveProjections.cxx:789
TEveProjection::kPT_3D
@ kPT_3D
Definition: TEveProjections.h:29
TEveProjection::SetDirectionalVector
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get vector for axis in a projected space.
Definition: TEveProjections.cxx:403
TEveProjection::fName
TString fName
Definition: TEveProjections.h:55
TEveProjection::fScaleR
Float_t fScaleR
Definition: TEveProjections.h:69
TMath::Sqrt
Double_t Sqrt(Double_t x)
Definition: TMath.h:691
TEveProjections.h
TEveProjection::GetScreenVal
virtual Float_t GetScreenVal(Int_t ax, Float_t value)
Project point on given axis and return projected value.
Definition: TEveProjections.cxx:532
TMath::CeilNint
Int_t CeilNint(Double_t x)
Definition: TMath.h:699
Float_t
float Float_t
Definition: RtypesCore.h:57
TEveProjection::SetPastFixRFac
void SetPastFixRFac(Float_t x)
Set 2's-exponent for relative scaling beyond FixR.
Definition: TEveProjections.cxx:290
TEveProjection::ProjectPointdv
void ProjectPointdv(Double_t *v, Float_t d)
Project double array.
Definition: TEveProjections.cxx:64
TEveProjection::fCenter
TEveVector fCenter
Definition: TEveProjections.h:57
TEveProjection::fFixZ
Float_t fFixZ
Definition: TEveProjections.h:66
TEveProjection::ProjectPoint
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e p=kPP_Full)=0
TEveVectorT::fY
TT fY
Definition: TEveVector.h:30
x
Double_t x[n]
Definition: legend1.C:17
TEveProjection::kGM_Polygons
@ kGM_Polygons
Definition: TEveProjections.h:31
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TEveVectorT::Dot
TT Dot(const TEveVectorT &a) const
Definition: TEveVector.h:168
TEveXZProjection::fProjectedCenter
TEveVector fProjectedCenter
Definition: TEveProjections.h:212
TEve3DProjection
3D scaling projection.
Definition: TEveProjections.h:236
TEveProjection::AcceptSegment
virtual Bool_t AcceptSegment(TEveVector &, TEveVector &, Float_t) const
Definition: TEveProjections.h:133
TEveProjection::ProjectVector
void ProjectVector(TEveVector &v, Float_t d)
Project TEveVector.
Definition: TEveProjections.cxx:74
v
@ v
Definition: rootcling_impl.cxx:3664
TEveProjection::fScaleZ
Float_t fScaleZ
Definition: TEveProjections.h:70
TEveRPhiProjection
XY projection with distortion around given center.
Definition: TEveProjections.h:191
TEveProjection::fDisplaceOrigin
bool fDisplaceOrigin
Definition: TEveProjections.h:59
bool
TEveProjection::kPP_Distort
@ kPP_Distort
Definition: TEveProjections.h:30
TEveProjection::PreScalePoint
void PreScalePoint(Float_t &x, Float_t &y)
Pre-scale point (x, y) in projected coordinates for 2D projections:
Definition: TEveProjections.cxx:153
TEveXZProjection::TEveXZProjection
TEveXZProjection()
Constructor.
Definition: TEveProjections.cxx:778
TEveProjection::vPreScale_i
std::vector< PreScaleEntry_t >::iterator vPreScale_i
Definition: TEveProjections.h:50
TEveRPhiProjection::ProjectPoint
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
Definition: TEveProjections.cxx:715
TEveRhoZProjection::TEveRhoZProjection
TEveRhoZProjection()
Constructor.
Definition: TEveProjections.cxx:552
TEveProjection::TEveProjection
TEveProjection()
Constructor.
Definition: TEveProjections.cxx:36
TEveUtil.h
TEveRhoZProjection::AcceptSegment
virtual Bool_t AcceptSegment(TEveVector &v1, TEveVector &v2, Float_t tolerance) const
Check if segment of two projected points is valid.
Definition: TEveProjections.cxx:652
TEveProjection::SetDisplaceOrigin
void SetDisplaceOrigin(bool)
Set flag to displace for center.
Definition: TEveProjections.cxx:315
TEveProjection::SetFixZ
void SetFixZ(Float_t x)
Set fixed radius.
Definition: TEveProjections.cxx:280
TEveProjection::fType
EPType_e fType
Definition: TEveProjections.h:53
TEveProjection::fgEps
static Float_t fgEps
Definition: TEveProjections.h:148
TEveProjection::fDistortion
Float_t fDistortion
Definition: TEveProjections.h:64
TMath::Log2
Double_t Log2(Double_t x)
Definition: TMath.cxx:101
TEveProjection::kPP_Plane
@ kPP_Plane
Definition: TEveProjections.h:30
TEveProjection::GetProjectedCenter
virtual Float_t * GetProjectedCenter()
Get projected center.
Definition: TEveProjections.cxx:299
TEveProjection::SetCenter
virtual void SetCenter(TEveVector &v)
Definition: TEveProjections.h:98
TEveProjection::vPreScale_t
std::vector< PreScaleEntry_t > vPreScale_t
Definition: TEveProjections.h:49
TEveXZProjection::SetDirectionalVector
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get direction in the unprojected space for axis index in the projected space.
Definition: TEveProjections.cxx:870
TEveProjection::GetValForScreenPos
virtual Float_t GetValForScreenPos(Int_t ax, Float_t value)
Inverse projection.
Definition: TEveProjections.cxx:430
TEve3DProjection::TEve3DProjection
TEve3DProjection()
Constructor.
Definition: TEveProjections.cxx:889
TEveVectorT::Arr
const TT * Arr() const
Definition: TEveVector.h:58
a
auto * a
Definition: textangle.C:12
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TMath::Sign
T1 Sign(T1 a, T2 b)
Definition: TMathBase.h:165
TMath::Power
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:735
TEveProjection::SetDistortion
void SetDistortion(Float_t d)
Set distortion.
Definition: TEveProjections.cxx:258
TMath::Sin
Double_t Sin(Double_t)
Definition: TMath.h:639
TEveVectorT< Float_t >
TEveProjection::SetFixR
void SetFixR(Float_t x)
Set fixed radius.
Definition: TEveProjections.cxx:270
y
Double_t y[n]
Definition: legend1.C:17
TEve3DProjection::ProjectPoint
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
Definition: TEveProjections.cxx:900
TEveTrans.h
TEveProjection::PreScaleEntry_t::fMax
Float_t fMax
Definition: TEveProjections.h:35
TEveRhoZProjection::SetDirectionalVector
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get direction in the unprojected space for axis index in the projected space.
Definition: TEveProjections.cxx:637
TEveProjection::fPastFixRFac
Float_t fPastFixRFac
Definition: TEveProjections.h:67
TEveProjection::fGeoMode
EGeoMode_e fGeoMode
Definition: TEveProjections.h:54
TEveProjection::fgEpsSqr
static Float_t fgEpsSqr
Definition: TEveProjections.h:149
ROOT::Math::Mag2
T Mag2(const SVector< T, D > &rhs)
Vector magnitude square Template to compute .
Definition: Functions.h:230
TEveProjection::fFixR
Float_t fFixR
Definition: TEveProjections.h:65
TEveTrans::Multiply
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
Definition: TEveTrans.cxx:760
TEveVectorT::Mult
TEveVectorT & Mult(const TEveVectorT &a, TT af)
Definition: TEveVector.h:196
TEveProjection::SetPastFixZFac
void SetPastFixZFac(Float_t x)
Set 2's-exponent for relative scaling beyond FixZ.
Definition: TEveProjections.cxx:325
TEveProjection::PreScaleEntry_t::fMin
Float_t fMin
Definition: TEveProjections.h:35
v1
@ v1
Definition: rootcling_impl.cxx:3666
Double_t
double Double_t
Definition: RtypesCore.h:59
TEveProjection::PreScaleEntry_t::fOffset
Float_t fOffset
Definition: TEveProjections.h:36
TEveProjection::IsOnSubSpaceBoundrary
virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector &) const
Definition: TEveProjections.h:135
TEveXZProjection::SetCenter
virtual void SetCenter(TEveVector &v)
Set center of distortion (virtual method).
Definition: TEveProjections.cxx:849
TEveProjection::fPreScales
vPreScale_t fPreScales[3]
Definition: TEveProjections.h:62
vec
Definition: civetweb.c:2228
TEveException
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:102
TEveProjection::PreScaleVariable
void PreScaleVariable(Int_t dim, Float_t &v)
Pre-scale single variable with pre-scale entry dim.
Definition: TEveProjections.cxx:130
TEveVectorT::fX
TT fX
Definition: TEveVector.h:30
v2
@ v2
Definition: rootcling_impl.cxx:3667
TEveProjection::fPastFixRScale
Float_t fPastFixRScale
Definition: TEveProjections.h:71
TEveProjection::kPP_Full
@ kPP_Full
Definition: TEveProjections.h:30
TEveProjection::ProjectPointfv
void ProjectPointfv(Float_t *v, Float_t d)
Project float array.
Definition: TEveProjections.cxx:55
d
#define d(i)
Definition: RSha256.hxx:102
TEveProjection::ChangePreScaleEntry
void ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale)
Change scale for given entry and coordinate.
Definition: TEveProjections.cxx:222
TEveRhoZProjection::SubSpaceId
virtual Int_t SubSpaceId(const TEveVector &v) const
Return sub-space id for the point.
Definition: TEveProjections.cxx:681
TEveXZProjection
XZ projection with distortion around given center.
Definition: TEveProjections.h:210
TEveProjection::BisectBreakPoint
virtual void BisectBreakPoint(TEveVector &vL, TEveVector &vR, Float_t eps_sqr)
Find break-point on both sides of the discontinuity.
Definition: TEveProjections.cxx:337
TEveRhoZProjection::IsOnSubSpaceBoundrary
virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector &v) const
Checks if point is on sub-space boundary.
Definition: TEveProjections.cxx:689
xmlio::cnt
const char * cnt
Definition: TXMLSetup.cxx:75
Float_t
TEveRhoZProjection::SetCenter
virtual void SetCenter(TEveVector &v)
Set center of distortion (virtual method).
Definition: TEveProjections.cxx:615
TEveProjection::GetOrthogonalCenter
TEveVector GetOrthogonalCenter(int idx, TEveVector &out)
Get center ortogonal to given axis index.
Definition: TEveProjections.cxx:414
TEveProjection::kPT_XZ
@ kPT_XZ
Definition: TEveProjections.h:29
TEveTrans::MultiplyIP
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Definition: TEveTrans.cxx:728
TEveRhoZProjection
Transformation from 3D to 2D.
Definition: TEveProjections.h:160
TEveVectorT::Set
void Set(const Float_t *v)
Definition: TEveVector.h:82
TEveProjection::PreScaleEntry_t::fScale
Float_t fScale
Definition: TEveProjections.h:37
TMath
TMath.
Definition: TMathBase.h:35
TEveRhoZProjection::ProjectPoint
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
Definition: TEveProjections.cxx:562
int
TError.h
TEveProjection::fPastFixZScale
Float_t fPastFixZScale
Definition: TEveProjections.h:72
TEveProjection::kGM_Unknown
@ kGM_Unknown
Definition: TEveProjections.h:31