public override void Draw(Point cursorCoordinates)
        {
            if (count == 0)
            {
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
            }
            if (count == 1)
            {
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
            }
            if (count == 2 && (SystemCoordinates)cursorCoordinates != p1 && (SystemCoordinates)cursorCoordinates != p2)
            {
                if (SystemCoordinates.InOneLine(p1, cursorCoordinates, p2))
                {
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                    Line a = new Line(p1, p2, false);
                    a.Drawer(Color.Black, 2);
                }
                else
                {
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                    Circle a = new Circle(p1, cursorCoordinates, p2);
                    a.Draw();
                }
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
            }
            if (count == 3 && (SystemCoordinates)cursorCoordinates != p1 && (SystemCoordinates)cursorCoordinates != p2 && (SystemCoordinates)cursorCoordinates != p3)
            {
                if (SystemCoordinates.InOneLine(p1, cursorCoordinates, p2))
                {
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                    Line a = new Line(p1, p2, false);
                    a.Drawer(Color.Black, 2);
                }
                else
                {
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                    OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                    Circle a = new Circle(p1, cursorCoordinates, p2);
                    a.Draw();
                }

                if (!SystemCoordinates.InOneLine(p1, p3, p2))
                {
                    Circle b = new Circle(p1, p3, p2);
                    b.Draw();
                }
                else
                {
                    Line b = new Line(p1, p2, false);
                    b.Drawer(Color.Black, 2);
                }
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p3, 5);
            }
        }
Пример #2
0
        private void RebuildLense(SystemCoordinates center, SystemCoordinates p1, SystemCoordinates p2,
                                  SystemCoordinates p3, SystemCoordinates p4, SystemCoordinates p5, SystemCoordinates p6)
        {
            ic1 = false;
            ic2 = false;
            if (SystemCoordinates.InOneLine(p1, p2, p3))
            {
                l1 = new Line(p1, p3, false);
            }
            else
            {
                ic1 = true;
                c1  = new Circle(p1, p2, p3);
            }
            if (SystemCoordinates.InOneLine(p4, p5, p6))
            {
                l2 = new Line(p4, p6, false);
            }
            else
            {
                ic2 = true;
                c2  = new Circle(p4, p5, p6);
            }
            //length = p1.Distance(p3);
            Line l = new Line(p1, p3, false);

            menisk = DoubleExtention.MinimumOf(p3.Distance(p4), p3.Distance(p6));
            if (menisk != 0)
            {
                if (p3.Distance(p4) < p3.Distance(p6))
                {
                    menisk1 = new Line(p3, p4, false);
                    menisk2 = new Line(p1, p6, false);
                }
                else
                {
                    menisk1 = new Line(p3, p6, false);
                    menisk2 = new Line(p1, p4, false);
                }
            }
            coordinates = center;
            this.p2     = p2;
            this.p5     = p5;
        }
Пример #3
0
        public Lense(string name, SystemCoordinates center, SystemCoordinates p1, SystemCoordinates p2, SystemCoordinates p3, SystemCoordinates p4, SystemCoordinates p5, SystemCoordinates p6)
        {
            ic1 = false;
            ic2 = false;
            if (SystemCoordinates.InOneLine(p1, p2, p3))
            {
                l1 = new Line(p1, p3, false);
            }
            else
            {
                ic1 = true;
                c1  = new Circle(p1, p2, p3);
            }
            if (SystemCoordinates.InOneLine(p4, p5, p6))
            {
                l2 = new Line(p4, p6, false);
            }
            else
            {
                ic2 = true;
                c2  = new Circle(p4, p5, p6);
            }
            Line l = new Line(p1, p3, false);

            menisk = DoubleExtention.MinimumOf(p3.Distance(p4), p3.Distance(p6));
            if (menisk != 0)
            {
                if (p3.Distance(p4) < p3.Distance(p6))
                {
                    menisk1 = new Line(p3, p4, false);
                    menisk2 = new Line(p1, p6, false);
                }
                else
                {
                    menisk1 = new Line(p3, p6, false);
                    menisk2 = new Line(p1, p4, false);
                }
            }
            coordinates = center;
            this.name   = name;
            this.p2     = p2;
            this.p5     = p5;
        }
 public override void Action(Point cursorCoordinates)
 {
     if (count == 0)
     {
         p1 = cursorCoordinates;
         count++;
     }
     else
     {
         if (count == 1 && cursorCoordinates != p1.ToScreen())
         {
             p2 = cursorCoordinates;
             count++;
         }
         else
         {
             if (count == 2 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen())
             {
                 p3 = cursorCoordinates;
                 count++;
             }
             else if (count == 3 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen() &&
                      cursorCoordinates != p3.ToScreen())
             {
                 if (!(SystemCoordinates.InOneLine(p1, p3, p2) && SystemCoordinates.InOneLine(p1, cursorCoordinates, p2)))
                 {
                     p4 = cursorCoordinates;
                     count++;
                 }
             }
             if (count == 4)
             {
                 Line aa = new Line(p1, p2, false);
                 ObjectCollection.Instance.AddObject(
                     new Lense(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.Lense)), aa.Center, p1, p3,
                               p2, p1,
                               p4, p2));
                 Deactivate();
             }
         }
     }
 }
Пример #5
0
 public override void Draw(Point cursorCoordinates)
 {
     if (count == 0)
     {
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), cursorCoordinates, 2);
     }
     if (count == 1)
     {
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), c1, 2);
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), cursorCoordinates, 2);
     }
     if (count == 2)
     {
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), c1, 2);
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), c2, 2);
         if (!SystemCoordinates.InOneLine(c1, c2, cursorCoordinates))
         {
             Circle      a = new Circle(c1, cursorCoordinates, c2);
             ObjectProto x = new SphereMirror("A~~112e^", a.Center, a.Radius, c1, cursorCoordinates, c2, control_modifier);
             x.Drawer();
         }
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), cursorCoordinates, 2);
     }
     if (count == 3)
     {
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), c1, 2);
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), c2, 2);
         OGL.DrawFilledCircle(new Pen(Color.Yellow, 4), c3, 2);
         if (!SystemCoordinates.InOneLine(c1, c2, c3))
         {
             Circle      a = new Circle(c1, c3, c2);
             ObjectProto x = new SphereMirror("A~~112e^", a.Center, a.Radius, c1, c3, c2, control_modifier);
             x.Drawer();
         }
     }
 }
Пример #6
0
 public Lense(string savestr)
 {
     string[] splitted = savestr.Split('^');
     if (splitted.Length != 18)
     {
         throw new ErrorWhileReading();
     }
     else
     {
         try
         {
             name        = splitted[1];
             coordinates = new SystemCoordinates(Convert.ToDouble(splitted[2]), Convert.ToDouble(splitted[3]));
             SystemCoordinates p1, p2, p3, p4, p5, p6;
             p1  = new SystemCoordinates(Convert.ToDouble(splitted[4]), Convert.ToDouble(splitted[5]));
             p2  = new SystemCoordinates(Convert.ToDouble(splitted[6]), Convert.ToDouble(splitted[7]));
             p3  = new SystemCoordinates(Convert.ToDouble(splitted[8]), Convert.ToDouble(splitted[9]));
             p4  = new SystemCoordinates(Convert.ToDouble(splitted[10]), Convert.ToDouble(splitted[11]));
             p5  = new SystemCoordinates(Convert.ToDouble(splitted[12]), Convert.ToDouble(splitted[13]));
             p6  = new SystemCoordinates(Convert.ToDouble(splitted[14]), Convert.ToDouble(splitted[15]));
             ic1 = false;
             ic2 = false;
             if (SystemCoordinates.InOneLine(p1, p2, p3))
             {
                 l1 = new Line(p1, p3, false);
             }
             else
             {
                 ic1 = true;
                 c1  = new Circle(p1, p2, p3);
             }
             if (SystemCoordinates.InOneLine(p4, p5, p6))
             {
                 l2 = new Line(p4, p6, false);
             }
             else
             {
                 ic2 = true;
                 c2  = new Circle(p4, p5, p6);
             }
             Line l = new Line(p1, p3, false);
             menisk = DoubleExtention.MinimumOf(p3.Distance(p4), p3.Distance(p6));
             if (menisk != 0)
             {
                 if (p3.Distance(p4) < p3.Distance(p6))
                 {
                     menisk1 = new Line(p3, p4, false);
                     menisk2 = new Line(p1, p6, false);
                 }
                 else
                 {
                     menisk1 = new Line(p3, p6, false);
                     menisk2 = new Line(p1, p4, false);
                 }
             }
             id             = Convert.ToInt32(splitted[16]);
             opticalDensity = Convert.ToDouble(splitted[17]);
             this.p2        = p2;
             this.p5        = p5;
         }
         catch (Exception e)
         {
             throw;
         }
     }
 }
        public override void Draw(Point cursorCoordinates)
        {
            SystemCoordinates P1, P3, P4, P6;

            if (count == 0)
            {
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
            }
            if (count == 1)
            {
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
            }
            if (count == 2 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p2.ToScreen())
            {
                Line            x = p1 + p2;
                DoubleExtention l = x.DistanceToPoint(cursorCoordinates);
                Line            z = x.BuildOrthogonalLine(p2);
                z.BuildAngle();
                if (z.AngleForOnePointLines == new Angle(90, false) || z.AngleForOnePointLines == new Angle(90, false))
                {
                    z.FirstEnd  = new SystemCoordinates(p2.X, p2.Y + l);
                    z.SecondEnd = new SystemCoordinates(p2.X, p2.Y - l);
                }
                else
                {
                    z.FirstEnd  = new SystemCoordinates(p2.X + l * z.AngleForOnePointLines.cos(), p2.Y + l * z.AngleForOnePointLines.sin());
                    z.SecondEnd = new SystemCoordinates(p2.X - l * z.AngleForOnePointLines.cos(), p2.Y + l * z.AngleForOnePointLines.sin());
                }
                Line u = x.BuildOrthogonalLine(p1);
                u.BuildAngle();
                if (u.AngleForOnePointLines == new Angle(90, false) || u.AngleForOnePointLines == new Angle(90, false))
                {
                    u.FirstEnd  = new SystemCoordinates(p1.X, p1.Y + l);
                    u.SecondEnd = new SystemCoordinates(p1.X, p1.Y - l);
                }
                else
                {
                    u.FirstEnd  = new SystemCoordinates(p1.X + l * u.AngleForOnePointLines.cos(), p1.Y + l * u.AngleForOnePointLines.sin());
                    u.SecondEnd = new SystemCoordinates(p1.X - l * u.AngleForOnePointLines.cos(), p1.Y + l * u.AngleForOnePointLines.sin());
                }
                P1 = z.FirstEnd;
                P3 = z.SecondEnd;
                P4 = u.FirstEnd;
                P6 = u.SecondEnd;
                u  = new Line(P1, P3, false);
                z  = new Line(P4, P6, false);
                u.Drawer(2);
                z.Drawer(2);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), P1, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), P3, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), P4, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), P6, 5);
            }
            if (count == 3 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p3.ToScreen() && cursorCoordinates != p4.ToScreen() && cursorCoordinates != p6.ToScreen())
            {
                Line z = new Line(p1, p3, false);
                Line u = new Line(p4, p6, false);
                z.Drawer(2);
                u.Drawer(2);

                if (p1.Distance(p4) < p1.Distance(p6))
                {
                    Circle beta  = null;
                    Line   alpha = null;
                    if (SystemCoordinates.InOneLine(p1, cursorCoordinates, p4))
                    {
                        alpha = new Line(p1, p4, false);
                    }
                    else
                    {
                        beta = new Circle(p1, cursorCoordinates, p4);
                    }
                    if (alpha != null)
                    {
                        alpha.Drawer(Color.Black, 2);
                    }
                    if (beta != null)
                    {
                        beta.Draw(false);
                    }
                }
                else
                {
                    Circle beta  = null;
                    Line   alpha = null;
                    if (SystemCoordinates.InOneLine(p1, cursorCoordinates, p6))
                    {
                        alpha = new Line(p1, p6, false);
                    }
                    else
                    {
                        beta = new Circle(p1, cursorCoordinates, p6);
                    }
                    if (alpha != null)
                    {
                        alpha.Drawer(Color.Black, 2);
                    }
                    if (beta != null)
                    {
                        beta.Draw(false);
                    }
                }
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p3, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p4, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p6, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
            }
            if (count == 4 && cursorCoordinates != p1.ToScreen() && cursorCoordinates != p3.ToScreen() && cursorCoordinates != p4.ToScreen() && cursorCoordinates != p6.ToScreen())
            {
                Line z = new Line(p1, p3, false);
                Line u = new Line(p4, p6, false);
                z.Drawer(2);
                u.Drawer(2);
                if (p1.Distance(p4) < p1.Distance(p6))
                {
                    Line   beta_x = null;
                    Line   alpha_x = null;
                    Circle alpha = null, beta = null;
                    if (SystemCoordinates.InOneLine(p1, p2, p4))
                    {
                        beta_x = new Line(p1, p4, false);
                    }
                    else
                    {
                        beta = new Circle(p1, p2, p4);
                    }
                    if (SystemCoordinates.InOneLine(p3, cursorCoordinates, p6))
                    {
                        alpha_x = new Line(p3, p6, false);
                    }
                    else
                    {
                        alpha = new Circle(p3, cursorCoordinates, p6);
                    }
                    if (beta != null)
                    {
                        beta.Draw(false);
                    }
                    if (alpha != null)
                    {
                        alpha.Draw(false);
                    }
                    if (beta_x != null)
                    {
                        beta_x.Drawer(2);
                    }
                    if (alpha_x != null)
                    {
                        alpha_x.Drawer(2);
                    }
                }
                else
                {
                    Line   beta_x  = null;
                    Line   alpha_x = null;
                    Circle beta    = null;
                    Circle alpha   = null;
                    if (SystemCoordinates.InOneLine(p1, p2, p6))
                    {
                        beta_x = new Line(p1, p6, false);
                    }
                    else
                    {
                        beta = new Circle(p1, p2, p6);
                    }
                    if (SystemCoordinates.InOneLine(p3, cursorCoordinates, p4))
                    {
                        alpha_x = new Line(p3, p4, false);
                    }
                    else
                    {
                        alpha = new Circle(p3, cursorCoordinates, p4);
                    }
                    if (beta != null)
                    {
                        beta.Draw(false);
                    }
                    if (alpha != null)
                    {
                        alpha.Draw(false);
                    }
                    if (beta_x != null)
                    {
                        beta_x.Drawer(2);
                    }
                    if (alpha_x != null)
                    {
                        alpha_x.Drawer(2);
                    }
                }
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p3, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p4, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p6, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 5);
            }
            if (count == 5)
            {
                Line z = new Line(p1, p3, false);
                Line u = new Line(p4, p6, false);
                z.Drawer(2);
                u.Drawer(2);
                if (p1.Distance(p4) < p1.Distance(p6))
                {
                    Line   beta_x = null;
                    Line   alpha_x = null;
                    Circle alpha = null, beta = null;
                    if (SystemCoordinates.InOneLine(p1, p2, p4))
                    {
                        beta_x = new Line(p1, p4, false);
                    }
                    else
                    {
                        beta = new Circle(p1, p2, p4);
                    }
                    if (SystemCoordinates.InOneLine(p3, p5, p6))
                    {
                        alpha_x = new Line(p3, p6, false);
                    }
                    else
                    {
                        alpha = new Circle(p3, p5, p6);
                    }
                    if (beta != null)
                    {
                        beta.Draw(false);
                    }
                    if (alpha != null)
                    {
                        alpha.Draw(false);
                    }
                    if (beta_x != null)
                    {
                        beta_x.Drawer(2);
                    }
                    if (alpha_x != null)
                    {
                        alpha_x.Drawer(2);
                    }
                }
                else
                {
                    Line   beta_x  = null;
                    Line   alpha_x = null;
                    Circle beta    = null;
                    Circle alpha   = null;
                    if (SystemCoordinates.InOneLine(p1, p2, p6))
                    {
                        beta_x = new Line(p1, p6, false);
                    }
                    else
                    {
                        beta = new Circle(p1, p2, p6);
                    }
                    if (SystemCoordinates.InOneLine(p3, p5, p4))
                    {
                        alpha_x = new Line(p3, p4, false);
                    }
                    else
                    {
                        alpha = new Circle(p3, p5, p4);
                    }
                    if (beta != null)
                    {
                        beta.Draw(false);
                    }
                    if (alpha != null)
                    {
                        alpha.Draw(false);
                    }
                    if (beta_x != null)
                    {
                        beta_x.Drawer(2);
                    }
                    if (alpha_x != null)
                    {
                        alpha_x.Drawer(2);
                    }
                }
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p3, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p4, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p6, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p2, 5);
                OGL.DrawFilledCircle(new Pen(Color.Yellow), p5, 5);
            }
        }
Пример #8
0
 public override void Action(Point cursorCoordinates)
 {
     if (count == 0)
     {
         c1 = cursorCoordinates;
         count++;
     }
     else
     if (count == 1 && c1.ToScreen() != cursorCoordinates)
     {
         c2 = cursorCoordinates;
         count++;
     }
     else if (count == 2 && c1.ToScreen() != cursorCoordinates && c2.ToScreen() != cursorCoordinates && !SystemCoordinates.InOneLine(c1, c2, cursorCoordinates))
     {
         c3 = cursorCoordinates;
         count++;
         Circle a = new Circle(c1, c3, c2);
         ObjectCollection.Instance.AddObject(
             new SphereMirror(ObjectProto.GenName(ObjectProto.GetSpec(ObjectTypes.SphereMirror)), a.Center,
                              a.Radius, c1, c3, c2, control_modifier));
         Deactivate();
     }
 }