Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Doca Class Reference

does some calculations about the DOCA between two Rays More...

#include <Doca.h>

List of all members.

Public Member Functions

 Doca (const Ray &ray1, const Ray &ray2=nullRay)
 Doca (const Point &point1, const Vector &vector1, const Point &point2=p_nullRay, const Vector &vector2=v_nullRay)
 ~Doca ()
double docaRay1Ray2 ()
 return doca between two Rays

double arcLenRay1 ()
 return distance of doca from origin of 1st Ray

double arcLenRay2 ()
 return distance of doca from origin of 2nd Ray

Point docaPointRay1 ()
 point of doca on 1st Ray

Point docaPointRay2 ()
 point of doca on 2nd Ray

double docaOfPoint (const Point &p)
 doca of a point to the first line


Private Types

enum  mode { LINELINE, LINEPOINT }

Private Member Functions

void ini ()

Private Attributes

Point P
 origin of 1st Ray

Vector u
 direction of 1st Ray

Point Q
 origin of 2nd Ray

Vector v
 direction of 2nd Ray

double doca
 DOCA between the two Rays.

double s
 distance of DOCA point from origin 1

double t
 distance of DOCA point from origin 2

mode m_mode
 mode of doca call, either 2 lines or a line and a point

Point p1
 storage for point in LINEPOINT mode


Detailed Description

does some calculations about the DOCA between two Rays

A utility for calculating the distance of closest approach between two (assumed straight) tracks and the point on each line where this occurs.

Also can do the distance between a line and a point

The method is taken from "Distance between Lines and Segments with their Closest Point of Approach" found at http://www.geometryalgorithms.com/Archive/algorithm_0106/algorithm_0106.htm

Author:
Tracy Usher 03/05/02

Definition at line 34 of file Doca.h.


Member Enumeration Documentation

enum Doca::mode [private]
 

Enumeration values:
LINELINE 
LINEPOINT 

Definition at line 58 of file Doca.h.

00058 {LINELINE, LINEPOINT};


Constructor & Destructor Documentation

Doca::Doca const Ray &  ray1,
const Ray &  ray2 = nullRay
 

Definition at line 15 of file Doca.cxx.

References ini().

00017            : P(ray1.position()), u(ray1.direction()), 
00018            Q(ray2.position()), v(ray2.direction()), 
00019            p1(p_nullRay)
00020 {
00021     ini();
00022 }

Doca::Doca const Point &  point1,
const Vector &  vector1,
const Point &  point2 = p_nullRay,
const Vector &  vector2 = v_nullRay
 

Definition at line 24 of file Doca.cxx.

References ini().

00026            : P(point1), u(vector1), Q(point2), v(vector2), 
00027            p1(p_nullRay)
00028 {
00029     ini();
00030 }

Doca::~Doca  )  [inline]
 

Definition at line 40 of file Doca.h.

00040 {}


Member Function Documentation

double Doca::arcLenRay1  )  [inline]
 

return distance of doca from origin of 1st Ray

Definition at line 45 of file Doca.h.

References s.

Referenced by VtxValsTool::calculate(), and TkrValsTool::calculate().

00045 {return s;}

double Doca::arcLenRay2  )  [inline]
 

return distance of doca from origin of 2nd Ray

Definition at line 47 of file Doca.h.

References t.

00047 {return t;}

double Doca::docaOfPoint const Point &  p  ) 
 

doca of a point to the first line

Definition at line 86 of file Doca.cxx.

References P, p1, s, and u.

Referenced by VtxValsTool::calculate(), TkrValsTool::calculate(), and CalValsTool::calculate().

00087 {
00088     p1 = p;
00089     Vector dp =  p1 - P;
00090     s  = dp.dot(u);
00091 
00092     return (dp.cross(u)).mag();
00093 }

Point Doca::docaPointRay1  ) 
 

point of doca on 1st Ray

Definition at line 74 of file Doca.cxx.

References P, s, and u.

00075 {
00076      return P + s * u;
00077 }

Point Doca::docaPointRay2  ) 
 

point of doca on 2nd Ray

Definition at line 79 of file Doca.cxx.

References LINEPOINT, m_mode, Q, t, and v.

00080 {
00081     if(m_mode==LINEPOINT) return p_nullRay;
00082 
00083     return Q + t * v;
00084 }

double Doca::docaRay1Ray2  )  [inline]
 

return doca between two Rays

Definition at line 43 of file Doca.h.

References doca.

00043 {return doca;}

void Doca::ini  )  [private]
 

Definition at line 32 of file Doca.cxx.

References doca, LINELINE, LINEPOINT, m_mode, P, Q, s, t, u, and v.

Referenced by Doca().

00032                {
00033 
00034     u = u.unit();
00035 
00036     m_mode = LINELINE;
00037     if(v.mag()==0.0) {
00038         m_mode = LINEPOINT;
00039         return;
00040     }
00041 
00042     v = v.unit();
00043 
00044     //Determine vector from start point track 1 to start of track 2
00045     Vector w     = P - Q;
00046 
00047     //Projections of of tracks along vector between start points
00048     double d     = u.dot(w);
00049     double e     = v.dot(w);
00050 
00051     //Dot product between two tracks to check if parallel
00052     double b     = u.dot(v);
00053     double denom = 1. - b*b;
00054 
00055     //Lines are not parallel
00056     if (fabs(b) < 1.)
00057     {
00058         s    = (b*e - d  ) / denom;
00059         t    = (e   - b*d) / denom;
00060         w    = w + s * u - t * v;
00061         doca = w.magnitude();
00062     }
00063     //Lines are parallel
00064     else
00065     {
00066         s    = 0;
00067         t    = d / b;
00068         w    = w - t * v;
00069         doca = w.magnitude();
00070     }
00071 }


Member Data Documentation

double Doca::doca [private]
 

DOCA between the two Rays.

Definition at line 68 of file Doca.h.

Referenced by docaRay1Ray2(), and ini().

mode Doca::m_mode [private]
 

mode of doca call, either 2 lines or a line and a point

Definition at line 74 of file Doca.h.

Referenced by docaPointRay2(), and ini().

Point Doca::P [private]
 

origin of 1st Ray

Definition at line 60 of file Doca.h.

Referenced by docaOfPoint(), docaPointRay1(), and ini().

Point Doca::p1 [private]
 

storage for point in LINEPOINT mode

Definition at line 76 of file Doca.h.

Referenced by docaOfPoint().

Point Doca::Q [private]
 

origin of 2nd Ray

Definition at line 64 of file Doca.h.

Referenced by docaPointRay2(), and ini().

double Doca::s [private]
 

distance of DOCA point from origin 1

Definition at line 70 of file Doca.h.

Referenced by arcLenRay1(), docaOfPoint(), docaPointRay1(), and ini().

double Doca::t [private]
 

distance of DOCA point from origin 2

Definition at line 72 of file Doca.h.

Referenced by arcLenRay2(), docaPointRay2(), and ini().

Vector Doca::u [private]
 

direction of 1st Ray

Definition at line 62 of file Doca.h.

Referenced by docaOfPoint(), docaPointRay1(), and ini().

Vector Doca::v [private]
 

direction of 2nd Ray

Definition at line 66 of file Doca.h.

Referenced by docaPointRay2(), and ini().


The documentation for this class was generated from the following files:
Generated on Mon Dec 1 20:09:09 2008 by doxygen 1.3.3