Example #1
0
        public override bool IsPointClose(Coordonnees point, double precision)
        {
            if (NbPoints < 2)
            {
                return(false);
            }
            Bbox.InitBbox(Coordonnees);

            if (point.Longitude < Bbox.Min.Longitude || point.Longitude > Bbox.Max.Longitude)
            {
                return(false);
            }
            if (point.Latitude < Bbox.Min.Latitude || point.Latitude > Bbox.Max.Latitude)
            {
                return(false);
            }

            // calculer distance entre point et les 2 extremites + mediane et considerer le plus petit
            for (int i = 0; i < Coordonnees.Count - 1; i++)
            {
                double distance;
                distance = MathUtil.DistanceBetweenLine(Coordonnees[i].Longitude, Coordonnees[i].Latitude, Coordonnees[i + 1].Longitude, Coordonnees[i + 1].Latitude, point.Longitude, point.Latitude);
                if (distance < precision)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (ClassId != 0)
        {
            hash ^= ClassId.GetHashCode();
        }
        if (Score != 0F)
        {
            hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Score);
        }
        if (bbox_ != null)
        {
            hash ^= Bbox.GetHashCode();
        }
        if (segm_ != null)
        {
            hash ^= Segm.GetHashCode();
        }
        if (florplanpoint_ != null)
        {
            hash ^= Florplanpoint.GetHashCode();
        }
        if (Features.Length != 0)
        {
            hash ^= Features.GetHashCode();
        }
        if (_unknownFields != null)
        {
            hash ^= _unknownFields.GetHashCode();
        }
        return(hash);
    }
Example #3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (header_ != null)
            {
                hash ^= Header.GetHashCode();
            }
            if (Id != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (Label.Length != 0)
            {
                hash ^= Label.GetHashCode();
            }
            if (Score != 0D)
            {
                hash ^= Score.GetHashCode();
            }
            if (bbox_ != null)
            {
                hash ^= Bbox.GetHashCode();
            }
            if (velocity_ != null)
            {
                hash ^= Velocity.GetHashCode();
            }
            return(hash);
        }
Example #4
0
        public void BboxIntilizationUserString()
        {
            string expected = "bbox=";
            Bbox   Bbox     = new Bbox("UserString");

            expected += "UserString";
            Assert.AreEqual(expected, Bbox.GetPartUrl());
        }
Example #5
0
 public Tri(Point P1, Point P2, Point P3, Vector N)
 {
     p    = new Point[3];
     bb   = new Bbox();
     p[0] = P1;
     p[1] = P2;
     p[2] = P3;
     n    = N;
 }
Example #6
0
 public Tri()
 {
     p = new Point[3];
     bb = new Bbox();
     p[0] = new Point(0,0,0);
     p[1] = new Point(0, 0, 0);
     p[2] = new Point(0, 0, 0);
     n = null; 
 }
Example #7
0
 public Tri(Vector N)
 {
     // a strange constructor indeed...
     p    = new Point[3];
     bb   = new Bbox();
     p[0] = new Point();
     p[1] = new Point();
     p[2] = new Point();
     n    = N;
 }
        /// <summary>
        /// Presmetuva bounding box
        /// </summary>
        /// <param name="x">X</param>
        /// <param name="y">Y</param>
        /// <param name="resolution">Rezolucija</param>
        /// <param name="w">shirina vo pikseli</param>
        /// <param name="h">visina vo pikseli</param>
        /// <returns></returns>
        private static Bbox CalculateBounds(double x, double y, double resolution, int w, int h)
        {
            var halfWDeg = (w * resolution) / 2;
            var halfHDeg = (h * resolution) / 2;
            var bbox     = new Bbox {
                Left = x - halfWDeg, Bottom = y - halfHDeg, Right = x + halfWDeg, Top = y + halfHDeg
            };

            return(bbox);
        }
        /// <summary>
        /// Returns true if RouteResponsePath instances are equal
        /// </summary>
        /// <param name="input">Instance of RouteResponsePath to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(RouteResponsePath input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Distance == input.Distance ||
                     (Distance != null &&
                      Distance.Equals(input.Distance))
                     ) &&
                 (
                     Time == input.Time ||
                     (Time != null &&
                      Time.Equals(input.Time))
                 ) &&
                 (
                     Ascend == input.Ascend ||
                     (Ascend != null &&
                      Ascend.Equals(input.Ascend))
                 ) &&
                 (
                     Descend == input.Descend ||
                     (Descend != null &&
                      Descend.Equals(input.Descend))
                 ) &&
                 (
                     Points == input.Points ||
                     (Points != null &&
                      Points.Equals(input.Points))
                 ) &&
                 (
                     PointsEncoded == input.PointsEncoded ||
                     (PointsEncoded != null &&
                      PointsEncoded.Equals(input.PointsEncoded))
                 ) &&
                 (
                     Bbox == input.Bbox ||
                     Bbox != null &&
                     Bbox.SequenceEqual(input.Bbox)
                 ) &&
                 (
                     SnappedWaypoints == input.SnappedWaypoints ||
                     (SnappedWaypoints != null &&
                      SnappedWaypoints.Equals(input.SnappedWaypoints))
                 ) &&
                 (
                     Instructions == input.Instructions ||
                     (Instructions != null &&
                      Instructions.Equals(input.Instructions))
                 ));
        }
Example #10
0
        public void BboxGetPartUrlStandart2()
        {
            Bbox Bbox = new Bbox(latTopLeft, lonTopLeft, latDownRigth, lonDownRigth);

            string result = $"bbox={Bbox.TopLeftPointLon.ToString().Replace(',', '.')}" +
                            $",{Bbox.TopLeftPointLat.ToString().Replace(',', '.')}~" +
                            $"{Bbox.DownRightPointLon.ToString().Replace(',', '.')}" +
                            $",{Bbox.DownRightPointLat.ToString().Replace(',', '.')}";

            Assert.AreEqual(result, Bbox.GetPartUrl());
        }
Example #11
0
 public Tri(Point P1, Point P2, Point P3)
 {
     p = new Point[3];
     bb = new Bbox();
     p[0] = P1;
     p[1] = P2;
     p[2] = P3;
     // if normal is not given, calculate it here.
     Vector v1 = new Vector(p[0].x - p[1].x, p[0].y - p[1].y, p[0].z - p[1].z);
     Vector v2 = new Vector(p[0].x - p[2].x, p[0].y - p[2].y, p[0].z - p[2].z);
     n = v1.Cross(v2); // the normal is in the direction of the cross product between the edge vectors
     n = (1 / n.Length()) * n; // normalize to length==1
 }
Example #12
0
        public AlienBuilding(WarGame game, Vector3 _position, MainScene _scene)
            : base(game, _scene, _position)
        {
            gameObjectModel = game.alienBaseModel;
            scale = new Vector3(0.5f, 0.5f, 0.5f);
            maxForce = 0;
            maxSpeed = 0;
            mass = 1000;
            currentSB = SBNames.None;
            currentWorld = Matrix.CreateScale(scale) * Matrix.CreateWorld(Position, lastNonZeroVelocity, Vector3.Up);

            boundingBox = new Bbox(this, game, scene);
            scene.SceneComponents.Add(boundingBox);

            boundingBox.RecalculateBoundingBox();
        }
Example #13
0
 public void MergeFrom(ObjectAnnotation other)
 {
     if (other == null)
     {
         return;
     }
     if (other.ClassId != 0)
     {
         ClassId = other.ClassId;
     }
     if (other.Score != 0F)
     {
         Score = other.Score;
     }
     if (other.bbox_ != null)
     {
         if (bbox_ == null)
         {
             bbox_ = new global::BBox();
         }
         Bbox.MergeFrom(other.Bbox);
     }
     if (other.segm_ != null)
     {
         if (segm_ == null)
         {
             segm_ = new global::SegmObject();
         }
         Segm.MergeFrom(other.Segm);
     }
     if (other.florplanpoint_ != null)
     {
         if (florplanpoint_ == null)
         {
             florplanpoint_ = new global::Point();
         }
         Florplanpoint.MergeFrom(other.Florplanpoint);
     }
     if (other.Features.Length != 0)
     {
         Features = other.Features;
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (Distance != null)
         {
             hashCode = hashCode * 59 + Distance.GetHashCode();
         }
         if (Time != null)
         {
             hashCode = hashCode * 59 + Time.GetHashCode();
         }
         if (Ascend != null)
         {
             hashCode = hashCode * 59 + Ascend.GetHashCode();
         }
         if (Descend != null)
         {
             hashCode = hashCode * 59 + Descend.GetHashCode();
         }
         if (Points != null)
         {
             hashCode = hashCode * 59 + Points.GetHashCode();
         }
         if (PointsEncoded != null)
         {
             hashCode = hashCode * 59 + PointsEncoded.GetHashCode();
         }
         if (Bbox != null)
         {
             hashCode = hashCode * 59 + Bbox.GetHashCode();
         }
         if (SnappedWaypoints != null)
         {
             hashCode = hashCode * 59 + SnappedWaypoints.GetHashCode();
         }
         if (Instructions != null)
         {
             hashCode = hashCode * 59 + Instructions.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #15
0
 public void MergeFrom(Detection3D other)
 {
     if (other == null)
     {
         return;
     }
     if (other.header_ != null)
     {
         if (header_ == null)
         {
             header_ = new global::Apollo.Common.Header();
         }
         Header.MergeFrom(other.Header);
     }
     if (other.Id != 0)
     {
         Id = other.Id;
     }
     if (other.Label.Length != 0)
     {
         Label = other.Label;
     }
     if (other.Score != 0D)
     {
         Score = other.Score;
     }
     if (other.bbox_ != null)
     {
         if (bbox_ == null)
         {
             bbox_ = new global::Apollo.Common.BoundingBox3D();
         }
         Bbox.MergeFrom(other.Bbox);
     }
     if (other.velocity_ != null)
     {
         if (velocity_ == null)
         {
             velocity_ = new global::Apollo.Common.Twist();
         }
         Velocity.MergeFrom(other.Velocity);
     }
 }
Example #16
0
        public override bool IsPointClose(Coordonnees point, double precision)
        {
            if (NbPoints == 0)
            {
                throw new ArgumentException("La liste de polyline est vide");
            }

            Bbox.InitBbox(Coordonnees);

            if (point.Longitude < Bbox.Min.Longitude || point.Longitude > Bbox.Max.Longitude)
            {
                return(false);
            }
            if (point.Latitude < Bbox.Min.Latitude || point.Latitude > Bbox.Max.Latitude)
            {
                return(false);
            }

            for (int i = 0; i < Coordonnees.Count; i++)
            {
                double distance;
                if (i < Coordonnees.Count)
                {
                    distance = MathUtil.DistanceBetweenLine(Coordonnees[i].Longitude, Coordonnees[i].Latitude, Coordonnees[i + 1].Longitude, Coordonnees[i + 1].Latitude, point.Longitude, point.Latitude);
                    if (distance < precision)
                    {
                        return(true);
                    }
                }
                else // derniere ligne pour fermer le polygone
                {
                    distance = MathUtil.DistanceBetweenLine(Coordonnees[i].Longitude, Coordonnees[i].Latitude, Coordonnees[0].Longitude, Coordonnees[0].Latitude, point.Longitude, point.Latitude);
                    if (distance < precision)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #17
0
        static void Main(string[] args)
        {
            L    l    = new L(true, false, false, true);
            LL   ll   = new LL(56.00848, 92.85302);
            int  z    = 15;
            Bbox bbox = new Bbox(56.01000, 92.85, 56.00580, 92.85778);
            Spn  spn  = new Spn(0.005, 0.005);
            Size size = new Size(450, 450);
            Lang lang = new Lang(Lang.Lang_reg.en_US);

            //Создание карты с слоем пробок
            StaticAPI map1 = new StaticAPI(l, ll, z, size, lang);

            Console.Write("Создание карты с слоем пробок.\n");
            Console.Write(map1.GetPictureURL() + "\n\n");

            //Создание карты с различными метками
            Pm              pm1      = new Pm(56.00922, 92.84895);
            Pm              pm2      = new Pm(56.00956, 92.85569, Pm.Color.do_, Pm.Size.l, 2);
            Pm              pm3      = new Pm(56.00891, 92.85581, Pm.Color.nt, Pm.Size.s, 3);
            Pm2             pm4      = new Pm2(56.00895, 92.85679);
            Pm2             pm5      = new Pm2(56.00702, 92.85713, Pm2.Color.gr, Pm2.Size.l, 5);
            Vk              pm6      = new Vk(56.00690, 92.85552, Vk.Color.bk);
            Vector          pm7      = new Vector(56.00613, 92.85574, Vector.Mark.comma);
            Vector          pm8      = new Vector(56.00574, 92.85283, Vector.Mark.ya_ru);
            Vector          pm9      = new Vector(56.00672, 92.85258, Vector.Mark.home);
            Flag            pm10     = new Flag(56.00661, 92.84937);
            List <MarkBase> listMark = new List <MarkBase>()
            {
                pm1, pm2, pm3, pm4, pm5, pm6, pm7, pm8, pm9, pm10
            };
            Pt        pt   = new Pt(listMark);
            StaticAPI map2 = new StaticAPI(new L(), bbox, pt: pt);

            Console.Write("Создание карты с различными метками.\n");
            Console.Write(map2.GetPictureURL() + "\n\n");

            //Создание спутниковой карты с полилиниями разного цвета
            Polyline polyline1 = new Polyline("0000FF99", 6, new List <Point>()
            {
                new Point(56.00976, 92.85251),
                new Point(56.00519, 92.85328),
                new Point(56.00518, 92.85359),
                new Point(56.00978, 92.85290)
            });
            Polyline polyline2 = new Polyline("FF0000FF", 10, new List <Point>()
            {
                new Point(56.00673, 92.84922),
                new Point(56.00719, 92.85721)
            });
            List <Polyline> listPol = new List <Polyline>()
            {
                polyline1, polyline2
            };
            Pl        pl   = new Pl(listPol);
            StaticAPI map3 = new StaticAPI(
                new L(false, true, true, false),
                ll,
                spn,
                new Size(450, 300),
                scale: 4,
                pl: pl);

            Console.Write("Создание спутниковой карты с полилиниями разного цвета.\n");
            Console.Write(map3.GetPictureURL() + "\n\n");

            //Создание карты с двумя пересекающимися полигонами
            List <Point> listPolygonPoint = new List <Point>()
            {
                new Point(56.00922, 92.84895),
                new Point(56.00956, 92.85569),
                new Point(56.00891, 92.85581),
                new Point(56.00895, 92.85679),
                new Point(56.00702, 92.85713),
                new Point(56.00690, 92.85552),
                new Point(56.00613, 92.85574),
                new Point(56.00574, 92.85283),
                new Point(56.00672, 92.85258),
                new Point(56.00661, 92.84937)
            };
            List <Point> listPolygonPoint2 = new List <Point>()
            {
                new Point(56.00827, 92.85097),
                new Point(56.00819, 92.85516),
                new Point(56.00693, 92.85367),
                new Point(56.00758, 92.85076)
            };
            Polyline     polygons          = new Polygon("F473fFAF", "ec473fF2", 8, listPolygonPoint, listPolygonPoint2);
            List <Point> listPolygonPoint3 = new List <Point>()
            {
                new Point(56.00976, 92.85251),
                new Point(56.00978, 92.85290),
                new Point(56.00518, 92.85359),
                new Point(56.00519, 92.85328)
            };
            Polyline        polygons2   = new Polygon(listPolygonPoint3);
            List <Polyline> listPolygon = new List <Polyline>()
            {
                polygons, polygons2
            };
            Pl        pl2  = new Pl(listPolygon);
            StaticAPI map4 = new StaticAPI(new L(), bbox, pl: pl2);

            Console.Write("Создание карты с двумя пересекающимися полигонами.\n");
            Console.Write(map4.GetPictureURL() + "\n\n");

            //Создание карты со всеми ранее созданными объектами
            List <Polyline> listPolygonPoint4 = new List <Polyline>()
            {
                polyline1, polyline2, polygons, polygons2
            };
            Pl        pl3  = new Pl(listPolygonPoint4);
            StaticAPI map5 = new StaticAPI(
                new L(true, false, true, true),
                bbox,
                new Size(450, 650),
                new Lang(Lang.Lang_reg.ru_RU),
                1.5,
                pt,
                pl3);

            Console.Write("Создание карты со всеми ранее созданными объектами.\n");
            Console.Write(map5.GetPictureURL() + "\n\n");

            Console.ReadLine();
        }
Example #18
0
 public Tri(Vector N)
 {
     // a strange constructor indeed...
        p = new Point[3];
        bb = new Bbox();
        p[0] = new Point();
        p[1] = new Point();
        p[2] = new Point();
        n = N;
 }
Example #19
0
 public Tri(Point P1, Point P2, Point P3, Vector N)
 {
     p = new Point[3];
        bb = new Bbox();
        p[0] = P1;
        p[1] = P2;
        p[2] = P3;
        n = N;
 }
Example #20
0
 public Tri(Point P1, Point P2, Point P3)
 {
     p = new Point[3];
        bb = new Bbox();
        p[0] = P1;
        p[1] = P2;
        p[2] = P3;
        // if normal is not given, calculate it here.
        Vector v1 = new Vector(p[0].x - p[1].x, p[0].y - p[1].y, p[0].z - p[1].z);
        Vector v2 = new Vector(p[0].x - p[2].x, p[0].y - p[2].y, p[0].z- p[2].z);
        n = v1.Cross(v2); // the normal is in the direction of the cross product between the edge vectors
        n = (1 / n.Length()) * n; // normalize to length==1
 }
    private List <Vector3d> GetNextDownLine(List <Vector3d> outLine, List <Vector3d> spacePts, int gridSize)
    {
        var rtnList = new List <Vector3d>();

        if (outLine.Count == 0)
        {
            return(rtnList);
        }

        Bbox _bbox = new Bbox(outLine);

        for (int i = 0; i < outLine.Count; i++)
        {
            if (outLine[i].Y == _bbox.Min.Y)
            {
                var nextPos = new Vector3d(outLine[i].X
                                           , outLine[i].Y - gridSize
                                           , 0);
                if (spacePts.Contains(nextPos))
                {
                    rtnList.Add(nextPos);
                }
            }
        }

        //二つに分かれたときは数の多いほうを返す。
        var rtnTree = new List <List <Point3d> >();


        double hypotenuse = Math.Sqrt((gridSize * gridSize) * 2);
        var    rtnListPts = VecToPt(rtnList);

        int iterat = 0;

        while (rtnListPts.Count > 0 && iterat < 1000)
        {
            rtnTree.Add(new List <Point3d>());
            SortList(ref rtnListPts);
            var stPts = new List <Point3d>()
            {
                rtnListPts[0]
            };
            ConnectPts(stPts, ref rtnListPts, ref rtnTree, hypotenuse, 10, 1, iterat);
            iterat++;
        }

        if (rtnTree.Count == 1)
        {
            return(rtnList);
        }

        if (rtnTree.Count > 1)
        {
            int maxPath  = 0;
            int maxCount = 0;
            for (int i = 0; i < rtnTree.Count; i++)
            {
                var path = i;
                if (rtnTree[path].Count > maxCount)
                {
                    maxCount = rtnTree[path].Count;
                    maxPath  = path;
                }
            }
            return(PtToVec(rtnTree[maxPath]));
        }

        return(rtnList);
    }
Example #22
0
 public Tri()
 {
     p = new Point[3];
        bb = new Bbox();
        p[0] = new Point(0,0,0);
        p[1] = new Point(0, 0, 0);
        p[2] = new Point(0, 0, 0);
        n = null;
 }
Example #23
0
    void Awake()
    {
        _mf = gameObject
              .GetComponent <MeshFilter>();
        _mr = gameObject.GetComponent <MeshRenderer>();

        string[] lines = file.text.Split('\n');

        if (lines[0].ToUpper().Equals("OFF"))
        {
            Debug.LogError("Not an Off Mesh");
            Destroy(gameObject);
        }

        string[] nbs = lines[1].Split(' ');
        _nbVertex = int.Parse(nbs[0]);
        _nbTris   = int.Parse(nbs[1]);

        _vertices = new Vector3[_nbVertex];
        _tris     = new int[_nbTris * 3];
        float biggestCoordinates  = float.NegativeInfinity;
        float biggestCoordinatesX = float.NegativeInfinity;
        float biggestCoordinatesY = float.NegativeInfinity;
        float biggestCoordinatesZ = float.NegativeInfinity;

        float smallestCoordinatesX = float.PositiveInfinity;
        float smallestCoordinatesY = float.PositiveInfinity;
        float smallestCoordinatesZ = float.PositiveInfinity;

        for (int i = 0; i < _nbVertex; i++)
        {
            string[] vtx = lines[i + 2].Split(' ');

            decimal x = decimal.Parse(vtx[0], style, CultureInfo.InvariantCulture);
            decimal y = decimal.Parse(vtx[1], style, CultureInfo.InvariantCulture);
            decimal z = decimal.Parse(vtx[2], style, CultureInfo.InvariantCulture);
            _vertices[i] = (new Vector3((float)x, (float)y, (float)z));
            float Ax = Mathf.Abs((float)x);
            float Ay = Mathf.Abs((float)y);
            float Az = Mathf.Abs((float)z);

            biggestCoordinates = (Ax > biggestCoordinates) ? Ax : biggestCoordinates;
            biggestCoordinates = (Ay > biggestCoordinates) ? Ay : biggestCoordinates;
            biggestCoordinates = (Az > biggestCoordinates) ? Az : biggestCoordinates;
            biggestCoordinates = Mathf.Abs(biggestCoordinates);


            _gravityCenter += _vertices[i];
        }

        _gravityCenter /= _nbVertex;
        for (int i = 0; i < _vertices.Length; i++)
        {
            _vertices[i] -= _gravityCenter;
            _vertices[i] /= biggestCoordinates;

            biggestCoordinatesX = (_vertices[i].x > biggestCoordinatesX) ? _vertices[i].x : biggestCoordinatesX;
            biggestCoordinatesY = (_vertices[i].y > biggestCoordinatesY) ? _vertices[i].y : biggestCoordinatesY;
            biggestCoordinatesZ = (_vertices[i].z > biggestCoordinatesZ) ? _vertices[i].z : biggestCoordinatesZ;

            smallestCoordinatesX = (_vertices[i].x < smallestCoordinatesX) ? _vertices[i].x : smallestCoordinatesX;
            smallestCoordinatesY = (_vertices[i].y < smallestCoordinatesY) ? _vertices[i].y : smallestCoordinatesY;
            smallestCoordinatesZ = (_vertices[i].z < smallestCoordinatesZ) ? _vertices[i].z : smallestCoordinatesZ;
        }

        for (int i = 0; i < _nbTris; i++)
        {
            string[] vtx = lines[i + 2 + _nbVertex].Split(' ');
            _tris[3 * i]     = (int.Parse(vtx[1]));
            _tris[3 * i + 1] = (int.Parse(vtx[2]));
            _tris[3 * i + 2] = (int.Parse(vtx[3]));
        }

        bounding = new Bbox(
            new Vector3(smallestCoordinatesX, smallestCoordinatesY, smallestCoordinatesZ),
            new Vector3(biggestCoordinatesX, biggestCoordinatesY, biggestCoordinatesZ)
            );

        _mesh = new Mesh {
            vertices = _vertices, triangles = _tris
        };
        _mesh.RecalculateNormals();
        _mf.mesh = _mesh;

        if (mat)
        {
            _mr.material = mat;
        }
        else
        {
            _mr.material = new Material(Shader.Find("Diffuse"));
        }
    }