Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
22Base-class for non-linear projections.
23
24Enables to define an external center of distortion and a scale to
25fixate 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{
157}
158
159////////////////////////////////////////////////////////////////////////////////
160/// Pre-scale point (x, y, z) in projected coordinates for 3D projection.
161
163{
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;
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Set fixed radius.
279
281{
282 fFixZ = z;
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{
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;
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);
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);
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);
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
543Transformation from 3D to 2D. X axis represent Z coordinate. Y axis have value of
544radius 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) {
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) {
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);
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
696XY 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
770XZ 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 {
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 {
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 {
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 TEveYZProjection
880\ingroup TEve
881YZ projection with distortion around given center.
882*/
883
885
886////////////////////////////////////////////////////////////////////////////////
887/// Constructor.
888
891{
892 fType = kPT_YZ;
894 fName = "YZ";
895}
896
897////////////////////////////////////////////////////////////////////////////////
898/// Project point.
899
901 Float_t d, EPProc_e proc)
902{
903 using namespace TMath;
904
905 if (fDisplaceOrigin)
906 {
907 x -= fCenter.fX;
908 y -= fCenter.fY;
909 z -= fCenter.fZ;
910 }
911
912 // projection
913 if (proc == kPP_Plane || proc == kPP_Full)
914 {
915 x = y;
916 y = z;
917 z = d;
918 }
919 if (proc != kPP_Distort || proc == kPP_Full)
920 {
921 Float_t r, phi;
922 if (fUsePreScale)
923 {
924 r = Sqrt(x*x + y*y);
925 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
926 PreScalePoint(r, phi);
927 x = r*Cos(phi);
928 y = r*Sin(phi);
929 }
930
931 if (!fDisplaceOrigin)
932 {
935 }
936
937 r = Sqrt(x*x + y*y);
938 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
939
940 if (r > fFixR)
941 r = fFixR + fPastFixRScale*(r - fFixR);
942 else if (r < -fFixR)
943 r = -fFixR + fPastFixRScale*(r + fFixR);
944 else
945 r = r * fScaleR / (1.0f + r*fDistortion);
946
947 x = r*Cos(phi);
948 y = r*Sin(phi);
949
950 if (!fDisplaceOrigin)
951 {
954 }
955 }
956}
957
958////////////////////////////////////////////////////////////////////////////////
959/// Set center of distortion (virtual method).
960
962{
963 fCenter = v;
964
965 if (fDisplaceOrigin)
966 {
967 fProjectedCenter.Set(0.f, 0.f, 0.f);
968 }
969 else
970 {
974 }
975}
976
977////////////////////////////////////////////////////////////////////////////////
978/// Get direction in the unprojected space for axis index in the
979/// projected space.
980/// This is virtual method from base-class TEveProjection.
981
983{
984 if (screenAxis == 0)
985 vec.Set(0.0f, 1.0f, 0.0f);
986 else if (screenAxis == 1)
987 vec.Set(0.0f, 0.0f, 1.0f);
988}
989
990
991/** \class TEveZXProjection
992\ingroup TEve
993ZX projection with distortion around given center.
994*/
995
997
998////////////////////////////////////////////////////////////////////////////////
999/// Constructor.
1000
1003{
1004 fType = kPT_ZX;
1006 fName = "ZX";
1007}
1008
1009////////////////////////////////////////////////////////////////////////////////
1010/// Project point.
1011
1013 Float_t d, EPProc_e proc)
1014{
1015 using namespace TMath;
1016
1017 if (fDisplaceOrigin)
1018 {
1019 x -= fCenter.fX;
1020 y -= fCenter.fY;
1021 z -= fCenter.fZ;
1022 }
1023
1024 // projection
1025 if (proc == kPP_Plane || proc == kPP_Full)
1026 {
1027 y = x;
1028 x = z;
1029 z = d;
1030 }
1031 if (proc != kPP_Distort || proc == kPP_Full)
1032 {
1033 Float_t r, phi;
1034 if (fUsePreScale)
1035 {
1036 r = Sqrt(x*x + y*y);
1037 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
1038 PreScalePoint(r, phi);
1039 x = r*Cos(phi);
1040 y = r*Sin(phi);
1041 }
1042
1043 if (!fDisplaceOrigin)
1044 {
1047 }
1048
1049 r = Sqrt(x*x + y*y);
1050 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
1051
1052 if (r > fFixR)
1053 r = fFixR + fPastFixRScale*(r - fFixR);
1054 else if (r < -fFixR)
1055 r = -fFixR + fPastFixRScale*(r + fFixR);
1056 else
1057 r = r * fScaleR / (1.0f + r*fDistortion);
1058
1059 x = r*Cos(phi);
1060 y = r*Sin(phi);
1061
1062 if (!fDisplaceOrigin)
1063 {
1066 }
1067 }
1068}
1069
1070////////////////////////////////////////////////////////////////////////////////
1071/// Set center of distortion (virtual method).
1072
1074{
1075 fCenter = v;
1076
1077 if (fDisplaceOrigin)
1078 {
1079 fProjectedCenter.Set(0.f, 0.f, 0.f);
1080 }
1081 else
1082 {
1085 fProjectedCenter.fZ = 0;
1086 }
1087}
1088
1089////////////////////////////////////////////////////////////////////////////////
1090/// Get direction in the unprojected space for axis index in the
1091/// projected space.
1092/// This is virtual method from base-class TEveProjection.
1093
1095{
1096 if (screenAxis == 0)
1097 vec.Set(0.0f, 0.0f, 1.0f);
1098 else if (screenAxis == 1)
1099 vec.Set(1.0f, 0.0f, 0.0f);
1100}
1101
1102
1103/** \class TEveZYProjection
1104\ingroup TEve
1105ZY projection with distortion around given center.
1106*/
1107
1109
1110////////////////////////////////////////////////////////////////////////////////
1111/// Constructor.
1112
1115{
1116 fType = kPT_ZY;
1118 fName = "ZY";
1119}
1120
1121////////////////////////////////////////////////////////////////////////////////
1122/// Project point.
1123
1125 Float_t d, EPProc_e proc)
1126{
1127 using namespace TMath;
1128
1129 if (fDisplaceOrigin)
1130 {
1131 x -= fCenter.fX;
1132 y -= fCenter.fY;
1133 z -= fCenter.fZ;
1134 }
1135
1136 // projection
1137 if (proc == kPP_Plane || proc == kPP_Full)
1138 {
1139 x = z;
1140 z = d;
1141 }
1142 if (proc != kPP_Distort || proc == kPP_Full)
1143 {
1144 Float_t r, phi;
1145 if (fUsePreScale)
1146 {
1147 r = Sqrt(x*x + y*y);
1148 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
1149 PreScalePoint(r, phi);
1150 x = r*Cos(phi);
1151 y = r*Sin(phi);
1152 }
1153
1154 if (!fDisplaceOrigin)
1155 {
1158 }
1159
1160 r = Sqrt(x*x + y*y);
1161 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
1162
1163 if (r > fFixR)
1164 r = fFixR + fPastFixRScale*(r - fFixR);
1165 else if (r < -fFixR)
1166 r = -fFixR + fPastFixRScale*(r + fFixR);
1167 else
1168 r = r * fScaleR / (1.0f + r*fDistortion);
1169
1170 x = r*Cos(phi);
1171 y = r*Sin(phi);
1172
1173 if (!fDisplaceOrigin)
1174 {
1177 }
1178 }
1179}
1180
1181////////////////////////////////////////////////////////////////////////////////
1182/// Set center of distortion (virtual method).
1183
1185{
1186 fCenter = v;
1187
1188 if (fDisplaceOrigin)
1189 {
1190 fProjectedCenter.Set(0.f, 0.f, 0.f);
1191 }
1192 else
1193 {
1196 fProjectedCenter.fZ = 0;
1197 }
1198}
1199
1200////////////////////////////////////////////////////////////////////////////////
1201/// Get direction in the unprojected space for axis index in the
1202/// projected space.
1203/// This is virtual method from base-class TEveProjection.
1204
1206{
1207 if (screenAxis == 0)
1208 vec.Set(0.0f, 0.0f, 1.0f);
1209 else if (screenAxis == 1)
1210 vec.Set(0.0f, 1.0f, 0.0f);
1211}
1212
1213
1214/** \class TEve3DProjection
1215\ingroup TEve
12163D scaling projection. One has to use pre-scaling to make any ise of this.
1217*/
1218
1220
1221////////////////////////////////////////////////////////////////////////////////
1222/// Constructor.
1223
1226{
1227 fType = kPT_3D;
1229 fName = "3D";
1230}
1231
1232////////////////////////////////////////////////////////////////////////////////
1233/// Project point.
1234
1236 Float_t /*d*/, EPProc_e proc)
1237{
1238 using namespace TMath;
1239
1240 if (proc != kPP_Plane)
1241 {
1242 if (fUsePreScale)
1243 {
1244 PreScalePoint(x, y, z);
1245 }
1246
1247 x -= fCenter.fX;
1248 y -= fCenter.fY;
1249 z -= fCenter.fZ;
1250 }
1251}
ROOT::R::TRInterface & r
Definition Object.C:4
#define d(i)
Definition RSha256.hxx:102
#define a(i)
Definition RSha256.hxx:99
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:231
char * Form(const char *fmt,...)
3D scaling projection.
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
TEve3DProjection()
Constructor.
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
Base-class for non-linear projections.
virtual void SetCenter(TEveVector &v)
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e p=kPP_Full)=0
static Float_t fgEpsSqr
void SetDistortion(Float_t d)
Set distortion.
static Float_t fgEps
Float_t GetLimit(Int_t i, Bool_t pos)
Method previously used by TEveProjectionAxesGL. Now obsolete.
void AddPreScaleEntry(Int_t coord, Float_t max_val, Float_t scale)
Add new scaling range for given coordinate.
virtual Float_t GetValForScreenPos(Int_t ax, Float_t value)
Inverse projection.
void SetPastFixRFac(Float_t x)
Set 2's-exponent for relative scaling beyond FixR.
virtual Float_t GetScreenVal(Int_t ax, Float_t value)
Project point on given axis and return projected value.
vPreScale_t fPreScales[3]
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get vector for axis in a projected space.
virtual void BisectBreakPoint(TEveVector &vL, TEveVector &vR, Float_t eps_sqr)
Find break-point on both sides of the discontinuity.
EGeoMode_e fGeoMode
void SetFixR(Float_t x)
Set fixed radius.
TEveVector GetOrthogonalCenter(int idx, TEveVector &out)
Get center ortogonal to given axis index.
void ProjectPointfv(Float_t *v, Float_t d)
Project float array.
void SetPastFixZFac(Float_t x)
Set 2's-exponent for relative scaling beyond FixZ.
void ChangePreScaleEntry(Int_t coord, Int_t entry, Float_t new_scale)
Change scale for given entry and coordinate.
TEveVector fCenter
void SetDisplaceOrigin(bool)
Set flag to displace for center.
std::vector< PreScaleEntry_t > vPreScale_t
void PreScalePoint(Float_t &x, Float_t &y)
Pre-scale point (x, y) in projected coordinates for 2D projections:
std::vector< PreScaleEntry_t >::iterator vPreScale_i
TEveProjection()
Constructor.
void ProjectVector(TEveVector &v, Float_t d)
Project TEveVector.
void ProjectPointdv(Double_t *v, Float_t d)
Project double array.
virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector &) const
void SetFixZ(Float_t x)
Set fixed radius.
void ClearPreScales()
Clear all pre-scaling information.
void PreScaleVariable(Int_t dim, Float_t &v)
Pre-scale single variable with pre-scale entry dim.
virtual Bool_t AcceptSegment(TEveVector &, TEveVector &, Float_t) const
virtual Float_t * GetProjectedCenter()
Get projected center.
XY projection with distortion around given center.
TEveRPhiProjection()
Constructor.
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
Transformation from 3D to 2D.
TEveVector fProjectedCenter
virtual Bool_t IsOnSubSpaceBoundrary(const TEveVector &v) const
Checks if point is on sub-space boundary.
virtual Bool_t AcceptSegment(TEveVector &v1, TEveVector &v2, Float_t tolerance) const
Check if segment of two projected points is valid.
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get direction in the unprojected space for axis index in the projected space.
TEveRhoZProjection()
Constructor.
virtual void SetCenter(TEveVector &v)
Set center of distortion (virtual method).
virtual Int_t SubSpaceId(const TEveVector &v) const
Return sub-space id for the point.
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition TEveTrans.h:27
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
const TT * Arr() const
Definition TEveVector.h:58
TEveVectorT & Mult(const TEveVectorT &a, TT af)
Definition TEveVector.h:196
TT Dot(const TEveVectorT &a) const
Definition TEveVector.h:168
void Set(const Float_t *v)
Definition TEveVector.h:82
XZ projection with distortion around given center.
TEveXZProjection()
Constructor.
TEveVector fProjectedCenter
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get direction in the unprojected space for axis index in the projected space.
virtual void SetCenter(TEveVector &v)
Set center of distortion (virtual method).
YZ projection with distortion around given center.
TEveVector fProjectedCenter
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get direction in the unprojected space for axis index in the projected space.
TEveYZProjection()
Constructor.
virtual void SetCenter(TEveVector &v)
Set center of distortion (virtual method).
ZX projection with distortion around given center.
TEveZXProjection()
Constructor.
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get direction in the unprojected space for axis index in the projected space.
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
virtual void SetCenter(TEveVector &v)
Set center of distortion (virtual method).
TEveVector fProjectedCenter
ZY projection with distortion around given center.
virtual void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full)
Project point.
TEveZYProjection()
Constructor.
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector &vec)
Get direction in the unprojected space for axis index in the projected space.
virtual void SetCenter(TEveVector &v)
Set center of distortion (virtual method).
TEveVector fProjectedCenter
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TMath.
Definition TMathBase.h:35
Double_t Log2(Double_t x)
Definition TMath.cxx:101
T1 Sign(T1 a, T2 b)
Definition TMathBase.h:161
Double_t Sqrt(Double_t x)
Definition TMath.h:641
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition TMath.h:685
Int_t CeilNint(Double_t x)
Definition TMath.h:649
Short_t Abs(Short_t d)
Definition TMathBase.h:120