Ignore:
Timestamp:
06/11/07 16:36:14 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MMath.cc

    r8484 r8544  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.31 2007-05-10 12:14:54 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.32 2007-06-11 15:35:14 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    567567    if (r==0)
    568568    {
    569         x1 = -a/2;
     569        x1 = x2 = -a/2;
    570570        return 1;
    571571    }
     
    710710        const Double_t rq    = R/TMath::Abs(Q);
    711711
     712        const Double_t t = TMath::ACos(rq/sqrtq)/3;
     713
     714        static const Double_t sqrt3 = TMath::Sqrt(3.);
     715
     716        const Double_t s = TMath::Sin(t)*sqrt3;
     717        const Double_t c = TMath::Cos(t);
     718
     719        x1 = 2*sqrtq *      c  - a/3;
     720        x2 =  -sqrtq * (s + c) - a/3;
     721        x3 =   sqrtq * (s - c) - a/3;
     722
     723        /* --- Easier to understand but slower ---
    712724        const Double_t th1 = TMath::ACos(rq/sqrtq);
    713725        const Double_t th2 = th1 + TMath::TwoPi();
     
    717729        x2 = 2.*sqrtq * TMath::Cos(th2/3.) - a/3.;
    718730        x3 = 2.*sqrtq * TMath::Cos(th3/3.) - a/3.;
    719 
     731        */
    720732        return 3;
    721733    }
  • trunk/MagicSoft/Mars/mbase/MMath.h

    r8324 r8544  
    7070    inline Int_t ModF(Double_t dbl, Double_t &frac) { Double_t rc; frac = modf(dbl, &rc); return TMath::Nint(rc); }
    7171
    72     inline Double_t Sqrt3(Double_t x) { return TMath::Sign(TMath::Power(TMath::Abs(x), 1./3), x); }
     72    inline Double_t Sqrt3(Double_t x) { return cbrt(x); }
    7373
    7474    inline Double_t Sgn(Double_t d) { return d<0 ? -1 : 1; }
Note: See TracChangeset for help on using the changeset viewer.