public static WavefrontFormat DrawClothoRadius(this WavefrontFormat wf, bool invertY, double a, string radiusColor) { List <int> indices = new List <int>(); double lmax = ClothoUtils.GetMaxL(a); int c = 100; for (int i = -c; i <= c; i++) { double s = i * lmax / c; double r = ClothoUtils.ClothoRadious(s, invertY, a); if (double.IsInfinity(r)) { r = SysMath.Sign(r) * 1000; } int v0 = wf.AddVertex(new Vec2d(s, r)); indices.Add(v0); //double dx, dy; //MathUtils.DClotho(s, r, a, out dx, out dy); } wf.UseMaterial(radiusColor); wf.AddLines(indices, false); return(wf); }
public static WavefrontFormat DrawClotho(this WavefrontFormat wf, bool invertY, double a, string clothoColor) { List <int> indices = new List <int>(); int c = 100; for (int i = -c; i <= c; i++) { double lmax = ClothoUtils.GetMaxL(a); double s = i * lmax / c; double x, y; ClothoUtils.Clotho(s, invertY, a, out x, out y); int v0 = wf.AddVertex(new Vec2d(x, y)); indices.Add(v0); //double dx, dy; //MathUtils.DClotho(s, r, a, out dx, out dy); } wf.UseMaterial(clothoColor); wf.AddLines(indices, false); return(wf); }
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; double x, y; ClothoUtils.Clotho(s, invertY, a, out x, out y); int v0 = wf.AddVertex(new Vec2d(x, y)); indices.Add(v0); Vec2d n = ClothoUtils.ClothoLeftNormal(s, invertY, a).Norm(); int v1 = wf.AddVertex(new Vec2d(x + n.X, y + n.Y)); normals.Add(Tuple.Create(v0, v1)); double dir = ClothoUtils.ClothoTangent(s, invertY, a); double dx = SysMath.Cos(dir); double dy = SysMath.Sin(dir); Vec2d d = new Vec2d(dx, dy).Norm(); int v2 = wf.AddVertex(new Vec2d(x + 5 * d.X, y + 5 * d.Y)); dirs.Add(Tuple.Create(v0, v2)); double r = ClothoUtils.ClothoRadious(s, invertY, a); if (double.IsInfinity(r)) { r = SysMath.Sign(r) * 100; } int v3 = wf.AddVertex(new Vec2d(x + r * n.X, y + r * n.Y)); 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); }