Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- when the boat wants to go home, it has to plot a route that might involve avoidance of the shore
- (e.g. in a lake shaped like a boomerang). To do that, the boat is going to imagine facing its destination,
- then projecting several 2-segment paths to the destination. whichever path is shortest but doesn't collide with the
- defined lake edge is the path which the robot will use.
- I haven't implemented edge detection like this before so It's going to take some effort.
- see notepad purple page 1
- """
- import math as Math
- class p:
- def __init__(self):
- self.x=x
- self.y=y
- self.d=d
- def xy(self):
- return [self.x,self.y]
- def exampleMapCircle(): #generates a circular map and returns it as a list of 'p' objects
- radius = 10
- numpoints = 20
- mappoints=[]
- for i in xrange(numpoints):
- angle = i*2 * 3.1416/numpoints
- newpoint = p(0,0,0)
- p.x = Math.cos(angle)*radius
- p.y = Math.sin(angle)*radius
- d = 0
- mappoints.append(p)
- return mappoints
- def exampleMapStar(): # generates the points of an n-pointed star
- innerradius = 5
- outerradius = 15
- numpoints = 5
- mappoints=[]
- for i in xrange(numpoints):
- point = p()
- angle= i*2*3.1416/numpoints
- p.x=Math.cos(angle) * innerradius
- p.y=Math.sin(angle) * innerradius
- mappoints.append(p)
- angle = (i+0.5)*2*3.1416/numpoints
- p.x=Math.cos(angle) * outerradius
- p.y=Math.sin(angle) * outerradius
- mappoints.append(p)
- print "done"
- exampleMapStar()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement