Ejemplo n.º 1
0
        private void Generate(IProjectorEngine projector)
        {
            var eps = 0.262;
            var b   = 20f;
            var a   = 20f;
            var u   = .0001;
            var n   = 10;
            var p   = (float)(a * Math.Cosh(u));
            var q   = (float)(b * Math.Sinh(u));
            var c1  = a / b;
            var c2  = b / a;
            var c   = (float)Math.Cosh(eps);
            var s   = (float)Math.Sinh(eps);

            (float, float)current = (0, 0);
            for (int i = 0; i < n; i++)
            {
                p = p * c + c1 * q * s;
                q = q * c + c2 * p * s;
                if (i == 0)
                {
                    current = (p, q);
                    continue;
                }
                projector.Graphics.DrawLine(PrimaryPen, p, q, current.Item1, current.Item2);
                current = (p, q);
            }
        }
Ejemplo n.º 2
0
        public override void Draw(IProjectorEngine projector)
        {
            var graphics = projector.Graphics;

            FillNewtonBasins(graphics,
                             (int)projector.Context.DrawableWidth,
                             (int)projector.Context.DrawableHeight);
        }
Ejemplo n.º 3
0
        public override void Draw(IProjectorEngine projector)
        {
            for (var i = 0; i < Model3D.GetLength(0) - 1; i++)
            {
                projector.DrawLine(Pens.CadetBlue, Model3D.point(i), Model3D.point(i + 1));
            }

            projector.DrawLine(Pens.CadetBlue, Model3D.point(Model3D.GetLength(0) - 1), Model3D.point(0));
        }
Ejemplo n.º 4
0
        public override void Draw(IProjectorEngine projector)
        {
            if (Model3D == default)
            {
                Reset(projector);
            }

            var vv    = projector.ViewVector(Model3D);
            var order = new List <(bool isVisible, (float x, float y, float z)[] Location)>();
Ejemplo n.º 5
0
 public virtual void Reset(IProjectorEngine projector)
 {
     if (Model3D == default)
     {
         return;
     }
     Transform(CG.RotY(.5f));
     Transform(CG.RotX(.5f));
     Transform(CG.TranslateZ(-12));
 }
 public void DrawAll(IProjectorEngine projector)
 {
     foreach (var extension in this)
     {
         if (extension.Enable && extension.Global || extension == Current)
         {
             extension.Draw(projector);
         }
     }
 }
Ejemplo n.º 7
0
 public override void Draw(IProjectorEngine projector)
 {
     for (int i = 1; i < Model3D.GetLength(0); i++)
     {
         // TODO: find out how to loop around all edges
         for (int j = i + 1; j < Model3D.GetLength(0); j++)
         {
             projector.DrawLine(PrimaryPen, Model3D.point(i), Model3D.point(j));
         }
     }
 }
Ejemplo n.º 8
0
 public override void Reset(IProjectorEngine projector)
 {
     Model3D = new[, ]
     {
         { 0f, 0, 0, 1 },
         { 1f, 0, 0, 1 },
         { 0, -1, 0, 1 },
         { 0, 0, 1, 1 }
     };
     base.Reset(projector);
 }
        public void BindTo(Control control, IProjectorEngine sender, PropertyInfo prop)
        {
            var ma = prop.GetCustomAttribute <ModifiableAttribute>();

            if (ma is null)
            {
                return;
            }

            BindComboBox(sender, control, prop, x => EngineChanged(x, ma.RequiresReset));
            BindCheckBox(sender, control, prop, x => EngineChanged(x, ma.RequiresReset));
            BindTrackBar(sender, control, prop, ma, x => EngineChanged(sender, ma.RequiresReset));
        }
Ejemplo n.º 10
0
        public override void Reset(IProjectorEngine projector)
        {
            Model3D = new[, ]
            {
                { 0f, 0, 0, 1 },
                { 0f, 2, 0, 1 },
                { 2, 2, 0, 1 },
                { 2, 0, 0, 1 },
            };
            for (int i = 2; i < 3; i++)
            {
                Model3D = Merge(Model3D, Model3D.Multiply(2));
            }

            base.Reset(projector);
        }
Ejemplo n.º 11
0
 public override void Reset(IProjectorEngine projector)
 {
     Model3D = new[, ]
     {
         { 0f, -1, 0, 1 }, //0 A
         { -1f, 0, 0, 1 }, //1 B
         { 0f, 1, 0, 1 },  //2 C
         { 1f, 0, 0, 1 },  //3 D
         { 0f, 0, 1, 1 },  //4 E
     };
     _faces = new[]
     {
         new[] { 0, 1, 2, 3 }, // ABCD
         new[] { 1, 4, 0 },    // BEA
         new[] { 0, 4, 3 },    // AED
         new[] { 2, 4, 1 },    // CEB
         new[] { 3, 4, 2 } // DEC
     };
     base.Reset(projector);
 }
Ejemplo n.º 12
0
        public override void Reset(IProjectorEngine projector)
        {
            /*var s = new Vector3(100, 1, 1);
             *
             * KeyPoints.Add(new SplinePoint(new Vector3(1, 28, 0) * s));
             * KeyPoints.Add(new SplinePoint(new Vector3(1.5f, 96, 0) * s));
             * KeyPoints.Add(new SplinePoint(new Vector3(2, 117, 0) * s));
             * KeyPoints.Add(new SplinePoint(new Vector3(2.5f, 181, 0) * s));
             * KeyPoints.Add(new SplinePoint(new Vector3(3, 106, 0) * s));
             * return;*/
            int randomPoints = 10;

            // randomize on each redraw
            KeyPoints.Clear();
            var b = projector.Context;

            var scaling = .015f;
            var offset = new Vector3(-10, -6, 0);
            int prewX = 100, prewY = 200;
            int stepX = (int)((b.DrawableWidth - prewX) / (randomPoints + 2));
            int stepY = (int)((b.DrawableHeight - prewY) / (randomPoints + 2));
            int stepZ = (int)(((b.DrawableHeight + b.DrawableWidth) / 2) / (randomPoints + 2));

            for (int i = 0, rit = 1; i < randomPoints; i++, rit++)
            {
                var(x, y, z) =
                    (_rand.Next(stepX * rit, stepX * (rit + 2)),
                     _rand.Next(stepY * rit, stepY * (rit + 2)),
                     Preserve3D ? _rand.Next(stepZ * rit, stepZ * (rit + 2)) : 0);

                KeyPoints.Add(new SplinePoint
                {
                    Position   = new Vector3(x, y, z) * scaling + offset,
                    Bias       = (float)_rand.NextDouble() * 2 - 1,
                    Continuity = (float)_rand.NextDouble() * 2 - 1,
                    Tension    = (float)_rand.NextDouble() * 2 - 1,
                });
            }
            base.Reset(projector);
        }
Ejemplo n.º 13
0
        public override void Draw(IProjectorEngine projector)
        {
            if (Model3D == default)
            {
                Reset(projector);
            }

            var colors = new[]
            {
                Pens.Red,
                Pens.Green,
                Pens.Yellow
            };

            for (var i = 1; i < Model3D.GetLength(0); i++)
            {
                projector.DrawLine(colors[i - 1], Model3D.point(i), Model3D.point(0));
            }

            GrawAxisName(projector, "x", Model3D.point(1));
            GrawAxisName(projector, "y", Model3D.point(2));
            GrawAxisName(projector, "z", Model3D.point(3));
        }
Ejemplo n.º 14
0
 public abstract void Draw(IProjectorEngine projector);
 public void InitializeAll(IProjectorEngine projector)
 {
     ForEach(x => x.Reset(projector));
 }
Ejemplo n.º 16
0
 private void EngineChanged(IProjectorEngine sender, bool resetModel)
 {
     OnEngineChanged?.Invoke(sender, resetModel);
 }
Ejemplo n.º 17
0
 public override void Draw(IProjectorEngine projector)
 {
     Generate(projector);
 }
Ejemplo n.º 18
0
 private void GrawAxisName(IProjectorEngine projector, string name, (float x, float y, float z) vertex)