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
28
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructor.
34
36 fType (kPT_Unknown),
37 fGeoMode (kGM_Unknown),
38 fName (0),
39 fCenter (),
40 fDisplaceOrigin (kFALSE),
41 fUsePreScale (kFALSE),
42 fDistortion (0.0f),
43 fFixR (300), fFixZ (400),
44 fPastFixRFac (0), fPastFixZFac (0),
45 fScaleR (1), fScaleZ (1),
46 fPastFixRScale (1), fPastFixZScale (1),
47 fMaxTrackStep (5)
48{
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Project float array.
53
58
59////////////////////////////////////////////////////////////////////////////////
60/// Project double array.
61/// This is a bit piggish as we convert the doubles to floats and back.
62
64{
65 Float_t x = v[0], y = v[1], z = v[2];
66 ProjectPoint(x, y, z, d);
67 v[0] = x; v[1] = y; v[2] = z;
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Project TEveVector.
72
77
78////////////////////////////////////////////////////////////////////////////////
79/// Project float array, converting it to global coordinate system first if
80/// transformation matrix is set.
81
83{
84 v[0] = p[0]; v[1] = p[1]; v[2] = p[2];
85 if (t)
86 {
87 t->MultiplyIP(v);
88 }
89 ProjectPoint(v[0], v[1], v[2], d);
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Project double array, converting it to global coordinate system first if
94/// transformation matrix is set.
95/// This is a bit piggish as we convert the doubles to floats and back.
96
98{
99 Float_t x, y, z;
100 if (t)
101 {
102 t->Multiply(p, v);
103 x = v[0]; y = v[1]; z = v[2];
104 }
105 else
106 {
107 x = p[0]; y = p[1]; z = p[2];
108 }
109 ProjectPoint(x, y, z, d);
110 v[0] = x; v[1] = y; v[2] = z;
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Project TEveVector, converting it to global coordinate system first if
115/// transformation matrix is set.
116
118{
119 if (t)
120 {
121 t->MultiplyIP(v);
122 }
123 ProjectPoint(v.fX, v.fY, v.fZ, d);
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Pre-scale single variable with pre-scale entry dim.
128
130{
131 if (!fPreScales[dim].empty())
132 {
134 if (v < 0) {
135 v = -v;
136 invp = kTRUE;
137 }
138 vPreScale_i i = fPreScales[dim].begin();
139 while (v > i->fMax)
140 ++i;
141 v = i->fOffset + (v - i->fMin)*i->fScale;
142 if (invp)
143 v = -v;
144 }
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Pre-scale point (x, y) in projected coordinates for 2D projections:
149/// - RhoZ ~ (rho, z)
150/// - RPhi ~ (r, phi), scaling phi doesn't make much sense.
151
157
158////////////////////////////////////////////////////////////////////////////////
159/// Pre-scale point (x, y, z) in projected coordinates for 3D projection.
160
167
168////////////////////////////////////////////////////////////////////////////////
169/// Add new scaling range for given coordinate.
170/// Arguments:
171/// - coord 0 ~ x, 1 ~ y, 2 ~ z
172/// - value value of input coordinate from which to apply this scale;
173/// - scale the scale to apply from value onwards.
174///
175/// NOTE: If pre-scaling is combined with center-displaced then
176/// the scale of the central region should be 1. This limitation
177/// can be removed but will cost CPU.
178
180{
181 static const TEveException eh("TEveProjection::AddPreScaleEntry ");
182
184 throw (eh + "coordinate out of range.");
185
186 const Float_t infty = std::numeric_limits<Float_t>::infinity();
187
189
190 if (vec.empty())
191 {
192 if (value == 0)
193 {
194 vec.push_back(PreScaleEntry_t(0, infty, 0, scale));
195 }
196 else
197 {
198 vec.push_back(PreScaleEntry_t(0, value, 0, 1));
199 vec.push_back(PreScaleEntry_t(value, infty, value, scale));
200 }
201 }
202 else
203 {
204 PreScaleEntry_t& prev = vec.back();
205 if (value <= prev.fMin)
206 throw (eh + "minimum value not larger than previous one.");
207
208 prev.fMax = value;
209 Float_t offset = prev.fOffset + (prev.fMax - prev.fMin)*prev.fScale;
210 vec.push_back(PreScaleEntry_t(value, infty, offset, scale));
211 }
212}
213
214////////////////////////////////////////////////////////////////////////////////
215/// Change scale for given entry and coordinate.
216///
217/// NOTE: If the first entry you created used other value than 0,
218/// one entry (covering range from 0 to this value) was created
219/// automatically.
220
223{
224 static const TEveException eh("TEveProjection::ChangePreScaleEntry ");
225
227 throw (eh + "coordinate out of range.");
228
230 Int_t vs = vec.size();
232 throw (eh + "entry out of range.");
233
234 vec[entry].fScale = new_scale;
235 Int_t i0 = entry, i1 = entry + 1;
236 while (i1 < vs)
237 {
239 vec[i1].fOffset = e0.fOffset + (e0.fMax - e0.fMin)*e0.fScale;
240 i0 = i1++;
241 }
242}
243
244////////////////////////////////////////////////////////////////////////////////
245/// Clear all pre-scaling information.
246
248{
249 fPreScales[0].clear();
250 fPreScales[1].clear();
251 fPreScales[2].clear();
252}
253
254////////////////////////////////////////////////////////////////////////////////
255/// Set distortion.
256
265
266////////////////////////////////////////////////////////////////////////////////
267/// Set fixed radius.
268
275
276////////////////////////////////////////////////////////////////////////////////
277/// Set fixed radius.
278
285
286////////////////////////////////////////////////////////////////////////////////
287/// Set 2's-exponent for relative scaling beyond FixR.
288
294
295////////////////////////////////////////////////////////////////////////////////
296/// Get projected center.
297
299{
300 static TEveVector zero;
301
302 if (fDisplaceOrigin)
303 return zero.Arr();
304 else
305 return fCenter.Arr();
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Set flag to displace for center.
310/// This options is useful if want to have projected center
311/// at (0, 0) position in projected coordinates and want to dismiss
312/// gap around projected center in RhoZ projection.
313
315{
317 // update projected center
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Set 2's-exponent for relative scaling beyond FixZ.
323
329
330////////////////////////////////////////////////////////////////////////////////
331/// Find break-point on both sides of the discontinuity.
332/// They still need to be projected after the call.
333/// This is an obsolete version of the method that required manual
334/// specification of precision -- this lead to (infrequent) infinite loops.
335
337{
338 static Bool_t warnedp = kFALSE;
339
340 if (!warnedp)
341 {
342 Warning("BisectBreakPoint", "call with eps_sqr argument is obsolete - please use the new signature.");
343 warnedp = kTRUE;
344 }
345
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// Find break-point on both sides of the discontinuity.
351/// If project_result is true, the resulting break points will be projected
352/// with given depth value.
353
356{
358 Int_t n_loops = TMath::CeilNint(TMath::Log2(1e12 * (vL-vR).Mag2() / (0.5f*(vL+vR)).Mag2()) / 2);
359 while (--n_loops >= 0)
360 {
361 vM.Mult(vL + vR, 0.5f);
362 vLP.Set(vL); ProjectPoint(vLP.fX, vLP.fY, vLP.fZ, 0);
363 vMP.Set(vM); ProjectPoint(vMP.fX, vMP.fY, vMP.fZ, 0);
364
366 {
367 vL.Set(vM);
368 vR.Set(vM);
369 break;
370 }
371
372 if (AcceptSegment(vLP, vMP, 0.0f))
373 {
374 vL.Set(vM);
375 }
376 else
377 {
378 vR.Set(vM);
379 }
380 }
381
382 if (project_result)
383 {
386 }
387}
388
389////////////////////////////////////////////////////////////////////////////////
390/// Method previously used by TEveProjectionAxesGL. Now obsolete.
391
393{
394 ::Warning("TEveProjection::GetLimits", "method is obsolete");
395
396 return 0;
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// Get vector for axis in a projected space.
401
403{
404 for (Int_t i=0; i<3; i++)
405 {
406 vec[i] = (i==screenAxis) ? 1.0f : 0.0f;
407 }
408}
409
410////////////////////////////////////////////////////////////////////////////////
411/// Get center ortogonal to given axis index.
412
425
426////////////////////////////////////////////////////////////////////////////////
427/// Inverse projection.
428
430{
431 static const TEveException eH("TEveProjection::GetValForScreenPos ");
432
433 static const int kMaxSteps = 5000;
434 static const int kMaxVal = 10;
435
436 Float_t xL, xM, xR;
438
441
444
447
448 // search from -/+ infinity according to sign of screen value
449 if (sv > zeroProjected[axisIdx])
450 {
451 xL = 0;
452 xR = kMaxVal;
453
454 int cnt = 0;
455 while (cnt < kMaxSteps)
456 {
457 vec.Mult(dirVec, xR);
459
460 ProjectVector(vec, 0);
461 if (vec[axisIdx] >= sv) break;
462 xL = xR; xR *= 2;
463
464 if (++cnt >= kMaxSteps)
465 throw eH + Form("positive projected %f, value %f,xL, xR ( %f, %f)\n", vec[axisIdx], sv, xL, xR);
466 }
467 }
468 else if (sv < zeroProjected[axisIdx])
469 {
470 xR = 0;
471 xL = -kMaxVal;
472
473 int cnt = 0;
474 while (cnt < kMaxSteps)
475 {
476 vec.Mult(dirVec, xL);
478
479 ProjectVector(vec, 0);
480 if (vec[axisIdx] <= sv) break;
481 xR = xL; xL *= 2;
482 if (++cnt >= kMaxSteps)
483 throw eH + Form("negative projected %f, value %f,xL, xR ( %f, %f)\n", vec[axisIdx], sv, xL, xR);
484 }
485 }
486 else
487 {
488 return 0.0f;
489 }
490
491 // printf("search for value %f in rng[%f, %f] \n", sv, xL, xR);
492 int cnt = 0;
493 do
494 {
495 //printf("search value with bisection xL=%f, xR=%f; vec[axisIdx]=%f, sv=%f\n", xL, xR, vec[axisIdx], sv);
496 xM = 0.5f * (xL + xR);
497 vec.Mult(dirVec, xM);
499 ProjectVector(vec, 0);
500 if (vec[axisIdx] > sv)
501 xR = xM;
502 else
503 xL = xM;
504 if (++cnt >= kMaxSteps)
505 throw eH + Form("can't converge %f %f, l/r %f/%f, idx=%d\n", vec[axisIdx], sv, xL, xR, axisIdx);
506
507 } while (TMath::Abs(vec[axisIdx] - sv) >= fgEps);
508
509
510 return xM;
511}
512
513////////////////////////////////////////////////////////////////////////////////
514/// Project point on given axis and return projected value.
515
517{
518 TEveVector pos = dirVec*x;
519
520 if (fDisplaceOrigin)
521 pos += fCenter;
522
523 ProjectVector(pos , 0.f);
524
525 return pos[i];
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Project point on given axis and return projected value.
530
532{
536 // GetOrthogonalCenter(i, oCenter);
537 return GetScreenVal(i, x, dirVec, oCenter);
538}
539
540/** \class TEveRhoZProjection
541\ingroup TEve
542Transformation from 3D to 2D. X axis represent Z coordinate. Y axis have value of
543radius with a sign of Y coordinate.
544*/
545
546
547////////////////////////////////////////////////////////////////////////////////
548/// Constructor.
549
556
557////////////////////////////////////////////////////////////////////////////////
558/// Project point.
559
562{
563 using namespace TMath;
564
565 if (fDisplaceOrigin) {
566 x -= fCenter.fX;
567 y -= fCenter.fY;
568 z -= fCenter.fZ;
569 }
570 if (proc == kPP_Plane || proc == kPP_Full)
571 {
572 // project
573 y = Sign((Float_t)Sqrt(x*x+y*y), y);
574 x = z;
575 }
576 if (proc == kPP_Distort || proc == kPP_Full)
577 {
578 if (fUsePreScale)
579 PreScalePoint(y, x);
580
581 // distort
582
583 if (!fDisplaceOrigin) {
586 }
587
588 if (x > fFixZ)
589 x = fFixZ + fPastFixZScale*(x - fFixZ);
590 else if (x < -fFixZ)
591 x = -fFixZ + fPastFixZScale*(x + fFixZ);
592 else
593 x = x * fScaleZ / (1.0f + Abs(x)*fDistortion);
594
595 if (y > fFixR)
596 y = fFixR + fPastFixRScale*(y - fFixR);
597 else if (y < -fFixR)
598 y = -fFixR + fPastFixRScale*(y + fFixR);
599 else
600 y = y * fScaleR / (1.0f + Abs(y)*fDistortion);
601
602 if (!fDisplaceOrigin) {
605 }
606 }
607 z = d;
608}
609
610////////////////////////////////////////////////////////////////////////////////
611/// Set center of distortion (virtual method).
612
614{
615 fCenter = v;
616
617 if (fDisplaceOrigin)
618 {
619 fProjectedCenter.Set(0.f, 0.f, 0.f);
620 }
621 else
622 {
623 Float_t r = TMath::Sqrt(v.fX*v.fX + v.fY*v.fY);
627 }
628}
629
630////////////////////////////////////////////////////////////////////////////////
631/// Get direction in the unprojected space for axis index in the
632/// projected space.
633/// This is virtual method from base-class TEveProjection.
634
636{
637 if (screenAxis == 0)
638 vec.Set(0.0f, 0.0f, 1.0f);
639 else if (screenAxis == 1)
640 vec.Set(0.0f, 1.0f, 0.0f);
641
642}
643
644////////////////////////////////////////////////////////////////////////////////
645/// Check if segment of two projected points is valid.
646///
647/// Move slightly one of the points if by shifting it by no more than
648/// tolerance the segment can become acceptable.
649
651 Float_t tolerance) const
652{
654 Bool_t val = kTRUE;
655 if ((v1.fY < a && v2.fY > a) || (v1.fY > a && v2.fY < a))
656 {
657 val = kFALSE;
658 if (tolerance > 0)
659 {
660 Float_t a1 = TMath::Abs(v1.fY - a), a2 = TMath::Abs(v2.fY - a);
661 if (a1 < a2)
662 {
663 if (a1 < tolerance) { v1.fY = a; val = kTRUE; }
664 }
665 else
666 {
667 if (a2 < tolerance) { v2.fY = a; val = kTRUE; }
668 }
669 }
670 }
671 return val;
672}
673
674////////////////////////////////////////////////////////////////////////////////
675/// Return sub-space id for the point.
676/// 0 - upper half-space
677/// 1 - lower half-space
678
680{
681 return v.fY > fProjectedCenter.fY ? 0 : 1;
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// Checks if point is on sub-space boundary.
686
691
692/** \class TEveRPhiProjection
693\ingroup TEve
694XY projection with distortion around given center.
695*/
696
697
698////////////////////////////////////////////////////////////////////////////////
699/// Constructor.
700
708
709////////////////////////////////////////////////////////////////////////////////
710/// Project point.
711
714{
715 using namespace TMath;
716
717 if (fDisplaceOrigin)
718 {
719 x -= fCenter.fX;
720 y -= fCenter.fY;
721 z -= fCenter.fZ;
722 }
723
724 if (proc != kPP_Plane)
725 {
726 Float_t r, phi;
727 if (fUsePreScale)
728 {
729 r = Sqrt(x*x + y*y);
730 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
731 PreScalePoint(r, phi);
732 x = r*Cos(phi);
733 y = r*Sin(phi);
734 }
735
736 if (!fDisplaceOrigin)
737 {
738 x -= fCenter.fX;
739 y -= fCenter.fY;
740 }
741
742 r = Sqrt(x*x + y*y);
743 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
744
745 if (r > fFixR)
746 r = fFixR + fPastFixRScale*(r - fFixR);
747 else if (r < -fFixR)
748 r = -fFixR + fPastFixRScale*(r + fFixR);
749 else
750 r = r * fScaleR / (1.0f + r*fDistortion);
751
752 x = r*Cos(phi);
753 y = r*Sin(phi);
754
755 if (!fDisplaceOrigin)
756 {
757 x += fCenter.fX;
758 y += fCenter.fY;
759 }
760 }
761
762 z = d;
763}
764
765/** \class TEveXZProjection
766\ingroup TEve
767XZ projection with distortion around given center.
768*/
769
770
771////////////////////////////////////////////////////////////////////////////////
772/// Constructor.
773
781
782////////////////////////////////////////////////////////////////////////////////
783/// Project point.
784
787{
788 using namespace TMath;
789
790 if (fDisplaceOrigin)
791 {
792 x -= fCenter.fX;
793 y -= fCenter.fY;
794 z -= fCenter.fZ;
795 }
796
797 // projection
798 if (proc == kPP_Plane || proc == kPP_Full)
799 {
800 y = z;
801 z = d;
802 }
803 if (proc != kPP_Distort || proc == kPP_Full)
804 {
805 Float_t r, phi;
806 if (fUsePreScale)
807 {
808 r = Sqrt(x*x + y*y);
809 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
810 PreScalePoint(r, phi);
811 x = r*Cos(phi);
812 y = r*Sin(phi);
813 }
814
815 if (!fDisplaceOrigin)
816 {
819 }
820
821 r = Sqrt(x*x + y*y);
822 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
823
824 if (r > fFixR)
825 r = fFixR + fPastFixRScale*(r - fFixR);
826 else if (r < -fFixR)
827 r = -fFixR + fPastFixRScale*(r + fFixR);
828 else
829 r = r * fScaleR / (1.0f + r*fDistortion);
830
831 x = r*Cos(phi);
832 y = r*Sin(phi);
833
834 if (!fDisplaceOrigin)
835 {
838 }
839 }
840}
841
842////////////////////////////////////////////////////////////////////////////////
843/// Set center of distortion (virtual method).
844
846{
847 fCenter = v;
848
849 if (fDisplaceOrigin)
850 {
851 fProjectedCenter.Set(0.f, 0.f, 0.f);
852 }
853 else
854 {
858 }
859}
860
861////////////////////////////////////////////////////////////////////////////////
862/// Get direction in the unprojected space for axis index in the
863/// projected space.
864/// This is virtual method from base-class TEveProjection.
865
867{
868 if (screenAxis == 0)
869 vec.Set(1.0f, 0.0f, 0.0f);
870 else if (screenAxis == 1)
871 vec.Set(0.0f, 0.0f, 1.0f);
872}
873
874
875/** \class TEveYZProjection
876\ingroup TEve
877YZ projection with distortion around given center.
878*/
879
880
881////////////////////////////////////////////////////////////////////////////////
882/// Constructor.
883
891
892////////////////////////////////////////////////////////////////////////////////
893/// Project point.
894
897{
898 using namespace TMath;
899
900 if (fDisplaceOrigin)
901 {
902 x -= fCenter.fX;
903 y -= fCenter.fY;
904 z -= fCenter.fZ;
905 }
906
907 // projection
908 if (proc == kPP_Plane || proc == kPP_Full)
909 {
910 x = y;
911 y = z;
912 z = d;
913 }
914 if (proc != kPP_Distort || proc == kPP_Full)
915 {
916 Float_t r, phi;
917 if (fUsePreScale)
918 {
919 r = Sqrt(x*x + y*y);
920 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
921 PreScalePoint(r, phi);
922 x = r*Cos(phi);
923 y = r*Sin(phi);
924 }
925
926 if (!fDisplaceOrigin)
927 {
930 }
931
932 r = Sqrt(x*x + y*y);
933 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
934
935 if (r > fFixR)
936 r = fFixR + fPastFixRScale*(r - fFixR);
937 else if (r < -fFixR)
938 r = -fFixR + fPastFixRScale*(r + fFixR);
939 else
940 r = r * fScaleR / (1.0f + r*fDistortion);
941
942 x = r*Cos(phi);
943 y = r*Sin(phi);
944
945 if (!fDisplaceOrigin)
946 {
949 }
950 }
951}
952
953////////////////////////////////////////////////////////////////////////////////
954/// Set center of distortion (virtual method).
955
957{
958 fCenter = v;
959
960 if (fDisplaceOrigin)
961 {
962 fProjectedCenter.Set(0.f, 0.f, 0.f);
963 }
964 else
965 {
969 }
970}
971
972////////////////////////////////////////////////////////////////////////////////
973/// Get direction in the unprojected space for axis index in the
974/// projected space.
975/// This is virtual method from base-class TEveProjection.
976
978{
979 if (screenAxis == 0)
980 vec.Set(0.0f, 1.0f, 0.0f);
981 else if (screenAxis == 1)
982 vec.Set(0.0f, 0.0f, 1.0f);
983}
984
985
986/** \class TEveZXProjection
987\ingroup TEve
988ZX projection with distortion around given center.
989*/
990
991
992////////////////////////////////////////////////////////////////////////////////
993/// Constructor.
994
1002
1003////////////////////////////////////////////////////////////////////////////////
1004/// Project point.
1005
1008{
1009 using namespace TMath;
1010
1011 if (fDisplaceOrigin)
1012 {
1013 x -= fCenter.fX;
1014 y -= fCenter.fY;
1015 z -= fCenter.fZ;
1016 }
1017
1018 // projection
1019 if (proc == kPP_Plane || proc == kPP_Full)
1020 {
1021 y = x;
1022 x = z;
1023 z = d;
1024 }
1025 if (proc != kPP_Distort || proc == kPP_Full)
1026 {
1027 Float_t r, phi;
1028 if (fUsePreScale)
1029 {
1030 r = Sqrt(x*x + y*y);
1031 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
1032 PreScalePoint(r, phi);
1033 x = r*Cos(phi);
1034 y = r*Sin(phi);
1035 }
1036
1037 if (!fDisplaceOrigin)
1038 {
1041 }
1042
1043 r = Sqrt(x*x + y*y);
1044 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
1045
1046 if (r > fFixR)
1047 r = fFixR + fPastFixRScale*(r - fFixR);
1048 else if (r < -fFixR)
1049 r = -fFixR + fPastFixRScale*(r + fFixR);
1050 else
1051 r = r * fScaleR / (1.0f + r*fDistortion);
1052
1053 x = r*Cos(phi);
1054 y = r*Sin(phi);
1055
1056 if (!fDisplaceOrigin)
1057 {
1060 }
1061 }
1062}
1063
1064////////////////////////////////////////////////////////////////////////////////
1065/// Set center of distortion (virtual method).
1066
1068{
1069 fCenter = v;
1070
1071 if (fDisplaceOrigin)
1072 {
1073 fProjectedCenter.Set(0.f, 0.f, 0.f);
1074 }
1075 else
1076 {
1079 fProjectedCenter.fZ = 0;
1080 }
1081}
1082
1083////////////////////////////////////////////////////////////////////////////////
1084/// Get direction in the unprojected space for axis index in the
1085/// projected space.
1086/// This is virtual method from base-class TEveProjection.
1087
1089{
1090 if (screenAxis == 0)
1091 vec.Set(0.0f, 0.0f, 1.0f);
1092 else if (screenAxis == 1)
1093 vec.Set(1.0f, 0.0f, 0.0f);
1094}
1095
1096
1097/** \class TEveZYProjection
1098\ingroup TEve
1099ZY projection with distortion around given center.
1100*/
1101
1102
1103////////////////////////////////////////////////////////////////////////////////
1104/// Constructor.
1105
1113
1114////////////////////////////////////////////////////////////////////////////////
1115/// Project point.
1116
1119{
1120 using namespace TMath;
1121
1122 if (fDisplaceOrigin)
1123 {
1124 x -= fCenter.fX;
1125 y -= fCenter.fY;
1126 z -= fCenter.fZ;
1127 }
1128
1129 // projection
1130 if (proc == kPP_Plane || proc == kPP_Full)
1131 {
1132 x = z;
1133 z = d;
1134 }
1135 if (proc != kPP_Distort || proc == kPP_Full)
1136 {
1137 Float_t r, phi;
1138 if (fUsePreScale)
1139 {
1140 r = Sqrt(x*x + y*y);
1141 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
1142 PreScalePoint(r, phi);
1143 x = r*Cos(phi);
1144 y = r*Sin(phi);
1145 }
1146
1147 if (!fDisplaceOrigin)
1148 {
1151 }
1152
1153 r = Sqrt(x*x + y*y);
1154 phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
1155
1156 if (r > fFixR)
1157 r = fFixR + fPastFixRScale*(r - fFixR);
1158 else if (r < -fFixR)
1159 r = -fFixR + fPastFixRScale*(r + fFixR);
1160 else
1161 r = r * fScaleR / (1.0f + r*fDistortion);
1162
1163 x = r*Cos(phi);
1164 y = r*Sin(phi);
1165
1166 if (!fDisplaceOrigin)
1167 {
1170 }
1171 }
1172}
1173
1174////////////////////////////////////////////////////////////////////////////////
1175/// Set center of distortion (virtual method).
1176
1178{
1179 fCenter = v;
1180
1181 if (fDisplaceOrigin)
1182 {
1183 fProjectedCenter.Set(0.f, 0.f, 0.f);
1184 }
1185 else
1186 {
1189 fProjectedCenter.fZ = 0;
1190 }
1191}
1192
1193////////////////////////////////////////////////////////////////////////////////
1194/// Get direction in the unprojected space for axis index in the
1195/// projected space.
1196/// This is virtual method from base-class TEveProjection.
1197
1199{
1200 if (screenAxis == 0)
1201 vec.Set(0.0f, 0.0f, 1.0f);
1202 else if (screenAxis == 1)
1203 vec.Set(0.0f, 1.0f, 0.0f);
1204}
1205
1206
1207/** \class TEve3DProjection
1208\ingroup TEve
12093D scaling projection. One has to use pre-scaling to make any ise of this.
1210*/
1211
1212
1213////////////////////////////////////////////////////////////////////////////////
1214/// Constructor.
1215
1218{
1219 fType = kPT_3D;
1221 fName = "3D";
1222}
1223
1224////////////////////////////////////////////////////////////////////////////////
1225/// Project point.
1226
1228 Float_t /*d*/, EPProc_e proc)
1229{
1230 using namespace TMath;
1231
1232 if (proc != kPP_Plane)
1233 {
1234 if (fUsePreScale)
1235 {
1236 PreScalePoint(x, y, z);
1237 }
1238
1239 x -= fCenter.fX;
1240 y -= fCenter.fY;
1241 z -= fCenter.fZ;
1242 }
1243}
#define d(i)
Definition RSha256.hxx:102
#define a(i)
Definition RSha256.hxx:99
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2495
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
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.
TEveRPhiProjection()
Constructor.
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
Project point.
Bool_t IsOnSubSpaceBoundrary(const TEveVector &v) const override
Checks if point is on sub-space boundary.
TEveVector fProjectedCenter
void SetDirectionalVector(Int_t screenAxis, TEveVector &vec) override
Get direction in the unprojected space for axis index in the projected space.
TEveRhoZProjection()
Constructor.
Int_t SubSpaceId(const TEveVector &v) const override
Return sub-space id for the point.
Bool_t AcceptSegment(TEveVector &v1, TEveVector &v2, Float_t tolerance) const override
Check if segment of two projected points is valid.
void SetCenter(TEveVector &v) override
Set center of distortion (virtual method).
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
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
TT Dot(const TEveVectorT &a) const
Definition TEveVector.h:168
void Set(const Float_t *v)
Definition TEveVector.h:82
void SetCenter(TEveVector &v) override
Set center of distortion (virtual method).
void SetDirectionalVector(Int_t screenAxis, TEveVector &vec) override
Get direction in the unprojected space for axis index in the projected space.
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
Project point.
TEveXZProjection()
Constructor.
TEveVector fProjectedCenter
void SetCenter(TEveVector &v) override
Set center of distortion (virtual method).
TEveVector fProjectedCenter
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
Project point.
void SetDirectionalVector(Int_t screenAxis, TEveVector &vec) override
Get direction in the unprojected space for axis index in the projected space.
TEveYZProjection()
Constructor.
void SetDirectionalVector(Int_t screenAxis, TEveVector &vec) override
Get direction in the unprojected space for axis index in the projected space.
void SetCenter(TEveVector &v) override
Set center of distortion (virtual method).
TEveZXProjection()
Constructor.
TEveVector fProjectedCenter
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
Project point.
TEveZYProjection()
Constructor.
void SetCenter(TEveVector &v) override
Set center of distortion (virtual method).
void SetDirectionalVector(Int_t screenAxis, TEveVector &vec) override
Get direction in the unprojected space for axis index in the projected space.
void ProjectPoint(Float_t &x, Float_t &y, Float_t &z, Float_t d, EPProc_e proc=kPP_Full) override
Project point.
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)
Returns the binary (base-2) logarithm of x.
Definition TMath.cxx:107
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Definition TMathBase.h:176
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:732
Int_t CeilNint(Double_t x)
Returns the nearest integer of TMath::Ceil(x).
Definition TMath.h:685
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:124