/// <summary>
        /// Gets vantage points from a given vantage street.
        /// Assumes that the outputVantageStreet.Centerline and the front lot line are parallel
        /// same-length offsets of each other.
        /// </summary>
        /// <param name="model">Used to help debug visualizations</param>
        /// <returns></returns>
        public static List <VantagePoint> GetVantagePoints(NYCDaylightEvaluationVantageStreet outputVantageStreet, Model model = null)
        {
            var vantagePoints         = new List <VantagePoint>();
            var ninetyDegreeDirection = (outputVantageStreet.FrontLotLine.PointAt(0.5) - outputVantageStreet.Centerline.PointAt(0.5)).Unitized();
            var hasThirdVantagePoint  = outputVantageStreet.Centerline.Length() > longCenterlineLength;

            // VP 1
            var base1   = new Vector3(outputVantageStreet.Centerline.Start);
            var dir1    = new Vector3(outputVantageStreet.Centerline.End - outputVantageStreet.Centerline.Start).Unitized();
            var origin1 = base1 + (dir1 * VantageDistance);
            var vp1     = new VantagePoint(
                outputVantageStreet,
                origin1,
                dir1 * -1,
                ninetyDegreeDirection
                );

            vantagePoints.Add(vp1);

            // VP 2
            var base2   = new Vector3(outputVantageStreet.Centerline.End);
            var dir2    = new Vector3(outputVantageStreet.Centerline.Start - outputVantageStreet.Centerline.End).Unitized();
            var origin2 = base2 + (dir2 * VantageDistance);
            var vp2     = new VantagePoint(
                outputVantageStreet,
                origin2,
                dir2 * -1,
                ninetyDegreeDirection
                );

            vantagePoints.Add(vp2);

            if (hasThirdVantagePoint)
            {
                var lineBetweenVps = new Line(origin1, origin2);
                var dir3           = dir1;
                var origin3        = lineBetweenVps.PointAt(0.5);
                var vp3            = new VantagePoint(
                    outputVantageStreet,
                    origin3,
                    dir3 * -1,
                    ninetyDegreeDirection
                    );
                vantagePoints.Add(vp3);
            }

            calculateDaylightBoundaries(outputVantageStreet, vantagePoints, model);
            foreach (var vp in vantagePoints)
            {
                vp.Diagram.CalculateProfileCurvesAndBoundingSquares();
            }

            return(vantagePoints);
        }
Esempio n. 2
0
        public static void Trace(string id, List <AnalysisPoint> aps, VantagePoint vp, Model model = null)
        {
            if (model == null)
            {
                return;
            }

            var start = 20;
            var end   = aps.Count;

            Console.WriteLine("Tracing:");

            for (var k = start; k < end; k++)
            {
                var srfAP    = aps[k];
                var progress = (k + 1) / (double)end;
                var color    = random.NextColor();
                var name     = $"{id}_{k}";
                var material = new Material(progress.ToString(), new Color(color.Red, color.Green, color.Blue, 1));

                if (k < end - 1)
                {
                    var nextAp = aps[k + 1];
                    var crv    = new ModelCurve(new Line(srfAP.PlanAndSection, nextAp.PlanAndSection), material);
                    crv.SetSelectable(false);
                    model.AddElement(crv);
                }

                var origin         = vp.Point;
                var original       = srfAP.Original;
                var planAndSection = srfAP.PlanAndSection;
                var drawCoordinate = srfAP.DrawCoordinate;

                Console.WriteLine($"- {k}/{end}: {srfAP.Original} & {srfAP.PlanAndSection}");

                var polyline = new Polyline(origin, original, planAndSection, drawCoordinate);

                var lineFromVP = new ModelCurve(polyline, material, name: name);
                lineFromVP.AdditionalProperties.Add("original", $"{srfAP.Original.X}, {srfAP.Original.Y}, {srfAP.Original.Z}");
                lineFromVP.AdditionalProperties.Add("new", $"{srfAP.PlanAndSection.X}, {srfAP.PlanAndSection.Y}, {srfAP.PlanAndSection.Z}");
                model.AddElement(lineFromVP);

                var transform     = new Transform(srfAP.PlanAndSection);
                var visualization = new Panel(new Circle(0.5).ToPolygon(), material, transform, name: name);
                model.AddElement(visualization);
            }
        }
        /// <summary>
        /// Create an output vantage street from an input vantage street.
        /// </summary>
        public static NYCDaylightEvaluationVantageStreet CreateVantageStreet(Polygon rectangularSite, VantageStreets vantageStreet, out List <VantagePoint> vantagePoints, VantageStreetsOverride ovd = null, Model model = null)
        {
            if (vantageStreet.Line == null)
            {
                throw new Exception("Each vantage street must have a line designating its rough location. Please draw a line outside of your lot that represents the centerline of your vantage street. It does not need to be straight or exactly parallel to the lot line, but it must exist.");
            }
            var siteCentroid         = rectangularSite.Centroid();
            var midpoint             = vantageStreet.Line.PointAt(0.5);
            var lotLines             = new List <Line>(rectangularSite.Segments()).OrderBy(segment => midpoint.DistanceTo(segment.PointAt(0.5))).ToList();
            var originalFrontLotLine = lotLines[0];
            var frontLotLine         = ovd?.Value.FrontLotLine ?? originalFrontLotLine;
            var centerlineOffsetDist = Settings.CenterlineDistances[vantageStreet.Width] / 2;
            var directionToStreet    = new Vector3(originalFrontLotLine.PointAt(0.5) - siteCentroid).Unitized() * centerlineOffsetDist;
            var centerline           = new Line(frontLotLine.Start + directionToStreet, frontLotLine.End + directionToStreet);
            var outputVantageStreet  = new NYCDaylightEvaluationVantageStreet(0, centerlineOffsetDist, frontLotLine, centerline, vantageStreet.StreetWallContinuity, lotLines, Units.FeetToMeters(vantageStreet.BlockDepthInFeet), name: vantageStreet.Name);

            if (ovd != null)
            {
                outputVantageStreet.AddOverrideIdentity(ovd);
            }
            vantagePoints = VantagePoint.GetVantagePoints(outputVantageStreet, model);

            return(outputVantageStreet);
        }