larvaworld.lib.model.envs.obstacle ================================== .. py:module:: larvaworld.lib.model.envs.obstacle Classes ------- .. autoapisummary:: larvaworld.lib.model.envs.obstacle.Obstacle larvaworld.lib.model.envs.obstacle.Box larvaworld.lib.model.envs.obstacle.Wall larvaworld.lib.model.envs.obstacle.Border Module Contents --------------- .. py:class:: Obstacle(model: Any | None = None, edges: Any | None = None, **kwargs: Any) Bases: :py:obj:`larvaworld.lib.model.GroupedObject`, :py:obj:`larvaworld.lib.param.ViewableLine` Base class for obstacles in simulation environment. Combines grouped object properties with viewable line visualization for rendering obstacles (walls, boxes, borders) in the arena. Attributes: model: Reference to simulation model edges: List of edge line segments defining obstacle boundaries Example: >>> obstacle = Obstacle(model=sim_model, edges=[[p1, p2], [p2, p3]]) .. py:attribute:: edges :value: None .. py:class:: Box(x: float = 0, y: float = 0, size: float = 1, **kwargs: Any) Bases: :py:obj:`Obstacle`, :py:obj:`larvaworld.lib.param.Pos2D` Rectangular box obstacle. Creates a square or rectangular obstacle centered at position (x, y) with specified size. Useful for creating containment areas or barriers. Attributes: x: Center x-coordinate y: Center y-coordinate size: Box side length closed: Whether box forms closed boundary (default: True) Example: >>> box = Box(x=0.5, y=0.5, size=0.2, color="black") .. py:attribute:: closed .. py:attribute:: size :value: 1 .. py:class:: Wall(point1: shapely.geometry.Point = geometry.Point(0, 0), point2: shapely.geometry.Point = geometry.Point(-1, 1), **kwargs: Any) Bases: :py:obj:`Obstacle` Linear wall obstacle between two points. Creates a straight wall segment from point1 to point2. Does not form closed boundary. Useful for maze construction and partial barriers. Attributes: point1: Starting point of wall segment point2: Ending point of wall segment closed: Whether wall forms closed boundary (default: False) Example: >>> wall = Wall(point1=Point(0, 0), point2=Point(1, 0), color="gray") .. py:attribute:: closed .. py:attribute:: point1 .. py:attribute:: point2 .. py:class:: Border(vertices: list[Any] = [], points: Any | None = None, **kwargs: Any) Bases: :py:obj:`Obstacle` Complex border obstacle from vertex list. Creates multi-segment border from sequence of vertices. Each consecutive vertex pair forms an edge. Supports scaling and coordinate transformations via define_lines method. Attributes: vertices: List of vertex coordinates defining border path points: Alternative point specification (optional) border_xy: Transformed vertex coordinates border_lines: LineString objects for each border segment closed: Whether border forms closed loop (default: False) Example: >>> border = Border(vertices=[(0, 0), (1, 0), (1, 1), (0, 1)]) >>> is_inside = border.contained((0.5, 0.5)) .. py:attribute:: closed .. py:attribute:: points :value: None .. py:method:: define_lines(vertices: list[Any], s: float = 1) -> tuple[list[Any], list[shapely.geometry.LineString]] .. py:method:: contained(p: Any) -> bool