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