Example #1
0
        public static double AltitudeRange(this IEnvironmentObject environmentObject)
        {
            BoundingBox panelBoundingBox = BH.Engine.Geometry.Query.IBounds(environmentObject.Polyline());
            double      altitudeRange    = panelBoundingBox.Max.Z - panelBoundingBox.Min.Z;

            return(altitudeRange);
        }
Example #2
0
        public static double?Orientation(this IEnvironmentObject environmentObject, double northAngle = 0.0, bool returnAzimuthAngle = false)
        {
            if (environmentObject == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the orientation of a null environment object.");
                return(null);
            }

            northAngle += Math.PI / 2; // Correct northAngle to be 0 at North, rather than East

            Plane  xyPlane     = BH.Engine.Geometry.Create.Plane(BH.Engine.Geometry.Create.Point(0, 0, 0), BH.Engine.Geometry.Create.Vector(0, 0, 1));
            Vector northVector = BH.Engine.Geometry.Create.Vector(Math.Cos(northAngle), Math.Sin(northAngle), 0);

            Vector objectNormal = BH.Engine.Geometry.Query.Normal(environmentObject.Polyline());

            if (objectNormal.X == 0 && objectNormal.Y == 0)
            {
                BH.Engine.Reflection.Compute.RecordError("When an objects normal is either directly up or down, orientation angle cannot be successfully evaluated.");
                return(null);
            }

            objectNormal.Z = 0;

            return(returnAzimuthAngle ? Math.PI * 2 - BH.Engine.Geometry.Query.Angle(northVector, objectNormal, xyPlane) : BH.Engine.Geometry.Query.Angle(northVector, objectNormal));
        }
Example #3
0
        public static double Tilt(this IEnvironmentObject environmentObject, double distanceTolerance = BH.oM.Geometry.Tolerance.Distance, double angleTolerance = BH.oM.Geometry.Tolerance.Angle)
        {
            if (environmentObject == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the tilt of a null environment object.");
                return(-1);
            }

            return(environmentObject.Polyline().Tilt(distanceTolerance, angleTolerance));
        }
Example #4
0
        public static double Orientation(this IEnvironmentObject environmentObject)
        {
            Polyline pLine = environmentObject.Polyline();

            List <Point> pts   = pLine.DiscontinuityPoints();
            Plane        plane = BH.Engine.Geometry.Create.Plane(pts[0], pts[1], pts[2]); //Some protection on this needed maybe?

            Vector xyNormal = BH.Engine.Geometry.Create.Vector(0, 1, 0);

            return(BH.Engine.Geometry.Query.Angle(plane.Normal, xyNormal) * (180 / Math.PI));
        }
Example #5
0
        public static double AltitudeRange(this IEnvironmentObject environmentObject)
        {
            if (environmentObject == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the altitude range of a null environment object.");
                return(-1);
            }

            BoundingBox panelBoundingBox = BH.Engine.Geometry.Query.IBounds(environmentObject.Polyline());
            double      altitudeRange    = panelBoundingBox.Max.Z - panelBoundingBox.Min.Z;

            return(altitudeRange);
        }
Example #6
0
        public static double Azimuth(this IEnvironmentObject environmentObject, Vector refVector)
        {
            if (environmentObject == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the azimuth for a null environmental object.");
                return(-1);
            }

            if (refVector == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the azimuth from a null vector.");
                return(-1);
            }

            return(environmentObject.Polyline().Azimuth(refVector));
        }
Example #7
0
        public static double Inclination(this IEnvironmentObject environmentObject)
        {
            if (environmentObject == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the inclination of a null environment object.");
                return(-1);
            }

            Polyline pLine = environmentObject.Polyline();

            List <Point> pts   = pLine.DiscontinuityPoints();
            Plane        plane = BH.Engine.Geometry.Create.Plane(pts[0], pts[1], pts[2]); //Some protection on this needed maybe?

            Vector xyNormal = BH.Engine.Geometry.Create.Vector(0, 0, 1);

            return(BH.Engine.Geometry.Query.Angle(plane.Normal, xyNormal) * (180 / Math.PI));
        }
Example #8
0
        public static ICurve Top(this IEnvironmentObject environmentObject, double distanceTolerance = BH.oM.Geometry.Tolerance.Distance, double angleTolerance = BH.oM.Geometry.Tolerance.Angle, double numericTolerance = BH.oM.Geometry.Tolerance.Distance)
        {
            if (environmentObject == null)
            {
                return(null);
            }

            double tilt = environmentObject.Tilt(distanceTolerance, angleTolerance);

            if ((tilt >= 0 - numericTolerance && tilt <= 0 + numericTolerance) || (tilt >= 180 - numericTolerance && tilt <= 180 + numericTolerance))
            {
                BH.Engine.Reflection.Compute.RecordWarning("Cannot find the top of a horizontal IEnvironemntObject");
                return(null);
            }

            Polyline workingCurves = environmentObject.Polyline();

            if (workingCurves == null)
            {
                return(null);
            }

            double aZ      = double.MinValue;
            ICurve aResult = null;

            foreach (ICurve aCurve in workingCurves.SplitAtPoints(workingCurves.DiscontinuityPoints()))
            {
                Point aPoint_Start = aCurve.IStartPoint();
                Point aPoint_End   = aCurve.IEndPoint();

                if (aPoint_End.Z >= aZ && aPoint_Start.Z >= aZ)
                {
                    aZ      = Math.Min(aPoint_End.Z, aPoint_Start.Z);
                    aResult = aCurve;
                }
            }

            return(aResult);
        }
Example #9
0
        public static List <ICurve> Sides(this IEnvironmentObject environmentObject, double distanceTolerance = BH.oM.Geometry.Tolerance.Distance, double angleTolerance = BH.oM.Geometry.Tolerance.Angle, double numericTolerance = BH.oM.Geometry.Tolerance.Distance)
        {
            if (environmentObject == null)
            {
                return(null);
            }

            double tilt = environmentObject.Tilt(distanceTolerance, angleTolerance);

            if ((tilt >= 0 - numericTolerance && tilt <= 0 + numericTolerance) || (tilt >= 180 - numericTolerance && tilt <= 180 + numericTolerance))
            {
                BH.Engine.Reflection.Compute.RecordWarning("Cannot find the sides of a horizontal IEnvironmentObject");
                return(null);
            }

            Polyline workingCurves = environmentObject.Polyline();

            if (workingCurves == null)
            {
                return(null);
            }

            double        aZMax   = workingCurves.ControlPoints().Select(z => z.Z).Max();
            double        aZMin   = workingCurves.ControlPoints().Select(z => z.Z).Max();
            List <ICurve> aResult = new List <ICurve>();

            foreach (ICurve aCurve in workingCurves.SplitAtPoints(workingCurves.DiscontinuityPoints()))
            {
                if (aCurve.IControlPoints().Where(x => x.Z == aZMax).Count() == 1 && aCurve.IControlPoints().Where(x => x.Z == aZMin).Count() == 1)
                {
                    aResult.Add(aCurve);
                }
            }

            return(aResult);
        }
Example #10
0
 public static double Tilt(this IEnvironmentObject environmentObject)
 {
     return(environmentObject.Polyline().Tilt());
 }
Example #11
0
 public static double Tilt(this IEnvironmentObject environmentObject, double distanceTolerance = BH.oM.Geometry.Tolerance.Distance, double angleTolerance = BH.oM.Geometry.Tolerance.Angle)
 {
     return(environmentObject.Polyline().Tilt(distanceTolerance, angleTolerance));
 }
Example #12
0
 public static double Azimuth(this IEnvironmentObject environmentObject, Vector refVector)
 {
     return(environmentObject.Polyline().Azimuth(refVector));
 }