Esempio n. 1
0
        public RandomDropOff(RealPoint position, Color color) : base(position, color, 200)
        {
            _loads = new List <List <Color> >();

            _loadOnTop    = null;
            _loadOnBottom = null;
        }
Esempio n. 2
0
 public WorldPanel()
 {
     InitializeComponent();
     Dimensions              = new WorldDimensions();
     Dimensions.WorldChange += Dimensions_WorldChange;
     _pointClicked           = null;
 }
Esempio n. 3
0
 private static void PaintRobotBuoy(Graphics g, Robot robot, RealPoint center, Color c)
 {
     if (c != Color.Transparent)
     {
         new Circle(new RealPoint(robot.Position.Coordinates.X + center.X, robot.Position.Coordinates.Y + center.Y), 36).Paint(g, Color.Black, 1, c, Scale);
     }
 }
Esempio n. 4
0
        private static IShape BuildCurrentShape(ShapeMode mode, RealPoint startPoint, RealPoint endPoint)
        {
            IShape output = null;

            switch (mode)
            {
            case ShapeMode.Rectangle:
                output = new PolygonRectangle(startPoint, endPoint.X - startPoint.X, endPoint.Y - startPoint.Y);
                break;

            case ShapeMode.Circle:
                output = new Circle(new Segment(startPoint, endPoint).Barycenter, startPoint.Distance(endPoint) / 2);
                break;

            case ShapeMode.CircleFromCenter:
                output = new Circle(startPoint, startPoint.Distance(endPoint));
                break;

            case ShapeMode.Segment:
                output = new Segment(startPoint, endPoint);
                break;

            case ShapeMode.Line:
                output = new Line(startPoint, endPoint);
                break;
            }

            return(output);
        }
Esempio n. 5
0
        private void pictureBoxTable_Click(object sender, EventArgs e)
        {
            if (boxSourisObstacle.Checked)
            {
                boxSourisObstacle.Checked = false;
            }
            else if (!moveMouse && Dessinateur.modeCourant == Dessinateur.MouseMode.TrajectoirePolaire)
            {
                RealPoint point = Dessinateur.Scale.ScreenToRealPosition(pictureBoxTable.PointToClient(MousePosition));
                //if (pointsPolaires.Count >= 2 && pointsPolaires.Count < 4)
                //    pointsPolaires.Insert(pointsPolaires.Count - 1, point);
                //else if (pointsPolaires.Count < 4)
                pointsPolaires.Add(point);

                if (pointsPolaires.Count > 1)
                {
                    trajectoirePolaire             = BezierCurve.GetPoints(pointsPolaires, (int)(numNbPoints.Value));//((int)pointsPolaires[0].Distance(pointsPolaires[pointsPolaires.Count - 1])) / 50);
                    Dessinateur.TrajectoirePolaire = trajectoirePolaire;
                    Dessinateur.PointsPolaire      = pointsPolaires;
                }
            }
            else
            {
                CheckElementClick();
            }
        }
Esempio n. 6
0
        public void TestCrossCenter()
        {
            Circle    c1 = new Circle(new RealPoint(10, 20), 30);
            RealPoint p1 = new RealPoint(10, 20);

            Assert.IsFalse(c1.Cross(p1));
        }
Esempio n. 7
0
        private void DrawAxes(Graphics g)
        {
            if (_axesVisible)
            {
                new Segment(new RealPoint(0, 0), new RealPoint(0, 150)).Paint(g, Color.Black, 3, Color.Transparent, _worldScale);
                new Segment(new RealPoint(0, 150), new RealPoint(5, 145)).Paint(g, Color.Black, 2, Color.Transparent, _worldScale);
                new Segment(new RealPoint(0, 150), new RealPoint(-5, 145)).Paint(g, Color.Black, 2, Color.Transparent, _worldScale);

                new Segment(new RealPoint(0, 0), new RealPoint(150, 0)).Paint(g, Color.Black, 3, Color.Transparent, _worldScale);
                new Segment(new RealPoint(150, 0), new RealPoint(145, 5)).Paint(g, Color.Black, 2, Color.Transparent, _worldScale);
                new Segment(new RealPoint(150, 0), new RealPoint(145, -5)).Paint(g, Color.Black, 2, Color.Transparent, _worldScale);

                RealPoint arc1 = _worldScale.RealToScreenPosition(new RealPoint(-80, -80));
                RealPoint arc2 = _worldScale.RealToScreenPosition(new RealPoint(80, 80));

                Rectangle r = new Rectangle((int)arc1.X, (int)arc1.Y, (int)(arc2.X - arc1.X), (int)(arc2.Y - arc1.Y));

                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                g.DrawArc(Pens.Black, r, 0, 90);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

                RealPoint arrow1 = new RealPoint(1, 80);
                RealPoint arrow2 = new RealPoint(6, 85);
                RealPoint arrow3 = new RealPoint(6, 75);

                new Segment(arrow1, arrow2).Paint(g, Color.Black, 1, Color.Black, _worldScale);
                new Segment(arrow1, arrow3).Paint(g, Color.Black, 1, Color.Black, _worldScale);

                new RealPoint(0, 0).Paint(g, Color.Black, 3, Color.Black, _worldScale);
            }
        }
Esempio n. 8
0
 private void DrawBarycenter(RealPoint pt, Graphics g)
 {
     if (_barycenterVisible)
     {
         pt?.Paint(g, Color.Black, 3, Color.Blue, _worldScale);
     }
 }
Esempio n. 9
0
File: Node.cs Progetto: Omybot/GoBot
 public Node()
 {
     _pos          = new RealPoint();
     _passable     = true;
     _incomingArcs = new List <Arc>();
     _outgoingArcs = new List <Arc>();
 }
Esempio n. 10
0
 /// <summary>
 /// Constructeur
 /// </summary>
 /// <param name="position">Position de l'élément</param>
 /// <param name="owner">Couleur d'appartenance de l'élément</param>
 /// <param name="hoverRadius">Rayon de survol de l'élément</param>
 public GameElement(RealPoint position, Color owner, int hoverRadius)
 {
     this._hoverRadius = hoverRadius;
     this._position    = position;
     this._owner       = owner;
     this._isAvailable = true;
 }
Esempio n. 11
0
        private List <RealPoint> ValuesToPositions(List <double> measures, bool limitOnTable, int minDistance, int maxDistance, Position refPosition)
        {
            List <RealPoint> positions  = new List <RealPoint>();
            AngleDelta       resolution = _scanRange / _pointsCount;

            for (int i = 0; i < measures.Count; i++)
            {
                AnglePosition angle = resolution * i;

                if (measures[i] > minDistance && (measures[i] < maxDistance || maxDistance == -1))
                {
                    AnglePosition anglePoint = new AnglePosition(angle.InPositiveRadians - refPosition.Angle.InPositiveRadians - _scanRange.InRadians / 2 - Math.PI / 2, AngleType.Radian);

                    RealPoint pos = new RealPoint(refPosition.Coordinates.X - anglePoint.Sin * measures[i], refPosition.Coordinates.Y - anglePoint.Cos * measures[i]);

                    int marge = 20; // Marge en mm de distance de detection à l'exterieur de la table (pour ne pas jeter les mesures de la bordure qui ne collent pas parfaitement)
                    if (!limitOnTable || (pos.X > -marge && pos.X < GameBoard.Width + marge && pos.Y > -marge && pos.Y < GameBoard.Height + marge))
                    {
                        positions.Add(pos);
                    }
                }
            }

            return(positions);
        }
Esempio n. 12
0
        private RealPoint GetDetectionLinePoint(Segment seg, IEnumerable <IShape> obstacles)
        {
            RealPoint closest     = null;
            double    minDistance = double.MaxValue;

            foreach (IShape s in obstacles)
            {
                List <RealPoint> pts = s.GetCrossingPoints(seg);
                foreach (RealPoint p in pts)
                {
                    double newDistance = seg.StartPoint.Distance(p);
                    if (newDistance < minDistance)
                    {
                        minDistance = newDistance;
                        closest     = p;
                    }
                }
            }

            Direction d = Maths.GetDirection(seg.StartPoint, closest);

            d.distance += (_rand.NextDouble() * _noise * 2 - _noise);
            closest     = Maths.GetDestination(seg.StartPoint, d);

            return(closest);
        }
Esempio n. 13
0
        public void SetWorldCenter(RealPoint center)
        {
            WorldRect  = WorldRect.SetCenter(center);
            WorldScale = new WorldScale(WorldScale.Factor, -WorldScale.RealToScreenDistance(WorldRect.X), -WorldScale.RealToScreenDistance(WorldRect.Y));

            WorldChange?.Invoke();
        }
Esempio n. 14
0
        public void TestCrossOrigin()
        {
            Circle    c1 = new Circle(new RealPoint(0, 0), 1);
            RealPoint p1 = c1.Center;

            Assert.IsFalse(c1.Cross(p1));
        }
Esempio n. 15
0
 private void DrawCrossingPoint(RealPoint pt, Graphics g)
 {
     if (_crossingPointsVisible)
     {
         pt.Paint(g, Color.Black, 5, Color.Red, _worldScale);
     }
 }
        public double GetResultsArea(RealPoint point)
        {
            double result = 0.0;

            foreach (var area in this.Areas)
            {
                foreach (var segmentI in area.Segments)
                {
                    int i = 0;
                    foreach (var collPointI in segmentI.CollocationPoints)
                    {
                        var functionT = Function_T.CalculateAreaValue(point, segmentI, collPointI, area.configurationData);
                        var functionq = Function_q.CalculateAreaValue(point, segmentI, collPointI, area.configurationData);

                        result += -functionq * segmentI.TemperatureBoundaryCondition.BoundaryConditionVector[i] + functionT * segmentI.HeatFluxBoundaryCondition.BoundaryConditionVector[i];
                        i++;
                    }
                }
            }
            foreach (var area in this.Areas)
            {
                var initial = InitialCondition.CalculateValue(area, point);
                result += initial;

                if (area.configurationData.addHeatSource)
                {
                    var subAreaIntegrationHelper = new SubAreaIntegrationHelper(4, area.Surfaces.Select(x => x.SurfaceShape).ToList());
                    result += HeatSource.CalculateValue(area, point, subAreaIntegrationHelper);
                }
            }

            return(result);
        }
Esempio n. 17
0
        public void TestCrossBorderDiagonal()
        {
            Circle    c1 = new Circle(new RealPoint(10, 20), 30);
            RealPoint p1 = new RealPoint(10 + Math.Sin(Math.PI / 3) * 30, 20 + Math.Cos(Math.PI / 3) * 30);

            Assert.IsTrue(c1.Cross(p1));
        }
Esempio n. 18
0
        private static void CalculVecteurs()
        {
            for (int i = 0; i < PositionsEnnemies.Count; i++)
            {
                List <RealPoint> deplacements = new List <RealPoint>();

                for (int j = 1; j < PositionsTemporelles[i].Count; j++)
                {
                    double dx = PositionsTemporelles[i][j].Position.X - PositionsTemporelles[i][j - 1].Position.X;
                    double dy = PositionsTemporelles[i][j].Position.Y - PositionsTemporelles[i][j - 1].Position.Y;

                    TimeSpan t = PositionsTemporelles[i][j].Date - PositionsTemporelles[i][j - 1].Date;
                    if (t.TotalMilliseconds > 0)
                    {
                        deplacements.Add(new RealPoint(dx * 1000.0 / t.TotalMilliseconds, dy * 1000.0 / t.TotalMilliseconds));
                    }
                }

                double x = 0, y = 0;
                foreach (RealPoint p in deplacements)
                {
                    x += p.X;
                    y += p.Y;
                }

                if (deplacements.Count > 0)
                {
                    x /= deplacements.Count;
                    y /= deplacements.Count;
                }

                VecteursPositionsEnnemies[i] = new RealPoint(x, y);
            }
        }
Esempio n. 19
0
        public void TestCrossOriginDot()
        {
            Circle    c1 = new Circle(new RealPoint(0, 0), 0);
            RealPoint p1 = c1.Center;

            Assert.IsTrue(p1.Cross(c1));
        }
        public static double CalculateValue(Area Area, RealPoint point, SubAreaIntegrationHelper subAreaIntegrationHelper, int boundarySegmentIndex = 0)
        {
            double value = 0.0;

            foreach (var surface in Area.Surfaces)
            {
                double denominator1 = HeatSource.denominator1(Area.configurationData.GetDiffusionCoefficient(), Area.configurationData.iterationProcess.TimeStep);
                double denominator2 = HeatSource.denominator2(Area.configurationData.GetThermalConductivity());

                for (int subAreaIndex = 0; subAreaIndex < subAreaIntegrationHelper.NumberOfSubSurfaces; subAreaIndex++)
                {
                    foreach (var surfaceIntegrationPoint in surface.HeatSourceSurfaceIntegrationPoints)
                    {
                        if (Area.configurationData.arePropertiesTimeDependent())
                        {
                            denominator1 = HeatSource.denominator1(Area.configurationData.GetDiffusionCoefficient(surfaceIntegrationPoint.TemperatureValue), Area.configurationData.iterationProcess.TimeStep);
                            denominator2 = HeatSource.denominator2(Area.configurationData.GetThermalConductivity(surfaceIntegrationPoint.TemperatureValue));
                        }

                        var subAreaSurfaceIntegrationPoint = subAreaIntegrationHelper.TransformIntegrationPoint(surface.Index, subAreaIndex, boundarySegmentIndex, surfaceIntegrationPoint, point);

                        var parameters = new Dictionary <string, double>();
                        parameters.Add("x", subAreaSurfaceIntegrationPoint.RealPosition.x);
                        parameters.Add("y", subAreaSurfaceIntegrationPoint.RealPosition.y);
                        parameters.Add("t", Area.configurationData.iterationProcess.CurrentTime);
                        var heatSource = surface.heatSourceFunction(parameters);

                        value += CalculateSiglePointFunctionValue(point, denominator1, denominator2, subAreaSurfaceIntegrationPoint) * heatSource;
                    }
                }
            }

            return(value);
        }
Esempio n. 21
0
        /// <summary>
        /// Retourne les coordonnées d'une coordonnée initiale modifiée par une prise de direction
        /// </summary>
        /// <param name="startPoint">Coordonnée de départ</param>
        /// <param name="direction">Direction suivie</param>
        /// <returns>Coordonnées du point</returns>
        public static RealPoint GetDestination(RealPoint startPoint, Direction direction)
        {
            double x = startPoint.X + direction.angle.Cos * direction.distance;
            double y = startPoint.Y - direction.angle.Sin * direction.distance;

            return(new RealPoint(new RealPoint(x, y)));
        }
Esempio n. 22
0
        public static double CalculateValue(Area Area, RealPoint point)
        {
            double value = 0.0;

            var sign = 1.0;

            foreach (var surface in Area.Surfaces)
            {
                double denominator1 = InitialCondition.denominator1(Area.configurationData.GetDiffusionCoefficient(), Area.configurationData.iterationProcess.TimeStep);
                double denominator2 = InitialCondition.denominator2(Area.configurationData.GetDiffusionCoefficient(), Area.configurationData.iterationProcess.TimeStep);

                if (surface.subractSurface)
                {
                    sign = -1.0;
                }

                foreach (var surfaceIntegrationPoint in surface.InitialConditionSurfaceIntegrationPoints)
                {
                    if (Area.configurationData.arePropertiesTimeDependent())
                    {
                        denominator1 = InitialCondition.denominator1(Area.configurationData.GetDiffusionCoefficient(surfaceIntegrationPoint.TemperatureValue), Area.configurationData.iterationProcess.TimeStep);
                        denominator2 = InitialCondition.denominator2(Area.configurationData.GetDiffusionCoefficient(surfaceIntegrationPoint.TemperatureValue), Area.configurationData.iterationProcess.TimeStep);
                    }

                    value += sign * CalculateSiglePointFunctionValue(point, denominator1, denominator2, surfaceIntegrationPoint) * surfaceIntegrationPoint.TemperatureValue;
                }
            }
            return(value);
        }
 public BezieCurve(RealPoint v0, RealPoint v1, RealPoint vp0, RealPoint vp1)
 {
     this.V0  = v0;
     this.V1  = v1;
     this.Vp0 = vp0;
     this.Vp1 = vp1;
     this.CalculateParameters();
 }
Esempio n. 24
0
        private WorldScale CreateWorldScale(double mmPerPixel, RealPoint center)
        {
            Console.WriteLine(center.ToString());
            int x = (int)(picWorld.Width / 2 - center.X / mmPerPixel);
            int y = (int)(picWorld.Height / 2 - center.Y / mmPerPixel);

            return(new WorldScale(mmPerPixel, x, y));
        }
Esempio n. 25
0
        public static void Start()
        {
            PositionCurseur = new RealPoint();

            _linkDisplay      = ThreadManager.CreateThread(link => DisplayLoop());
            _linkDisplay.Name = "Affichage de la table";
            _linkDisplay.StartThread();
        }
Esempio n. 26
0
        private void ZoomRight()
        {
            double dx = _worldScale.ScreenToRealDistance(picWorld.Height / 60f);
            double dy = 0;

            _worldScale = CreateWorldScale(_worldScale.Factor, RealPoint.Shift(GetCenter(), dx, dy));
            picWorld.Invalidate();
        }
Esempio n. 27
0
        private void WorldPanel_MouseDown(object sender, MouseEventArgs e)
        {
            _pointClicked  = Dimensions.WorldScale.ScreenToRealPosition(e.Location);
            _centerAtStart = Dimensions.WorldRect.Center();
            _scaleAtStart  = new WorldScale(Dimensions.WorldScale);

            OnStartMove();
        }
Esempio n. 28
0
        public static List <RealPoint> GetCrossingPoints(Circle circle1, Circle circle2)
        {
            // Résolution du système d'équation à deux inconnues des deux équations de cercle

            List <RealPoint> output = new List <RealPoint>();

            if (circle1.Radius == 0 && circle2.Radius == 0 && circle1.Center == circle2.Center)
            {
                // Cas particulier où les deux cercles ont un rayon de 0 et sont au même endroit : le croisement c'est ce point.
                output.Add(new RealPoint(circle1.Center));
            }
            else if (circle1.Center == circle2.Center)
            {
                // Cas particulier où les deux cercles ont un rayon > 0 et sont au même endroit : on ne calcule pas les points de croisement, même s'ils se superposent (une autre idée est la bienvenue ?)
            }
            else
            {
                bool aligned = Math.Abs(circle1.Center.Y - circle2.Center.Y) < RealPoint.PRECISION;

                if (aligned)// Cercles non alignés horizontalement (on pivote pour les calculs, sinon division par 0)
                {
                    circle1 = circle1.Rotation(90, circle2.Center);
                }

                RealPoint oc1 = new RealPoint(circle1.Center), oc2 = new RealPoint(circle2.Center);
                double    b = circle1.Radius, c = circle2.Radius;

                double a = (-(Math.Pow(oc1.X, 2)) - (Math.Pow(oc1.Y, 2)) + Math.Pow(oc2.X, 2) + Math.Pow(oc2.Y, 2) + Math.Pow(b, 2) - Math.Pow(c, 2)) / (2 * (oc2.Y - oc1.Y));
                double d = ((oc2.X - oc1.X) / (oc2.Y - oc1.Y));

                double A = Math.Pow(d, 2) + 1;
                double B = -2 * oc1.X + 2 * oc1.Y * d - 2 * a * d;
                double C = Math.Pow(oc1.X, 2) + Math.Pow(oc1.Y, 2) - 2 * oc1.Y * a + Math.Pow(a, 2) - Math.Pow(b, 2);

                double delta = Math.Pow(B, 2) - 4 * A * C;

                if (delta >= 0)
                {
                    double x1 = (-B + Math.Sqrt(delta)) / (2 * A);
                    double y1 = a - x1 * d;
                    output.Add(new RealPoint(x1, y1));

                    if (delta > 0)
                    {
                        double x2 = (-B - Math.Sqrt(delta)) / (2 * A);
                        double y2 = a - x2 * d;
                        output.Add(new RealPoint(x2, y2));
                    }
                }

                if (aligned)
                {
                    output = output.ConvertAll(p => p.Rotation(-90, circle2.Center));
                }
            }

            return(output);
        }
Esempio n. 29
0
        public static void RemoveVirtualBuoy(RealPoint center)
        {
            Buoy b = _elements.FindBuoy(center);

            if (b.IsVirtual)
            {
                _elements.RemoveBuoy(b);
            }
        }
Esempio n. 30
0
        public void TestCrossingPointsCircle()
        {
            Circle    c1 = new Circle(new RealPoint(0, 0), 1);
            RealPoint p1 = c1.Center;

            List <RealPoint> points1 = c1.GetCrossingPoints(p1);

            Assert.AreEqual(0, points1.Count);
        }