13 float* segmentPosition,
14 float* segmentDirection,
15 float* segmentInnerPoint,
16 float* segmentOuterPoint) {
19 segmentOuterPoint[0] = segmentPosition[0] + segmentLength * segmentDirection[0];
20 segmentOuterPoint[1] = segmentPosition[1] + segmentLength * segmentDirection[1];
21 segmentOuterPoint[2] = segmentLength;
23 if (fabs(segmentOuterPoint[1]) > segmentLimit)
24 segmentOuterPoint[1] = segmentLimit * (segmentOuterPoint[1] / fabs(segmentOuterPoint[1]));
26 segmentInnerPoint[0] = segmentPosition[0] - segmentLength * segmentDirection[0];
27 segmentInnerPoint[1] = segmentPosition[1] - segmentLength * segmentDirection[1];
28 segmentInnerPoint[2] = -segmentLength;
30 if (fabs(segmentInnerPoint[1]) > segmentLimit)
31 segmentInnerPoint[1] = segmentLimit * (segmentInnerPoint[1] / fabs(segmentInnerPoint[1]));
35 segmentOuterPoint[0] = segmentPosition[0] + segmentDirection[0] * (segmentPosition[2] / segmentDirection[2]);
36 segmentOuterPoint[1] = segmentPosition[1] + segmentDirection[1] * (segmentPosition[2] / segmentDirection[2]);
37 segmentOuterPoint[2] = segmentPosition[2];
39 if (fabs(segmentOuterPoint[1]) > segmentLength)
40 segmentOuterPoint[1] = segmentLength * (segmentOuterPoint[1] / fabs(segmentOuterPoint[1]));
42 segmentInnerPoint[0] = segmentPosition[0] - segmentDirection[0] * (segmentPosition[2] / segmentDirection[2]);
43 segmentInnerPoint[1] = segmentPosition[1] - segmentDirection[1] * (segmentPosition[2] / segmentDirection[2]);
44 segmentInnerPoint[2] = -segmentPosition[2];
46 if (fabs(segmentInnerPoint[1]) > segmentLength)
47 segmentInnerPoint[1] = segmentLength * (segmentInnerPoint[1] / fabs(segmentInnerPoint[1]));
55 segmentOuterPoint[0] = segmentPosition[0] + segmentLength * segmentDirection[0];
56 segmentOuterPoint[1] = segmentPosition[1] + segmentLength * segmentDirection[1];
57 segmentOuterPoint[2] = segmentLength;
59 segmentInnerPoint[0] = segmentPosition[0] - segmentLength * segmentDirection[0];
60 segmentInnerPoint[1] = segmentPosition[1] - segmentLength * segmentDirection[1];
61 segmentInnerPoint[2] = -segmentLength;
65 double mag =
sqrt(segmentDirection[0] * segmentDirection[0] + segmentDirection[1] * segmentDirection[1] +
66 segmentDirection[2] * segmentDirection[2]);
69 atan2(
sqrt(segmentDirection[0] * segmentDirection[0] + segmentDirection[1] * segmentDirection[1]),
72 double newSegmentLength = segmentLength /
cos(theta);
74 segmentInnerPoint[0] = segmentPosition[0] + (segmentDirection[0] /
mag) * newSegmentLength;
75 segmentInnerPoint[1] = segmentPosition[1] + (segmentDirection[1] /
mag) * newSegmentLength;
76 segmentInnerPoint[2] = segmentPosition[2] + (segmentDirection[2] /
mag) * newSegmentLength;
78 segmentOuterPoint[0] = segmentPosition[0] - (segmentDirection[0] /
mag) * newSegmentLength;
79 segmentOuterPoint[1] = segmentPosition[1] - (segmentDirection[1] /
mag) * newSegmentLength;
80 segmentOuterPoint[2] = segmentPosition[2] - (segmentDirection[2] /
mag) * newSegmentLength;
82 if (fabs(segmentOuterPoint[0]) > segmentLimit) {
83 segmentOuterPoint[0] = segmentLimit * (segmentOuterPoint[0] / fabs(segmentOuterPoint[0]));
84 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)