(filename string, N int, speed, length func(float64) float64, tmin, tmax float64)
| 861 | } |
| 862 | |
| 863 | func plotPathLengthParametrization(filename string, N int, speed, length func(float64) float64, tmin, tmax float64) { |
| 864 | Tc, totalLength := invSpeedPolynomialChebyshevApprox(N, gaussLegendre7, speed, tmin, tmax) |
| 865 | |
| 866 | n := 100 |
| 867 | realData := make(plotter.XYs, n+1) |
| 868 | modelData := make(plotter.XYs, n+1) |
| 869 | for i := 0; i < n+1; i++ { |
| 870 | t := tmin + (tmax-tmin)*float64(i)/float64(n) |
| 871 | l := totalLength * float64(i) / float64(n) |
| 872 | realData[i].X = length(t) |
| 873 | realData[i].Y = t |
| 874 | modelData[i].X = l |
| 875 | modelData[i].Y = Tc(l) |
| 876 | } |
| 877 | |
| 878 | scatter, err := plotter.NewScatter(realData) |
| 879 | if err != nil { |
| 880 | panic(err) |
| 881 | } |
| 882 | scatter.Shape = draw.CircleGlyph{} |
| 883 | |
| 884 | line, err := plotter.NewLine(modelData) |
| 885 | if err != nil { |
| 886 | panic(err) |
| 887 | } |
| 888 | line.LineStyle.Color = Red |
| 889 | line.LineStyle.Width = 2.0 |
| 890 | |
| 891 | p := plot.New() |
| 892 | p.X.Label.Text = "L" |
| 893 | p.Y.Label.Text = "t" |
| 894 | p.Add(scatter, line) |
| 895 | |
| 896 | p.Legend.Add("real", scatter) |
| 897 | p.Legend.Add(fmt.Sprintf("Chebyshev N=%v", N), line) |
| 898 | |
| 899 | if err := p.Save(7*vg.Inch, 4*vg.Inch, filename); err != nil { |
| 900 | panic(err) |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | func TestPathLengthParametrization(t *testing.T) { |
| 905 | if !testing.Verbose() { |
no test coverage detected