Unmet Hours - RSS feedhttps://unmethours.com/questions/Question-and-Answer Resource for the Building Energy Modeling CommunityenFri, 16 Oct 2020 11:32:15 -0500Best practice for determining if two Surfaces intersect?https://unmethours.com/question/43654/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` are `OpenStudio::Model::Surface`
- `surfaces_intersect` = a boolean that determines if `surface1` and `surface2` intersect
I've looked into the `computeIntersection` for Surface found [here](http://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-2.7.0-doc/model/html/classopenstudio_1_1model_1_1_surface.html#aebb4c63e3627e957d02e67ead8fd7a36) 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:
1. Identify if floor with outside boundary condition equal to *Ground*. If so, flag as a floor requiring a `FFactorGroundFloorConstruction`
2. 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.
3. 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!Mon, 06 Apr 2020 11:56:06 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/Comment by jugonzal07 for <p>Hi all,</p>
<p>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.</p>
<p>Ideally, the code would look something like.</p>
<pre><code>#Made up function 'intersectsWith'
surfaces_intersect = surface1.intersectsWith(surface2)
if surfaces_intersect
#DO SOMETHING
end
</code></pre>
<p>Where </p>
<ul>
<li><code>surface1</code>,<code>surface2</code> are <code>OpenStudio::Model::Surface</code> </li>
<li><code>surfaces_intersect</code> = a boolean that determines if <code>surface1</code> and <code>surface2</code> intersect</li>
</ul>
<p>I've looked into the <code>computeIntersection</code> for Surface found <a href="http://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-2.7.0-doc/model/html/classopenstudio_1_1model_1_1_surface.html#aebb4c63e3627e957d02e67ead8fd7a36">here</a> but am unsure if this is path would be the most elegant way to do this.</p>
<p>For context, I'm trying to dynamically determine the perimeter of a floor surface exposed to ambient to set them for a <code>FFactorGroundFloorConstruction</code>. I haven't seen any way to easily do this in OpenStudio. Here is my approach:</p>
<ol>
<li>Identify if floor with outside boundary condition equal to <em>Ground</em>. If so, flag as a floor requiring a <code>FFactorGroundFloorConstruction</code></li>
<li>Identify all walls in this floor's space. If the wall's outside boundary condition is <em>Outdoors</em> 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). <strong>NOTE</strong>: This assumes a wall only touches 1 floor; this might not always be true.</li>
<li>Add these perimeters for the floor to ultimately arrive at the exposed perimeter.</li>
</ol>
<p>I cannot complete step two as I do not have a way to determine if a wall intersects a floor surface.</p>
<p>Any ideas? Thanks!</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=43656#post-id-43656Thanks 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.Mon, 06 Apr 2020 15:53:35 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=43656#post-id-43656Comment by Eric Ringold for <p>Hi all,</p>
<p>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.</p>
<p>Ideally, the code would look something like.</p>
<pre><code>#Made up function 'intersectsWith'
surfaces_intersect = surface1.intersectsWith(surface2)
if surfaces_intersect
#DO SOMETHING
end
</code></pre>
<p>Where </p>
<ul>
<li><code>surface1</code>,<code>surface2</code> are <code>OpenStudio::Model::Surface</code> </li>
<li><code>surfaces_intersect</code> = a boolean that determines if <code>surface1</code> and <code>surface2</code> intersect</li>
</ul>
<p>I've looked into the <code>computeIntersection</code> for Surface found <a href="http://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-2.7.0-doc/model/html/classopenstudio_1_1model_1_1_surface.html#aebb4c63e3627e957d02e67ead8fd7a36">here</a> but am unsure if this is path would be the most elegant way to do this.</p>
<p>For context, I'm trying to dynamically determine the perimeter of a floor surface exposed to ambient to set them for a <code>FFactorGroundFloorConstruction</code>. I haven't seen any way to easily do this in OpenStudio. Here is my approach:</p>
<ol>
<li>Identify if floor with outside boundary condition equal to <em>Ground</em>. If so, flag as a floor requiring a <code>FFactorGroundFloorConstruction</code></li>
<li>Identify all walls in this floor's space. If the wall's outside boundary condition is <em>Outdoors</em> 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). <strong>NOTE</strong>: This assumes a wall only touches 1 floor; this might not always be true.</li>
<li>Add these perimeters for the floor to ultimately arrive at the exposed perimeter.</li>
</ol>
<p>I cannot complete step two as I do not have a way to determine if a wall intersects a floor surface.</p>
<p>Any ideas? Thanks!</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=43655#post-id-43655My 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](https://ruby-doc.org/core-2.5.0/Math.html#method-c-hypot) 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.Mon, 06 Apr 2020 15:45:48 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=43655#post-id-43655Comment by Eric Ringold for <p>Hi all,</p>
<p>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.</p>
<p>Ideally, the code would look something like.</p>
<pre><code>#Made up function 'intersectsWith'
surfaces_intersect = surface1.intersectsWith(surface2)
if surfaces_intersect
#DO SOMETHING
end
</code></pre>
<p>Where </p>
<ul>
<li><code>surface1</code>,<code>surface2</code> are <code>OpenStudio::Model::Surface</code> </li>
<li><code>surfaces_intersect</code> = a boolean that determines if <code>surface1</code> and <code>surface2</code> intersect</li>
</ul>
<p>I've looked into the <code>computeIntersection</code> for Surface found <a href="http://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-2.7.0-doc/model/html/classopenstudio_1_1model_1_1_surface.html#aebb4c63e3627e957d02e67ead8fd7a36">here</a> but am unsure if this is path would be the most elegant way to do this.</p>
<p>For context, I'm trying to dynamically determine the perimeter of a floor surface exposed to ambient to set them for a <code>FFactorGroundFloorConstruction</code>. I haven't seen any way to easily do this in OpenStudio. Here is my approach:</p>
<ol>
<li>Identify if floor with outside boundary condition equal to <em>Ground</em>. If so, flag as a floor requiring a <code>FFactorGroundFloorConstruction</code></li>
<li>Identify all walls in this floor's space. If the wall's outside boundary condition is <em>Outdoors</em> 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). <strong>NOTE</strong>: This assumes a wall only touches 1 floor; this might not always be true.</li>
<li>Add these perimeters for the floor to ultimately arrive at the exposed perimeter.</li>
</ol>
<p>I cannot complete step two as I do not have a way to determine if a wall intersects a floor surface.</p>
<p>Any ideas? Thanks!</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=43657#post-id-43657Yeah 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](https://github.com/NREL/OpenStudio/blob/2700a16d28ce7f8bf10cbdf16bfd1b1ac4263b31/src/model/Surface.cpp#L1036-L1039).Mon, 06 Apr 2020 16:02:41 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=43657#post-id-43657Answer by David Goldwasser for <p>Hi all,</p>
<p>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.</p>
<p>Ideally, the code would look something like.</p>
<pre><code>#Made up function 'intersectsWith'
surfaces_intersect = surface1.intersectsWith(surface2)
if surfaces_intersect
#DO SOMETHING
end
</code></pre>
<p>Where </p>
<ul>
<li><code>surface1</code>,<code>surface2</code> are <code>OpenStudio::Model::Surface</code> </li>
<li><code>surfaces_intersect</code> = a boolean that determines if <code>surface1</code> and <code>surface2</code> intersect</li>
</ul>
<p>I've looked into the <code>computeIntersection</code> for Surface found <a href="http://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-2.7.0-doc/model/html/classopenstudio_1_1model_1_1_surface.html#aebb4c63e3627e957d02e67ead8fd7a36">here</a> but am unsure if this is path would be the most elegant way to do this.</p>
<p>For context, I'm trying to dynamically determine the perimeter of a floor surface exposed to ambient to set them for a <code>FFactorGroundFloorConstruction</code>. I haven't seen any way to easily do this in OpenStudio. Here is my approach:</p>
<ol>
<li>Identify if floor with outside boundary condition equal to <em>Ground</em>. If so, flag as a floor requiring a <code>FFactorGroundFloorConstruction</code></li>
<li>Identify all walls in this floor's space. If the wall's outside boundary condition is <em>Outdoors</em> 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). <strong>NOTE</strong>: This assumes a wall only touches 1 floor; this might not always be true.</li>
<li>Add these perimeters for the floor to ultimately arrive at the exposed perimeter.</li>
</ol>
<p>I cannot complete step two as I do not have a way to determine if a wall intersects a floor surface.</p>
<p>Any ideas? Thanks!</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?answer=43658#post-id-43658@jugonzal07 I think by intersect here you are referring to two surfaces which share a common edge, as opposed to intersect surfaces related to surface matching, where you have to split a surface into two more elements to be able to match it to the adjacent zone.
We have a method to calculate building perimeter by story that works very much as you describe. It does have some limitations but it works in most cases. It creates an array of edges in a space and then store surfaces that use that edge. It finds an edge which has an exterior wall, and also has a ground or interior exposed floor. It then adds these together. This is in the `openstudio-extension` gem which is included with OpenStudio much like the `openstudio-standards` gem.
https://github.com/NREL/openstudio-extension-gem/blob/5518fbdbc2faf3746dce3947a33556f3be82acef/lib/openstudio/extension/core/os_lib_geometry.rb#L1134
An alternative approach I have played with is using method in OpenStudio that merges multiple polygons into a single polygon. Then you can just sum the length of the edges. I have used this method to create a geojson footprint from an OpenStudio model. There were some issues with this so it was not stable enough for me to want to use to calculate perimeter yet but if you want to explore that I can find a link to it.Mon, 06 Apr 2020 17:47:07 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?answer=43658#post-id-43658Comment by jugonzal07 for <p><a href="/users/1618/jugonzal07/">@jugonzal07</a> I think by intersect here you are referring to two surfaces which share a common edge, as opposed to intersect surfaces related to surface matching, where you have to split a surface into two more elements to be able to match it to the adjacent zone.</p>
<p>We have a method to calculate building perimeter by story that works very much as you describe. It does have some limitations but it works in most cases. It creates an array of edges in a space and then store surfaces that use that edge. It finds an edge which has an exterior wall, and also has a ground or interior exposed floor. It then adds these together. This is in the <code>openstudio-extension</code> gem which is included with OpenStudio much like the <code>openstudio-standards</code>gem.
<a href="https://github.com/NREL/openstudio-extension-gem/blob/5518fbdbc2faf3746dce3947a33556f3be82acef/lib/openstudio/extension/core/os_lib_geometry.rb#L1134">https://github.com/NREL/openstudio-ex...</a></p>
<p>An alternative approach I have played with is using method in OpenStudio that merges multiple polygons into a single polygon. Then you can just sum the length of the edges. I have used this method to create a geojson footprint from an OpenStudio model. There were some issues with this so it was not stable enough for me to want to use to calculate perimeter yet but if you want to explore that I can find a link to it.</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=45582#post-id-45582Thanks David, I ended up using a similar idea to what you had. You can find it in my answer above.Wed, 01 Jul 2020 12:52:29 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=45582#post-id-45582Comment by Luis Lara for <p><a href="/users/1618/jugonzal07/">@jugonzal07</a> I think by intersect here you are referring to two surfaces which share a common edge, as opposed to intersect surfaces related to surface matching, where you have to split a surface into two more elements to be able to match it to the adjacent zone.</p>
<p>We have a method to calculate building perimeter by story that works very much as you describe. It does have some limitations but it works in most cases. It creates an array of edges in a space and then store surfaces that use that edge. It finds an edge which has an exterior wall, and also has a ground or interior exposed floor. It then adds these together. This is in the <code>openstudio-extension</code> gem which is included with OpenStudio much like the <code>openstudio-standards</code>gem.
<a href="https://github.com/NREL/openstudio-extension-gem/blob/5518fbdbc2faf3746dce3947a33556f3be82acef/lib/openstudio/extension/core/os_lib_geometry.rb#L1134">https://github.com/NREL/openstudio-ex...</a></p>
<p>An alternative approach I have played with is using method in OpenStudio that merges multiple polygons into a single polygon. Then you can just sum the length of the edges. I have used this method to create a geojson footprint from an OpenStudio model. There were some issues with this so it was not stable enough for me to want to use to calculate perimeter yet but if you want to explore that I can find a link to it.</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=43663#post-id-43663This looks super interesting. I will play around with the `calculate_perimeter` method.Mon, 06 Apr 2020 18:31:01 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=43663#post-id-43663Answer by jugonzal07 for <p>Hi all,</p>
<p>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.</p>
<p>Ideally, the code would look something like.</p>
<pre><code>#Made up function 'intersectsWith'
surfaces_intersect = surface1.intersectsWith(surface2)
if surfaces_intersect
#DO SOMETHING
end
</code></pre>
<p>Where </p>
<ul>
<li><code>surface1</code>,<code>surface2</code> are <code>OpenStudio::Model::Surface</code> </li>
<li><code>surfaces_intersect</code> = a boolean that determines if <code>surface1</code> and <code>surface2</code> intersect</li>
</ul>
<p>I've looked into the <code>computeIntersection</code> for Surface found <a href="http://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-2.7.0-doc/model/html/classopenstudio_1_1model_1_1_surface.html#aebb4c63e3627e957d02e67ead8fd7a36">here</a> but am unsure if this is path would be the most elegant way to do this.</p>
<p>For context, I'm trying to dynamically determine the perimeter of a floor surface exposed to ambient to set them for a <code>FFactorGroundFloorConstruction</code>. I haven't seen any way to easily do this in OpenStudio. Here is my approach:</p>
<ol>
<li>Identify if floor with outside boundary condition equal to <em>Ground</em>. If so, flag as a floor requiring a <code>FFactorGroundFloorConstruction</code></li>
<li>Identify all walls in this floor's space. If the wall's outside boundary condition is <em>Outdoors</em> 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). <strong>NOTE</strong>: This assumes a wall only touches 1 floor; this might not always be true.</li>
<li>Add these perimeters for the floor to ultimately arrive at the exposed perimeter.</li>
</ol>
<p>I cannot complete step two as I do not have a way to determine if a wall intersects a floor surface.</p>
<p>Any ideas? Thanks!</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?answer=45581#post-id-45581Hi all,
I ended up writing my own script for calculating a wall and floor intersection. It comes with some caveats (found in the comments) but it can be found here:
https://github.com/NREL/openstudio-standards/blob/master/lib/openstudio-standards/prototypes/common/objects/Prototype.Model.rb#L699-L748
It's how I ended up solving this issue. It's not super generalized, but works for calculating most cases of walls and floors. Any feedback on it would be greatly appreciated.
Thanks!
EDIT: Updated URLWed, 01 Jul 2020 12:51:24 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?answer=45581#post-id-45581Comment by jugonzal07 for <p>Hi all,</p>
<p>I ended up writing my own script for calculating a wall and floor intersection. It comes with some caveats (found in the comments) but it can be found here:</p>
<p><a href="https://github.com/NREL/openstudio-standards/blob/master/lib/openstudio-standards/prototypes/common/objects/Prototype.Model.rb#L699-L748">https://github.com/NREL/openstudio-st...</a></p>
<p>It's how I ended up solving this issue. It's not super generalized, but works for calculating most cases of walls and floors. Any feedback on it would be greatly appreciated.</p>
<p>Thanks!</p>
<p>EDIT: Updated URL</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=48097#post-id-48097Thanks for catching that. I have updated the link.Fri, 16 Oct 2020 11:32:15 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=48097#post-id-48097Comment by Adrià González-Esteve for <p>Hi all,</p>
<p>I ended up writing my own script for calculating a wall and floor intersection. It comes with some caveats (found in the comments) but it can be found here:</p>
<p><a href="https://github.com/NREL/openstudio-standards/blob/master/lib/openstudio-standards/prototypes/common/objects/Prototype.Model.rb#L699-L748">https://github.com/NREL/openstudio-st...</a></p>
<p>It's how I ended up solving this issue. It's not super generalized, but works for calculating most cases of walls and floors. Any feedback on it would be greatly appreciated.</p>
<p>Thanks!</p>
<p>EDIT: Updated URL</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=48093#post-id-48093@jugonzal07 the link is not available anymore.Fri, 16 Oct 2020 09:33:17 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?comment=48093#post-id-48093Answer by Adrià González-Esteve for <p>Hi all,</p>
<p>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.</p>
<p>Ideally, the code would look something like.</p>
<pre><code>#Made up function 'intersectsWith'
surfaces_intersect = surface1.intersectsWith(surface2)
if surfaces_intersect
#DO SOMETHING
end
</code></pre>
<p>Where </p>
<ul>
<li><code>surface1</code>,<code>surface2</code> are <code>OpenStudio::Model::Surface</code> </li>
<li><code>surfaces_intersect</code> = a boolean that determines if <code>surface1</code> and <code>surface2</code> intersect</li>
</ul>
<p>I've looked into the <code>computeIntersection</code> for Surface found <a href="http://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-2.7.0-doc/model/html/classopenstudio_1_1model_1_1_surface.html#aebb4c63e3627e957d02e67ead8fd7a36">here</a> but am unsure if this is path would be the most elegant way to do this.</p>
<p>For context, I'm trying to dynamically determine the perimeter of a floor surface exposed to ambient to set them for a <code>FFactorGroundFloorConstruction</code>. I haven't seen any way to easily do this in OpenStudio. Here is my approach:</p>
<ol>
<li>Identify if floor with outside boundary condition equal to <em>Ground</em>. If so, flag as a floor requiring a <code>FFactorGroundFloorConstruction</code></li>
<li>Identify all walls in this floor's space. If the wall's outside boundary condition is <em>Outdoors</em> 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). <strong>NOTE</strong>: This assumes a wall only touches 1 floor; this might not always be true.</li>
<li>Add these perimeters for the floor to ultimately arrive at the exposed perimeter.</li>
</ol>
<p>I cannot complete step two as I do not have a way to determine if a wall intersects a floor surface.</p>
<p>Any ideas? Thanks!</p>
https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?answer=48094#post-id-48094Based on [this](https://www.lucidarme.me/intersection-of-segments/), I wrote the following [function](https://github.com/agonzalezesteve/ZeroEnvelope/blob/2b721a517ecdeb967b33cc531411fc6bcaae5e97/plugin/zeroenvelope/lib/src/Geometry.rb#L5) that I've just shared.
def self.get_length(vertices_a, vertices_b)
length = 0.0
vertices_a.each_with_index do |vertex_a, index_a|
prev_a = vertices_a[index_a-1]
vertices_b.each_with_index do |vertex_b, index_b|
prev_b = vertices_b[index_b-1]
p1 = prev_a
p2 = vertex_a
p3 = prev_b
p4 = vertex_b
p12 = p2-p1
p34 = p4-p3
next unless p12.cross(p34).length < 1e-6
p13 = p3-p1
next unless p12.cross(p13).length < 1e-6
p14 = p4-p1
k2 = p12.dot(p12)
k3 = p12.dot(p13)
k4 = p12.dot(p14)
table = [
[0.0, p14.length, p12.length],
[p13.length, p34.length, (p3-p2).length],
[p12.length, (p4-p2).length, 0.0]
]
row = if k3 < 1e-6 then
0
elsif k3 < k2 then
1
else
2
end
col = if k4 < 1e-6 then
0
elsif k4 < k2 then
1
else
2
end
length += table[row][col]
end
end
length /= 2 if vertices_a.length.eql?(2)
length /= 2 if vertices_b.length.eql?(2)
return length
end
Fri, 16 Oct 2020 09:33:59 -0500https://unmethours.com/question/43654/best-practice-for-determining-if-two-surfaces-intersect/?answer=48094#post-id-48094