-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Position sampling in Environments with holes. #100
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,15 @@ | |
"""OTHER USEFUL FUNCTIONS""" | ||
"""Geometry functions""" | ||
|
||
def polygon_area(hole): | ||
"""Given 4-point list defining a hole in the environment, returns its area. | ||
Args: | ||
hole (array): list of list of points defining the hole. | ||
Returns: | ||
scalar: area of the hole. | ||
""" | ||
x, y = zip(*hole) | ||
return round(0.5*np.abs(np.dot(x,np.roll(y,1))-np.dot(y,np.roll(x,1))),2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does this formula come from? Also is it limited to holes with four points? By the way we already list shapely as a requirement so we could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's interesting I've never heard of this formula before. Could you (a) either refer to it as the shoelace formula in the doc string or (b) use Also, clarify that isn't just 4-corner holes that works, its any sized holes. Finally, in the docstrng make sure you remember to clarify the intended shape of holes ((N, 2) for N >= 3 presumably). Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, excellent! I did not realize shapely was imported. This is the same formula that shapely uses: the formula to calculate the area of a polygon given the list of points considering connectedness across the list of points. So we do not this in utils.py. |
||
|
||
def get_perpendicular(a=None): | ||
"""Given 2-vector, a, returns its perpendicular | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reference this param in the doc string