Python Question (Count Polygon Crossings of a Line)

   1437   0   2
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
I am trying to build a tool in python for a class that is able to fill a concave surface with points. I am looking at using the Crossing Number method from this site [geomalgorithms.com] extended into 3 dimensions. The plan is to draw a line from a randomly selected point along one of the axes to some large distance and count the number of surface crossings that it does. The process is repeated for the other 2 axes, then an AND statement is used to control an IF that adds the random point to a list. Something like this:


def fillObject(numPoints, testObject)
n=0
points =
while n < numPoints:
x=random
y=random
z=random
x_test = {insert crossing test here}
y_test = {insert crossing test here}
z_test = {insert crossing test here}
if (x_test%2==1) AND (y_test%2==1) AND (z_test%2==1):
n+=1
points.append(point.setPosition(x,y,z))


Unfortunately I am unsure of how to setup the crossing test. Any ideas?
  • Quick Links