sparrowpy.geometry#
Module for the geometry of the room and the environment.
Classes:
|
Polygon constructed from greater than two points. |
- class sparrowpy.geometry.Polygon(points: ndarray, up_vector: ndarray, normal: ndarray)[source]#
Bases:
objectPolygon constructed from greater than two points.
Only convex polygons are allowed! Order of points is of course important!
Attributes:
Return the area in m^2 of the polygon.
Return the center coordinates of the polygon.
Return the number of points of the polygon.
Return the normal vector of the polygon.
Return the size in (lxmxn) of the polygon.
Methods:
from_dict(input_dict)Create an object from a dictionary.
intersection(origin, direction)Return a intersection point with a ray and the polygon.
on_surface(point)Return if a point is on the surface of the polygon.
plot([ax, color])Plot the polygon.
plot_point([ax, color])Plot the polygon points.
plot_view_up([ax])Plot the view and up vector of the polygon.
to_dict()Convert this object to dictionary.
- property area: ndarray#
Return the area in m^2 of the polygon. supports all convex polygons and some concave polygons.
- intersection(origin: ndarray, direction: ndarray) ndarray[source]#
Return a intersection point with a ray and the polygon.
- Parameters:
origin (np.ndarray) – origin of the incoming wave
direction (np.ndarray) – direction of the incoming wave
- Returns:
intersection point, if it hit, otherwise None
- Return type:
np.ndarray
- property n_points: int#
Return the number of points of the polygon.
- on_surface(point: ndarray) bool[source]#
Return if a point is on the surface of the polygon.
Returns True if the point is on the polygon’s surface and false otherwise.
- plot(ax: Axes = None, color=None)[source]#
Plot the polygon.
- Parameters:
ax (matplotlib.axes.Axes, optional) – _description_, by default None
color (_type_, optional) – _description_, by default None