Best practice for determining if two Surfaces intersect?
Hi all,
I'm looking to find the best way to use the OpenStudio SDK to check if two surfaces intersect. Rather than write my own code to do this, I assumed there's likely something packaged into the SDK to help me do this.
Ideally, the code would look something like.
#Made up function 'intersectsWith'
surfaces_intersect = surface1.intersectsWith(surface2)
if surfaces_intersect
#DO SOMETHING
end
Where
surface1
,surface2
areOpenStudio::Model::Surface
surfaces_intersect
= a boolean that determines ifsurface1
andsurface2
intersect
I've looked into the computeIntersection
for Surface found here but am unsure if this is path would be the most elegant way to do this.
For context, I'm trying to dynamically determine the perimeter of a floor surface exposed to ambient to set them for a FFactorGroundFloorConstruction
. I haven't seen any way to easily do this in OpenStudio. Here is my approach:
- Identify if floor with outside boundary condition equal to Ground. If so, flag as a floor requiring a
FFactorGroundFloorConstruction
- Identify all walls in this floor's space. If the wall's outside boundary condition is Outdoors AND it intersects the floor of interest, find it's projection on the x, y plane (i.e. the length of floor that is exposed to perimeter along this wall). NOTE: This assumes a wall only touches 1 floor; this might not always be true.
- Add these perimeters for the floor to ultimately arrive at the exposed perimeter.
I cannot complete step two as I do not have a way to determine if a wall intersects a floor surface.
Any ideas? Thanks!
My solution to the ground-exposed perimeter problem is to find the spaces with floor BCs of "Ground", loop through that space's "Outdoor"-exposed walls, find the two vertices with minimum z coordinates and calculate the distance between those two coordinates (and sum for all such surfaces). Probably not the most general or foolproof method, but works for most of my geometry.
Thanks Eric! That's not a bad idea. The issue I ran into recently was when a building had "stacked" walls on the same plane. Since I didn't check whether each wall intersected with the floor surface, I ended up double counting perimeters. If I implemented something similar to what you suggested but then also did a check that the "z" coordinate was along the same plane as the floor, I bet it would work. I'm hoping to find a more elegant "OpenStudio" way of doing it, but so far finding nothing.
Yeah or you could always store the global min-Z for all surfaces and compare against that. Which would fail if you had different ground elevations, but that's a pretty special case. BTW it looks like
computeIntersection
would fail if the surfaces are not coplanar.