14 float* segmentPosition,
15 float* segmentDirection,
16 float* segmentInnerPoint,
17 float* segmentOuterPoint )
23 segmentOuterPoint[0] = segmentPosition[0] + segmentLength*segmentDirection[0];
24 segmentOuterPoint[1] = segmentPosition[1] + segmentLength*segmentDirection[1];
25 segmentOuterPoint[2] = segmentLength;
27 if( fabs(segmentOuterPoint[1]) > segmentLimit )
28 segmentOuterPoint[1] = segmentLimit * ( segmentOuterPoint[1] / fabs( segmentOuterPoint[1] ));
30 segmentInnerPoint[0] = segmentPosition[0] - segmentLength*segmentDirection[0];
31 segmentInnerPoint[1] = segmentPosition[1] - segmentLength*segmentDirection[1];
32 segmentInnerPoint[2] = -segmentLength;
34 if( fabs(segmentInnerPoint[1]) > segmentLimit )
35 segmentInnerPoint[1] = segmentLimit * ( segmentInnerPoint[1] / fabs( segmentInnerPoint[1] ));
41 segmentOuterPoint[0] = segmentPosition[0] + segmentDirection[0] * ( segmentPosition[2] / segmentDirection[2] );
42 segmentOuterPoint[1] = segmentPosition[1] + segmentDirection[1] * ( segmentPosition[2] / segmentDirection[2] );
43 segmentOuterPoint[2] = segmentPosition[2];
45 if( fabs( segmentOuterPoint[1] ) > segmentLength )
46 segmentOuterPoint[1] = segmentLength * ( segmentOuterPoint[1]/fabs( segmentOuterPoint[1] ));
48 segmentInnerPoint[0] = segmentPosition[0] - segmentDirection[0] * ( segmentPosition[2] / segmentDirection[2] );
49 segmentInnerPoint[1] = segmentPosition[1] - segmentDirection[1] * ( segmentPosition[2] / segmentDirection[2] );
50 segmentInnerPoint[2] = -segmentPosition[2];
52 if( fabs( segmentInnerPoint[1] ) > segmentLength )
53 segmentInnerPoint[1] = segmentLength * ( segmentInnerPoint[1] / fabs( segmentInnerPoint[1] ));
63 segmentOuterPoint[0] = segmentPosition[0] + segmentLength*segmentDirection[0];
64 segmentOuterPoint[1] = segmentPosition[1] + segmentLength*segmentDirection[1];
65 segmentOuterPoint[2] = segmentLength;
67 segmentInnerPoint[0] = segmentPosition[0] - segmentLength*segmentDirection[0];
68 segmentInnerPoint[1] = segmentPosition[1] - segmentLength*segmentDirection[1];
69 segmentInnerPoint[2] = -segmentLength;
75 double mag =
sqrt( segmentDirection[0] * segmentDirection[0] +
76 segmentDirection[1] * segmentDirection[1] +
77 segmentDirection[2] * segmentDirection[2] );
79 double theta = atan2(
sqrt( segmentDirection[0] * segmentDirection[0]
80 + segmentDirection[1] * segmentDirection[1] ), segmentDirection[2] );
82 double newSegmentLength = segmentLength /
cos( theta );
84 segmentInnerPoint[0] = segmentPosition[0] + ( segmentDirection[0] /
mag ) * newSegmentLength;
85 segmentInnerPoint[1] = segmentPosition[1] + ( segmentDirection[1] /
mag ) * newSegmentLength;
86 segmentInnerPoint[2] = segmentPosition[2] + ( segmentDirection[2] /
mag ) * newSegmentLength;
88 segmentOuterPoint[0] = segmentPosition[0] - ( segmentDirection[0] /
mag ) * newSegmentLength;
89 segmentOuterPoint[1] = segmentPosition[1] - ( segmentDirection[1] /
mag ) * newSegmentLength;
90 segmentOuterPoint[2] = segmentPosition[2] - ( segmentDirection[2] /
mag ) * newSegmentLength;
92 if( fabs(segmentOuterPoint[0]) > segmentLimit )
94 segmentOuterPoint[0] = segmentLimit * ( segmentOuterPoint[0]/fabs( segmentOuterPoint[0] ));
95 segmentOuterPoint[1] = ( segmentOuterPoint[1]/fabs( segmentOuterPoint[1] )) *
tan( theta );
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Theta< T > theta() const
void createSegment(int detector, bool matchedSegment, float segmentLength, float segmentLimit, float *segmentPosition, float *segmentDirection, float *segmentInnerPoint, float *segmentOuterPoint)
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)