Changeset 17161


Ignore:
Timestamp:
Sep 9, 2013, 4:56:16 PM (6 years ago)
Author:
tbretz
Message:
Added a version of GetIntersectionPoint which allows to check for success.
Location:
trunk/Mars/mbase
Files:
2 edited

Legend:

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

    r11426 r17161  
    619619// Formula from: http://mathworld.wolfram.com/Line-LineIntersection.html
    620620//
    621 TVector2 MMath::GetIntersectionPoint(const TVector2 &x1, const TVector2 &y1, const TVector2 &x2, const TVector2 &y2)
     621TVector2 MMath::GetIntersectionPoint(const TVector2 &x1, const TVector2 &y1, const TVector2 &x2, const TVector2 &y2, Bool_t &rc)
    622622{
    623623    TMatrix d(2,2);
     
    629629    const Double_t denom = d.Determinant();
    630630    if (denom==0)
     631    {
     632        rc = false;
    631633        return TVector2();
     634    }
     635
     636    rc = true;
    632637
    633638    TMatrix l1(2,2);
     
    658663
    659664    return TVector2(X, Y);
     665}
     666
     667TVector2 MMath::GetIntersectionPoint(const TVector2 &x1, const TVector2 &y1, const TVector2 &x2, const TVector2 &y2)
     668{
     669    Bool_t rc;
     670    return GetIntersectionPoint(x1, y1, x2, y2, rc);
    660671}
    661672
  • trunk/Mars/mbase/MMath.h

    r11426 r17161  
    5555    Double_t InterpolParabCos(const TVector3 &vx, const TVector3 &vy, Double_t x);
    5656
     57    TVector2 GetIntersectionPoint(const TVector2 &x1, const TVector2 &y1, const TVector2 &x2, const TVector2 &y2, Bool_t &rc);
    5758    TVector2 GetIntersectionPoint(const TVector2 &x1, const TVector2 &y1, const TVector2 &x2, const TVector2 &y2);
    5859
Note: See TracChangeset for help on using the changeset viewer.