public void Test1() { const double error = 1e-8; // desarrollo, r, parametro, x, y, c, normal ¿o direccion?, for (int i = 0; i < this.testData1.Length;) { double l = this.testData1[i++]; double r = this.testData1[i++]; double a = this.testData1[i++]; double x = this.testData1[i++]; double y = this.testData1[i++]; double radio = this.testData1[i++]; double tg = this.testData1[i++]; bool invertY = ((l < 0 && r > 0) || (l > 0 && r < 0)); double x2, y2; ClothoUtils.Clotho(l, invertY, a, out x2, out y2); double radio2 = ClothoUtils.ClothoRadius(l, invertY, a); double tg2 = ClothoUtils.ClothoTangent(l, invertY, a); Assert.IsTrue(x.EpsilonEquals(x2, error)); Assert.IsTrue(y.EpsilonEquals(y2, error)); Assert.IsTrue((double.IsInfinity(radio) && double.IsInfinity(radio2)) || radio.EpsilonEquals(radio2, error)); Assert.IsTrue(AngleUtils.Ensure0To2Pi(tg).EpsilonEquals(AngleUtils.Ensure0To2Pi(tg2), error)); } }
public void Test1() { const double error = 1e-8; // desarrollo, r, parametro, x, y, c, normal ¿o direction?, for (int i = 0; i < this.testData1.Length;) { double s = this.testData1[i++]; double r = this.testData1[i++]; double a = this.testData1[i++]; double x = this.testData1[i++]; double y = this.testData1[i++]; double radio = this.testData1[i++]; double tg = this.testData1[i++]; // NOTA: Clip toma las clotoides con s < 0 invertidas en Y. if (s < 0) { y = -y; tg = 2 * SysMath.PI - tg; radio = -radio; } double x2, y2; ClothoUtils.Clotho(s, r < 0, a, out x2, out y2); double radio2 = ClothoUtils.ClothoRadious(s, r < 0, a); double tg2 = ClothoUtils.ClothoTangent(s, r < 0, a); double direction2 = ClothoUtils.ClothoTangent(s, r < 0, a); Assert.IsTrue(x.EpsilonEquals(x2, error)); Assert.IsTrue(y.EpsilonEquals(y2, error)); Assert.IsTrue((double.IsInfinity(radio) && double.IsInfinity(radio2)) || radio.EpsilonEquals(radio2, error)); //Assert.IsTrue(AngleUtils.Ensure0To2Pi(normal).EpsilonEquals(AngleUtils.Ensure0To2Pi(normal2), error)); //Assert.IsTrue(AngleUtils.Ensure0To2Pi(tg).EpsilonEquals(AngleUtils.Ensure0To2Pi(tg2), error)); } }
public new double GetTangent(double t) { double dl = this.GetL(t); return(ClothoUtils.ClothoTangent(dl, this.InvertY, this.A)); }
public static WavefrontFormat DrawClotho(this WavefrontFormat wf, bool invertY, double a, string clothoColor, string dirColor, string normalColor, string radColor) { List <int> indices = new List <int>(); List <Tuple <int, int> > normals = new List <Tuple <int, int> >(); List <Tuple <int, int> > dirs = new List <Tuple <int, int> >(); List <Tuple <int, int> > radius = new List <Tuple <int, int> >(); int c = 100; for (int i = -c; i <= c; i++) { double lmax = ClothoUtils.GetMaxL(a); double s = i * lmax / c; Point2d xy = ClothoUtils.Clotho(s, invertY, a); int v0 = wf.AddVertex(xy); indices.Add(v0); Vector2d n = ClothoUtils.ClothoLeftNormal(s, invertY, a).Unit; int v1 = wf.AddVertex(xy.Add(n)); normals.Add(Tuple.Create(v0, v1)); double dir = ClothoUtils.ClothoTangent(s, invertY, a); Vector2d d = Vector2d.NewRotate(dir); int v2 = wf.AddVertex(xy.Add(d.Mul(5))); dirs.Add(Tuple.Create(v0, v2)); double r = ClothoUtils.ClothoRadius(s, invertY, a); if (double.IsInfinity(r)) { r = SysMath.Sign(r) * 100; } int v3 = wf.AddVertex(xy.Add(n.Mul(r))); radius.Add(Tuple.Create(v0, v3)); //double dx, dy; //MathUtils.DClotho(s, r, a, out dx, out dy); } wf.UseMaterial(clothoColor); wf.AddLines(indices, false); wf.UseMaterial(normalColor); foreach (Tuple <int, int> normal in normals) { wf.AddLines(new[] { normal.Item1, normal.Item2 }, false); } wf.UseMaterial(dirColor); foreach (Tuple <int, int> dir in dirs) { wf.AddLines(new[] { dir.Item1, dir.Item2 }, false); } wf.UseMaterial(radColor); foreach (Tuple <int, int> rr in radius) { wf.AddLines(new[] { rr.Item1, rr.Item2 }, false); } return(wf); }