![]() |
Trax3 3.1.0
trax track library
|
Gets a segement length ds, so that the visible failure in a track would become smaller than some marginal distance of e. More...
Functions | |
| dclspc Length | trax::Segment (const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false) |
| Calculates a segment length ds so that the visible failure in a track would become smaller than some marginal distance of e. | |
| dclspc Length | trax::Segment (const Track &track, Length s, Length e, Length w, Length h, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false) |
| Works like the first overload, but takes the dimensions of the track model into account. | |
| dclspc Length | trax::Segment_Checked (const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false) |
| Works like Segment(), but checks the result and shrinks it if necessary. | |
| dclspc Length | trax::Segment_Checked (const Track &track, Length s, Length e, Length w, Length h, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false) |
| Works like the first overload, but takes the dimensions of the track model into account. | |
| dclspc Length | trax::Segment_TotallyChecked (const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false) |
| Works like Segment(), but checks the result. | |
| dclspc Length | trax::Segment_TotallyChecked (const Track &track, Length s, Length e, Length w, Length h, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false) |
| Works like the first overload, but takes the dimensions of the track model. into account. | |
Gets a segement length ds, so that the visible failure in a track would become smaller than some marginal distance of e.
| track | Track to get the segment for. |
| s | Parameter to evaluate the situation for [0,length]. |
| e | Distance failure that is assumed not to matter visibly. |
| w | maximum width of the track model. For asymmetric tracks take two times the widest side. |
| h | maximum height of the track model. For asymmetric tracks take two times the highest side. |
| segmentLimits | The minimum and maximum segment length to deliver. The last segment returned might be shorter, to go to the track's end. |
| ignoreCuvesTorsion | If true the torsion of the curve is not taken into consideration (but the twist still is). |
If it comes to rendering, we might want to break down a track into segments that are straight lines. This means, we graphically are working with incorrect T,N,B vectors over the length ds of this segment. This might result in visible errors that are about:
/// |dT| * ds <= e (1) /// |dN| * w/2 <= e (2) /// |dB| * h/2 <= e (3) ///
For small errors the dX = X(s+ds) - X(s) happen to be angles - times a radius it is an error in length. With w and h being the dimensions of the track model and ds being the segment length we are looking for. For a track model, we might want to limit the model's extents, so that w/2,h/2 <= ds. That would mean, we can guarantee (1)-(3) if we guarantee the following:
/// |dT| * ds <= e (4) /// |dN| * ds <= e (5) /// |dB| * ds <= e (6) ///
From Frenet https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas it follows:
/// (4) => ds <= sqrt(e/k) /// (5) => ds <= sqrt(e/sqrt(pow<2>(k)+pow<2>(t))) /// (6) => ds <= sqrt(e/|t|) /// /// k: curvature /// t: torsion ///
(5) Is the most restrictive and is targeted. s+ds will not exceed the end of the track. The curve is evaluated locally at s; so the ds has to be further limited to reasonably small values (compared to the changes of curvature and torsion) to guarantee that the condition really holds.
| std::logic_error | if no proper curve is attached with trhe track. |
| std::range_error | if s is outside the [0,Length()] range. |
| dclspc Length trax::Segment | ( | const Track & | track, |
| Length | s, | ||
| Length | e, | ||
| Length | w, | ||
| Length | h, | ||
| common::Interval< Length > | segmentLimits, | ||
| bool | ignoreCuvesTorsion = false ) |
Works like the first overload, but takes the dimensions of the track model into account.
In the above derivation it would follow:
/// (4) => ds <= sqrt(e/k) /// (5) => ds <= 2*e/(w * sqrt(pow<2>(k)+pow<2>(t))) /// (6) => ds <= 2*e/(h*|t|) ///
| dclspc Length trax::Segment_Checked | ( | const Track & | track, |
| Length | s, | ||
| Length | e, | ||
| common::Interval< Length > | segmentLimits, | ||
| bool | ignoreCuvesTorsion = false ) |
Works like Segment(), but checks the result and shrinks it if necessary.
This method might still deliver too large segments if the curve has huge changes inside the limits; for this reason do not choose the upper segment limit too big, since some sudden curve inside such a segment might get missed.
| dclspc Length trax::Segment_TotallyChecked | ( | const Track & | track, |
| Length | s, | ||
| Length | e, | ||
| common::Interval< Length > | segmentLimits, | ||
| bool | ignoreCuvesTorsion = false ) |
Works like Segment(), but checks the result.
This method might take a long time to compute, if segmentLimits.Near() is too small, but is guaranteed to not miss any curves with lengthes greater than segmentLimits.Near().