Ejemplo n.º 1
0
 public static void determinerIntersectionDroiteCercle(cercle leCercle, droite laDroite, ref intersection intersectionObjet)
 {
     solution solutionIntersection = new solution();
     double angleRad = laDroite.droiteInclinaison;
     angleRad /= 1000;
     int alphaDegre = (int)Math.convertRadianToDegree(angleRad);
     int a = 1;
     int b = 2 * (int)(((laDroite.droiteOrigineX - leCercle.cercleCentreX) * Math.cosinus(alphaDegre)) + ((laDroite.droiteOrigineY - leCercle.cercleCentreY) * Math.sinus(alphaDegre)));
     int c = (laDroite.droiteOrigineX - leCercle.cercleCentreX) * (laDroite.droiteOrigineX - leCercle.cercleCentreX) + (laDroite.droiteOrigineY - leCercle.cercleCentreY) * (laDroite.droiteOrigineY - leCercle.cercleCentreY) - leCercle.cercleRayon * leCercle.cercleRayon;
     resoudre(a, b, c, ref solutionIntersection);
     switch (solutionIntersection.nature)
     {
         case natureSolution.NON_DETERMINEE:
             intersectionObjet.nature = natureIntersection.INFINITE;
             intersectionObjet.X1 = 0;
             intersectionObjet.Y1 = 0;
             break;
         case natureSolution.PAS_DE_SOLUTION:
             intersectionObjet.nature = natureIntersection.DISTINCT;
             intersectionObjet.X1 = 0;
             intersectionObjet.Y1 = 0;
             break;
         case natureSolution.SIMPLE:
             intersectionObjet.nature = natureIntersection.SECANT;
             intersectionObjet.X1 = (int)(laDroite.droiteOrigineX + solutionIntersection.X1 * (Microsoft.SPOT.Math.Cos(alphaDegre) / 1000));
             intersectionObjet.Y1 = (int)(laDroite.droiteOrigineY + solutionIntersection.X1 * (Microsoft.SPOT.Math.Sin(alphaDegre) / 1000));
             break;
         case natureSolution.DOUBLE:
             intersectionObjet.nature = natureIntersection.SECANT;
             intersectionObjet.X1 = (int)(laDroite.droiteOrigineX + solutionIntersection.X1 * cosinus(alphaDegre));
             intersectionObjet.Y1 = (int)(laDroite.droiteOrigineY + solutionIntersection.X1 * sinus(alphaDegre));
             intersectionObjet.X2 = (int)(laDroite.droiteOrigineX + solutionIntersection.X2 * cosinus(alphaDegre));
             intersectionObjet.Y2 = (int)(laDroite.droiteOrigineY + solutionIntersection.X2 * sinus(alphaDegre));
             break;
         case natureSolution.COMPLEXE:
             intersectionObjet.nature = natureIntersection.DISTINCT;
             break;
     }
 }
Ejemplo n.º 2
0
        private void filling_the_board()
        {
            int    s = 50;
            double x = 0.0;
            int    f = -1;

NEW:
            f++;

            if (f == 8)
            {
                x = x + 50;
                s = 50;
            }
            if (f == 16)
            {
                x = x + 50;
                s = 50;
            }
            if (f == 24)
            {
                x = x + 50;
                s = 50;
            }
            if (f == 32)
            {
                x = x + 50;
                s = 50;
            }
            if (f == 40)
            {
                x = x + 50;
                s = 50;
            }
            if (f == 48)
            {
                x = x + 50;
                s = 50;
            }
            if (f == 56)
            {
                x = x + 50;
                s = 50;
            }
            if (f >= 64)
            {
                goto Exit;
            }
            Storyboard      down            = new Storyboard();
            DoubleAnimation doubleAnimation = new DoubleAnimation();

            doubleAnimation.To       = game_board.Height - s;
            doubleAnimation.Duration = TimeSpan.FromSeconds(0.5);
            Random r = new Random(f + Environment.TickCount - Environment.ProcessorCount - (int)x);

            switch (r.Next(1, 16))
            {
            case 1:
                cercle cer = new cercle();
                cer.SetValue(Canvas.LeftProperty, x);
                cer.SetValue(Canvas.TopProperty, (double)s);
                game_board.Children.Add(cer);
                Storyboard.SetTarget(doubleAnimation, cer);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Top)"));
                down.Children.Add(doubleAnimation);
                down.Duration  = doubleAnimation.Duration;
                cer.CordinateX = Canvas.GetLeft(cer);
                cer.CordinateY = Canvas.GetTop(cer);
                cer.MouseDown += Cer_MouseDown;
                down.Begin();
                s = s + 50;
                goto NEW;

            case 9: goto case 1;

            case 11: goto case 1;

            case 2:
                hexagon hex = new hexagon();
                hex.SetValue(Canvas.LeftProperty, x);
                hex.SetValue(Canvas.TopProperty, (double)s);
                game_board.Children.Add(hex);
                Storyboard.SetTarget(doubleAnimation, hex);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Top)"));
                down.Children.Add(doubleAnimation);
                down.Duration  = doubleAnimation.Duration;
                hex.CordinateX = Canvas.GetLeft(hex);
                hex.CordinateY = Canvas.GetTop(hex);
                hex.MouseDown += Hex_MouseDown;
                down.Begin();
                s = s + 50;
                goto NEW;

            case 7: goto case 2;

            case 15: goto case 2;

            case 3:
                pentahedron pent = new pentahedron();
                pent.SetValue(Canvas.LeftProperty, x);
                pent.SetValue(Canvas.TopProperty, (double)s);
                game_board.Children.Add(pent);
                Storyboard.SetTarget(doubleAnimation, pent);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Top)"));
                down.Children.Add(doubleAnimation);
                down.Duration   = doubleAnimation.Duration;
                pent.CordinateX = Canvas.GetLeft(pent);
                pent.CordinateY = Canvas.GetTop(pent);
                pent.MouseDown += Pent_MouseDown;
                down.Begin();
                s = s + 50;
                goto NEW;

            case 6: goto case 3;

            case 10: goto case 3;

            case 4:
                square squ = new square();
                squ.SetValue(Canvas.LeftProperty, x);
                squ.SetValue(Canvas.TopProperty, (double)s);
                game_board.Children.Add(squ);
                Storyboard.SetTarget(doubleAnimation, squ);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Top)"));
                down.Children.Add(doubleAnimation);
                down.Duration  = doubleAnimation.Duration;
                squ.CordinateX = Canvas.GetLeft(squ);
                squ.CordinateY = Canvas.GetTop(squ);
                squ.MouseDown += Squ_MouseDown;
                down.Begin();


                s = s + 50;
                goto NEW;

            case 8: goto case 4;

            case 13: goto case 4;

            case 5:
                triangle tri = new triangle();
                tri.SetValue(Canvas.LeftProperty, x);
                tri.SetValue(Canvas.TopProperty, (double)s);
                game_board.Children.Add(tri);
                Storyboard.SetTarget(doubleAnimation, tri);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Top)"));
                down.Children.Add(doubleAnimation);
                down.Duration  = doubleAnimation.Duration;
                tri.CordinateX = Canvas.GetLeft(tri);
                tri.CordinateY = Canvas.GetTop(tri);
                tri.MouseDown += Tri_MouseDown;
                down.Begin();
                s = s + 50;
                goto NEW;

            case 14: goto case 5;

            case 12: goto case 5;
            }
Exit:
            ;
        }
Ejemplo n.º 3
0
        private void Cer_MouseDown(object sender, MouseButtonEventArgs e)
        {
            SelectCercle = (cercle)sender;
            if (SelectOne == false)
            {
                SelectOne     = true;
                CordinateOneX = SelectCercle.CordinateX;
                CordinateOneY = SelectCercle.CordinateY;
                TypeOne       = "cercle";
            }
            else if (SelectOne == true)
            {
                SelectTwo     = true;
                CordinateTwoX = SelectCercle.CordinateX;
                CordinateTwoY = SelectCercle.CordinateY;
                TypeTwo       = "cercle";

                Storyboard      down            = new Storyboard();
                DoubleAnimation doubleAnimation = new DoubleAnimation();

                doubleAnimation.Duration = TimeSpan.FromSeconds(1.5);
                string answ = call.calculatingPathOne(CordinateOneX, CordinateTwoX, CordinateOneY, CordinateTwoY);

                Storyboard.SetTarget(doubleAnimation, SelectCercle);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(" + answ + ")"));
                down.Children.Add(doubleAnimation);
                down.Duration           = doubleAnimation.Duration;
                SelectCercle.CordinateX = Canvas.GetLeft(SelectCercle);
                SelectCercle.CordinateY = Canvas.GetTop(SelectCercle);
                SelectCercle.MouseDown += Cer_MouseDown;

                down.Begin();

                doubleAnimation.To       = CordinateTwoY;
                doubleAnimation.Duration = TimeSpan.FromSeconds(1.5);
                if (answ == "Canvas.Left")
                {
                    SelectHexagon.SetValue(Canvas.RightProperty, CordinateOneX);
                }
                if (answ == "Canvas.Top")
                {
                    SelectHexagon.SetValue(Canvas.BottomProperty, CordinateOneY);
                }
                if (answ == "Canvas.Right")
                {
                    SelectHexagon.SetValue(Canvas.LeftProperty, CordinateOneX);
                }
                if (answ == "Canvas.Bottom")
                {
                    SelectHexagon.SetValue(Canvas.TopProperty, CordinateOneY);
                }
                Storyboard.SetTarget(doubleAnimation, SelectHexagon);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(" + call.calculationsPathTwo() + ")"));
                down.Children.Add(doubleAnimation);
                down.Duration            = doubleAnimation.Duration;
                SelectHexagon.CordinateX = Canvas.GetLeft(SelectHexagon);
                SelectHexagon.CordinateY = Canvas.GetTop(SelectHexagon);
                SelectHexagon.MouseDown += Hex_MouseDown;

                down.Begin();
                SelectOne = false;
                SelectTwo = false;
            }
        }