Exemplo n.º 1
0
        public void Test2()
        {
            using (MaterialFormat mf = new MaterialFormat(@"C:\Temp\Default.mtl"))
            {
                mf.DefaultColors();
            }

            using (WavefrontFormat wf = new WavefrontFormat(@"C:\Temp\Radio+.obj"))
            {
                wf.LoadMaterialLib("Default.mtl");
                wf.DrawClotho(false, 10, "Red", "Yellow", "Green", "Magenta");
            }

            using (WavefrontFormat wf = new WavefrontFormat(@"C:\Temp\Radio-.obj"))
            {
                wf.LoadMaterialLib("Default.mtl");
                wf.DrawClotho(true, 10, "Blue", "Yellow", "Green", "Magenta");
            }
        }
Exemplo n.º 2
0
 public static MaterialFormat DefaultColors(this MaterialFormat mf)
 {
     mf.AddMaterial(new MaterialFormat.Mat("Black", Vec3d.FromRGB(0, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("White", Vec3d.FromRGB(255, 255, 255)));
     mf.AddMaterial(new MaterialFormat.Mat("Red", Vec3d.FromRGB(255, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Lime", Vec3d.FromRGB(0, 255, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Blue", Vec3d.FromRGB(0, 0, 255)));
     mf.AddMaterial(new MaterialFormat.Mat("Yellow", Vec3d.FromRGB(255, 255, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Cyan", Vec3d.FromRGB(0, 255, 255)));    // Aqua
     mf.AddMaterial(new MaterialFormat.Mat("Magenta", Vec3d.FromRGB(255, 0, 255))); // Fuchsia
     mf.AddMaterial(new MaterialFormat.Mat("Silver", Vec3d.FromRGB(192, 192, 192)));
     mf.AddMaterial(new MaterialFormat.Mat("Gray", Vec3d.FromRGB(128, 128, 128)));
     mf.AddMaterial(new MaterialFormat.Mat("Maroon", Vec3d.FromRGB(128, 0, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Olive", Vec3d.FromRGB(128, 128, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Green", Vec3d.FromRGB(0, 128, 0)));
     mf.AddMaterial(new MaterialFormat.Mat("Purple", Vec3d.FromRGB(128, 0, 128)));
     mf.AddMaterial(new MaterialFormat.Mat("Teal", Vec3d.FromRGB(0, 128, 128)));
     mf.AddMaterial(new MaterialFormat.Mat("Navy", Vec3d.FromRGB(0, 0, 128)));
     return(mf);
 }
Exemplo n.º 3
0
        public void Test2()
        {
            double a       = 10;
            bool   invertY = true;
            double maxL    = ClothoUtils.GetMaxL(a);

            int ysign = invertY ? -1 : 1;

            double[] angles =
            {
                ysign * 0,
                     ysign *SysMath.PI / 4,
                     ysign *SysMath.PI / 2,
                     ysign * 3 *SysMath.PI / 4
            };

            using (MaterialFormat mf = new MaterialFormat(@"C:\Temp\Default.mtl"))
            {
                mf.DefaultColors();
            }

            using (WavefrontFormat wf = new WavefrontFormat(@"C:\Temp\ClothoidArc2dTest_Test2.obj"))
            {
                wf.LoadMaterialLib("Default.mtl");
                wf.DrawClotho(invertY, a, "Red");

                foreach (double angle in angles)
                {
                    Vec2d  v = vecMath.NewRotate(angle);
                    double l = ClothoUtils.FindTangent(invertY, a, v);
                    wf.DrawLine("Green", ClothoUtils.Clotho(l, invertY, a), v);
                    wf.DrawLine("Magenta", ClothoUtils.Clotho(-l, invertY, a), v);
                }

                //wf.DrawLine("Yellow", new Vec2d(0, 0), new Vec2d(1, 0), 100);
                //wf.DrawLine("Yellow", new Vec2d(0, 0), new Vec2d(0, 1), 100);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Prueba el constructor ClothoidArc2d(double,Vec2d,Vec2d,double,double).
        /// </summary>
        private static void TestClotho(double a, bool invertY, bool negX, double tg0, double tg1, Vec2d p0, Vec2d dir,
                                       string fileName = null, bool toWavefront = false)
        {
            //double a = 5;
            //bool invertY = true;

            //double tg0 = -4 * SysMath.PI / 10;
            //double tg1 = -SysMath.PI / 10;

            // Si se indica negX, se invierten las tangentes.
            int sign = 1;

            if (negX)
            {
                sign = -1;
            }

            double l0 = sign * ClothoUtils.FindTangent(invertY, a, tg0);
            double l1 = sign * ClothoUtils.FindTangent(invertY, a, tg1);

            double r0  = ClothoUtils.ClothoRadious(l0, invertY, a);
            double r1  = ClothoUtils.ClothoRadious(l1, invertY, a);
            Vec2d  pp0 = ClothoUtils.Clotho(l0, invertY, a);
            Vec2d  pp1 = ClothoUtils.Clotho(l1, invertY, a);

            //Vec2d p0 = new Vec2d(5, 5);
            Vec2d p1 = p0.Add(dir.Mul(pp1.Sub(pp0).Length));

            ClothoidArc2 arc = new ClothoidArc2(l0, p0, p1, r0, r1);

            Assert.IsTrue(arc.Point0.EpsilonEquals(p0, ERROR));
            Assert.IsTrue(arc.Point1.EpsilonEquals(p1, ERROR));
            Assert.IsTrue(arc.GetRadius(arc.TMin).EpsilonEquals(r0, ERROR));
            Assert.IsTrue(arc.GetRadius(arc.TMax).EpsilonEquals(r1, ERROR)); // <-
            Assert.IsTrue(arc.InvertY == invertY);
            Assert.IsTrue(arc.A.EpsilonEquals(a, ERROR));

            // Salida por fichero de la prueba.
            if ((fileName != null) && toWavefront)
            {
                double figSize = 0.5;

                string mtl = Path.ChangeExtension(fileName, "mtl");

                using (MaterialFormat mf = new MaterialFormat(mtl))
                {
                    mf.DefaultColors();
                }

                using (WavefrontFormat wf = new WavefrontFormat(fileName))
                {
                    wf.LoadMaterialLib(Path.GetFileName(mtl));

                    wf.DrawLine("Yellow", Vec2d.Zero, new Vec2d(1, 0), 50);
                    wf.DrawLine("Yellow", Vec2d.Zero, new Vec2d(0, 1), 50);

                    wf.DrawFigure("Blue", WaveFigure.X, ClothoUtils.Clotho(l0, invertY, a), figSize);
                    wf.DrawFigure("Olive", WaveFigure.X, ClothoUtils.Clotho(l1, invertY, a), figSize);

                    wf.DrawClotho(invertY, a, "Red");

                    wf.DrawClotho("Magenta", arc);

                    wf.DrawFigure("Blue", WaveFigure.X, p0, figSize);
                    wf.DrawFigure("Olive", WaveFigure.X, p1, figSize);
                }
            }
        }