Grasshopper

algorithmic modeling for Rhino

I am using the following function to figure out if a Point is within a boundary area and outside an obstacle, mostly it works as expected but in some cases it doesn't:

Private Function Inside(ByVal Obstacle As List(Of Curve), _
                        ByVal Boundary As Curve, _
                        ByVal p As Point3d, _
                        Optional ByVal dt As Double = 0) _

                        As Boolean

  Dim t As Double

  If Boundary.Contains(p) = PointContainment.Outside Then
      Return False
  ElseIf dt > 0 Then
      Boundary.ClosestPoint(p, t)
      If p.DistanceTo(Boundary.PointAt(t)) < dt Then
         Return False
      End If
  End If

  For Each c As Curve In Obstacle
    If c.Contains(p) = PointContainment.Inside Then
      Return False
    ElseIf dt > 0 Then
      c.ClosestPoint(p, t)
      If p.DistanceTo(c.PointAt(t)) < dt Then
        Return False
      End If
    End If
  Next

  Return True
End Function

I have moved it to a VB Script node and found out that for a point that is miles within the boundary the function Curve.contains(P) returns that it is outside. (see image e.g. cell 4079) Any suggestions?

Best Richard

Views: 1047

Replies to This Discussion

Hi Richard,

any chance of getting the files needed to replicate this?

--

David Rutten

david@mcneel.com

Attached a file, would need to install SpiderWeb that is why I didn't include it at the beginning...

Attachments:

I get a whole bunch of wrong answers when using Curve.Contains.

For some reason the [Point In Curve] component gets it right, even though it eventually uses the same method. I haven't been able to figure out why yet.

--

David Rutten

david@mcneel.com

Any suggestion for an other methode? like limiting it to polylines or ... ?

Sorry, I'm on the road at the moment, I'd go for bitmap pixel testing since it's a nice squareish curve. I can do some testing once I'm back home on monday.

Hmm, that want do need a general solution and not a specific...

its not such a hurry was just wondering.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service