Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. """
  2. when the boat wants to go home, it has to plot a route that might involve avoidance of the shore
  3. (e.g. in a lake shaped like a boomerang). To do that, the boat is going to imagine facing its destination,
  4. then projecting several 2-segment paths to the destination. whichever path is shortest but doesn't collide with the
  5. defined lake edge is the path which the robot will use.
  6.  
  7. I haven't implemented edge detection like this before so It's going to take some effort.
  8. see notepad purple page 1
  9.  
  10. """
  11. import math as Math
  12. class p:
  13. def __init__(self):
  14. self.x=x
  15. self.y=y
  16. self.d=d
  17. def xy(self):
  18. return [self.x,self.y]
  19.  
  20.  
  21.  
  22. def exampleMapCircle(): #generates a circular map and returns it as a list of 'p' objects
  23. radius = 10
  24. numpoints = 20
  25. mappoints=[]
  26. for i in xrange(numpoints):
  27. angle = i*2 * 3.1416/numpoints
  28. newpoint = p(0,0,0)
  29. p.x = Math.cos(angle)*radius
  30. p.y = Math.sin(angle)*radius
  31. d = 0
  32. mappoints.append(p)
  33. return mappoints
  34.  
  35. def exampleMapStar(): # generates the points of an n-pointed star
  36. innerradius = 5
  37. outerradius = 15
  38. numpoints = 5
  39. mappoints=[]
  40. for i in xrange(numpoints):
  41. point = p()
  42. angle= i*2*3.1416/numpoints
  43. p.x=Math.cos(angle) * innerradius
  44. p.y=Math.sin(angle) * innerradius
  45. mappoints.append(p)
  46. angle = (i+0.5)*2*3.1416/numpoints
  47. p.x=Math.cos(angle) * outerradius
  48. p.y=Math.sin(angle) * outerradius
  49. mappoints.append(p)
  50. print "done"
  51. exampleMapStar()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement