Changeset 14150 for trunk/Mars


Ignore:
Timestamp:
06/11/12 10:50:27 (12 years ago)
Author:
tbretz
Message:
Addeda hexagonal mirror rotated by 15deg
Location:
trunk/Mars/msimreflector
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/msimreflector/MMirrorHex.cc

    r9947 r14150  
    201201// The action should coincide with what is painted in Paint()
    202202//
     203Bool_t MMirrorHex15::HasHit(const MQuaternion &p) const
     204{
     205    // p is the incident point in the mirror in the mirror's
     206    // coordinate frame
     207
     208    // Black spot in the mirror center (here we can fairly ignore
     209    // the distance from the plane to the mirror surface, as long
     210    // as the black spot does not become too large)
     211//    if (p.R2()<0.5*0.5)
     212//        return kFALSE;
     213
     214    static const TVector2 rot(cos(-15*TMath::DegToRad()), sin(-15*TMath::DegToRad()));
     215
     216    const TVector2 &v = p.XYvector();
     217
     218    const Double_t x = v^rot;
     219    const Double_t y = v*rot;
     220
     221    //
     222    // Now check if point is outside of hexagon; just check x coordinate
     223    // in three coordinate systems: the default one, in which two sides of
     224    // the hexagon are paralel to the y axis (see camera displays) and two
     225    // more, rotated with respect to that one by +- 60 degrees.
     226    //
     227    if (TMath::Abs(x)>fD)
     228        return kFALSE;
     229
     230    const Double_t dxc = x*fgCos60;
     231    const Double_t dys = y*fgSin60;
     232
     233    if (TMath::Abs(dxc+dys)>fD)
     234        return kFALSE;
     235
     236    if (TMath::Abs(dxc-dys)>fD)
     237        return kFALSE;
     238
     239    return kTRUE;
     240}
     241
     242// ------------------------------------------------------------------------
     243//
     244// Paint the mirror in x/y.
     245//
     246// The graphic should coincide with the action in HasHit
     247//
     248void MMirrorHex15::Paint(Option_t *opt)
     249{
     250    MHexagon h;
     251    TEllipse e;
     252    h.SetFillColor(18);
     253    if (!TString(opt).Contains("line", TString::kIgnoreCase))
     254    {
     255        h.SetFillColor(17);
     256        h.SetLineStyle(0);
     257        e.SetLineStyle(0);
     258        e.SetFillColor(gPad->GetFillColor());
     259    }
     260
     261    if (TString(opt).Contains("same", TString::kIgnoreCase))
     262    {
     263        h.SetFillStyle(0);
     264        e.SetFillStyle(0);
     265    }
     266
     267    h.PaintHexagon(X(), Y(), fD*2, 15*TMath::DegToRad());
     268
     269    if (!TString(opt).Contains("border", TString::kIgnoreCase))
     270        e.PaintEllipse(X(), Y(), 0.5, 0.5, 0, 360, 0);
     271}
     272
     273// ------------------------------------------------------------------------
     274//
     275// Check if the given position coincides with the mirror. The position
     276// is assumed to be the incident point on the mirror's surface.
     277//
     278// The coordinates are in the mirrors coordinate frame.
     279//
     280// The action should coincide with what is painted in Paint()
     281//
    203282Bool_t MMirrorHex90::HasHit(const MQuaternion &p) const
    204283{
     
    215294    // Now check if point is outside of hexagon; just check x coordinate
    216295    // in three coordinate systems: the default one, in which two sides of
    217     // the hexagon are paralel to the y axis (see camera displays) and two
     296    // the hexagon are parallel to the y axis (see camera displays) and two
    218297    // more, rotated with respect to that one by +- 60 degrees.
    219298    //
     
    263342        e.PaintEllipse(X(), Y(), 0.5, 0.5, 0, 360, 0);
    264343}
     344
  • trunk/Mars/msimreflector/MMirrorHex.h

    r9947 r14150  
    5353};
    5454
     55class MMirrorHex15 : public MMirrorHex
     56{
     57public:
     58    MMirrorHex15() : MMirrorHex() { }
     59
     60    // MMirror
     61    Bool_t HasHit(const MQuaternion &p) const;
     62
     63    // TObject
     64    void Paint(Option_t *);
     65
     66    ClassDef(MMirrorHex15, 1) // A spherical hexagon type mirror (MMirrorHex rotated by 15deg)
     67};
     68
    5569#endif
Note: See TracChangeset for help on using the changeset viewer.