Ignore:
Timestamp:
06/11/07 21:51:55 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc

    r8546 r8549  
    124124// The defaule for y is 0
    125125//
    126 Double_t MExtralgoSpline::FindY(Int_t i, Double_t y, Double_t min, Double_t max) const
     126Double_t MExtralgoSpline::FindY(Int_t i, Bool_t downwards, Double_t y, Double_t min, Double_t max) const
    127127{
    128128    // y = a*x^3 + b*x^2 + c*x + d'
     
    144144    const Int_t rc = MMath::SolvePol3(a, b, c, d, x1, x2, x3);
    145145
    146     Double_t x = -1;
    147     if (rc>0 && x1>=min && x1<max && x1>x)
    148         x = x1;
    149     if (rc>1 && x2>=min && x2<max && x2>x)
    150         x = x2;
    151     if (rc>2 && x3>=min && x3<max && x3>x)
    152         x = x3;
    153 
    154     return x<0 ? -2 : x+i;
     146    if (downwards==kTRUE)
     147    {
     148        Double_t x = -1;
     149
     150        if (rc>0 && x1>=min && x1<max && x1>x)
     151            x = x1;
     152        if (rc>1 && x2>=min && x2<max && x2>x)
     153            x = x2;
     154        if (rc>2 && x3>=min && x3<max && x3>x)
     155            x = x3;
     156
     157        return x<0 ? -2 : x+i;
     158    }
     159    else
     160    {
     161        Double_t x = 2;
     162
     163        if (rc>0 && x1>min && x1<=max && x1<x)
     164            x = x1;
     165        if (rc>1 && x2>min && x2<=max && x2<x)
     166            x = x2;
     167        if (rc>2 && x3>min && x3<=max && x3<x)
     168            x = x3;
     169
     170        return x>1 ? -2 : x+i;
     171    }
     172
     173    return -2;
    155174}
    156175
     
    166185
    167186    Int_t i = TMath::FloorNint(x);
    168     Double_t rc = FindY(i, y, 0, x-i);
     187    Double_t rc = FindY(i, kTRUE, y, 0, x-i);
    169188    while (--i>=0 && rc<0)
    170         rc = FindY(i, y);
     189        rc = FindY(i, kTRUE, y);
    171190
    172191    return rc;
     
    179198
    180199    Int_t i = TMath::FloorNint(x);
    181     Double_t rc = FindY(i, y, x-i, 1.);
     200    Double_t rc = FindY(i, kFALSE, y, x-i, 1.);
    182201    while (i++<fNum-1 && rc<0)
    183         rc = FindY(i, y);
     202        rc = FindY(i, kFALSE, y);
    184203
    185204    return rc;
Note: See TracChangeset for help on using the changeset viewer.