public void CreateFromPoints_UsesOutermostPoints()
        {
            var r = BoundingRectangle.CreateFromPoints(new[] {
                new Vector2(10, 10),
                new Vector2(12, 5),
                new Vector2(11, 7),
                new Vector2(15, 8),
            });

            var e = new BoundingRectangle(new Vector2(10, 5), new Vector2(15, 10));

            Assert.AreEqual(e, r);
        }
        protected BasePolygonRegion(IReadOnlyList <Side> shape, OABR oabr)
        {
            Contract.Requires(shape != null);
            Contract.Requires(shape.Count >= 3);

            _shape = shape;

            _bounds = BoundingRectangle.CreateFromPoints(Points);
            _oabr   = oabr;

            Area          = Points.Area();
            OabrAreaError = _oabr.Area - Area;
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="outline">Polygon outline of this map (clockwise wound, potentially concave)</param>
        /// <param name="internalRooms">Set of rooms which must be included unchanged in this map</param>
        /// <param name="random">PRNG (0-1)</param>
        /// <param name="metadata">Metadata used in random generation</param>
        /// <param name="parameters"></param>
        public GrowthMap(IReadOnlyList <Vector2> outline, IReadOnlyList <IReadOnlyList <Vector2> > internalRooms, Func <double> random, INamedDataCollection metadata, WallGrowthParameters parameters)
        {
            Contract.Requires(outline != null);
            Contract.Requires(internalRooms != null);
            Contract.Requires(random != null);
            Contract.Requires(metadata != null);
            Contract.Requires(parameters != null);

            _outline       = outline;
            _internalRooms = internalRooms;
            _random        = random;
            _metadata      = metadata;

            _seedDistance                   = parameters.SeedDistance;
            _seedChance                     = parameters.SeedChance;
            _parallelLengthMultiplier       = parameters.ParallelLengthMultiplier;
            _parallelCheckWidth             = parameters.ParallelCheckWidth;
            _cosineParallelAngleThreshold   = parameters.ParallelAngleThreshold.Transform(a => (float)Math.Cos(a));
            _intersectionContinuationChance = parameters.IntersectionContinuationChance;

            var bounds = BoundingRectangle.CreateFromPoints(outline).Inflate(0.2f);

            _mesh = new Mesh <FloorplanVertexTag, FloorplanHalfEdgeTag, FloorplanFaceTag>(bounds);
        }