models

agents

Defines a class Agent to store physical attributes and geometry of agents.

class configuration.models.agents.Agent(agent_type, measures)[source]

Bases: object

Class representing an agent with physical attributes and geometry.

Parameters:
  • agent_type (AgentTypes) -- The type of the agent.

  • measures (dict[str, float | Sex] | AgentMeasures) -- The measures associated with the agent. Can be a dictionary with measure names as keys and float values or Sex (Literal["male","female"]), or an AgentMeasures object.

property agent_type: AgentTypes

Get the agent type.

Returns:

The current agent type from the enumeration AgentTypes.

Return type:

AgentType

property measures: AgentMeasures

Access the agent's physical measurement data.

Returns:

Dataclass object holding all measurement parameters.

Return type:

AgentMeasures

property shapes2D: Shapes2D

Access the agent's 2D representation.

Returns:

Dataclass object holding all 2D shapes defining the agent's spatial boundaries.

Return type:

Shapes2D

property shapes3D: Shapes3D | None

Access the agent's 3D geometric representations.

Returns:

Dataclass object holding all 3D shapes defining the agent's 3D features, if available. None if not set.

Return type:

Shapes3D | None

translate(dx, dy)[source]

Translate all 2D shapes by the specified offsets in x and y directions.

Parameters:
  • dx (float) -- Translation offset along the x-axis (cm).

  • dy (float) -- Translation offset along the y-axis (cm).

Return type:

None

Notes

  • Does not affect 3D shapes.

rotate(angle)[source]

Rotate all 2D shapes around the agent position (defined by its centroid) by the specified angle.

Parameters:

angle (float) -- Rotation angle in degrees (positive for counter-clockwise).

Return type:

None

Notes

Does not affect 3D shapes.

get_position()[source]

Calculate the agent's position based on 2D shape geometry.

Returns:

The mean of the centroids of all composite shapes of the 2D representation of the agent.

Return type:

Point

translate_body3D(dx, dy, dz)[source]

Translate 3D shapes along all spatial axes with height adjustment.

Parameters:
  • dx (float) -- Displacement along x-axis (cm).

  • dy (float) -- Displacement along y-axis (cm).

  • dz (float) -- Vertical displacement along the z-axis (cm), modifying height keys in shapes3D.

Raises:

ValueError -- If shapes3D is None.

Return type:

None

rotate_body3D(angle)[source]

Rotate all 3D shapes on XY plane around Z-axis.

Parameters:

angle (float) -- Rotation angle in degrees (positive counter-clockwise).

Raises:

ValueError -- If shapes3D is None.

Return type:

None

get_centroid_body3D()[source]

Calculate the centroid of the agent's 3D body.

Returns:

The centroid of the agent's 3D body, calculated as the mean of the centroid of each 3D body layer.

Return type:

Point

Raises:

ValueError -- If shapes3D is None.

get_delta_GtoGi()[source]

Give the position vector from the agent centroid to the centroid of each shape.

Returns:

Dictionary with shape names as keys and tuples of x and y coordinates as values, representing the position vector from the agent centroid to the centroid of each shape.

Return type:

dict[str, tuple[float, float]]

get_agent_orientation()[source]

Get the agent's orientation angle as the direction orthogonal to the one given by the shoulders.

The shoulders direction is computed from the first shape minus the last shape position.

Returns:

The orientation of the agent in degrees.

Return type:

float

crowd

Module containing the Crowd class, which represents a crowd of pedestrians in a room.

class configuration.models.crowd.Crowd(measures=None, agents=None, boundaries=None)[source]

Bases: object

Class representing a crowd of pedestrians in a room.

Parameters:
  • measures (dict[str, float] | CrowdMeasures | None) --

    Crowd measures data. Can be:
    • A dictionary of agent statistics (str keys, float values)

    • A CrowdMeasures instance

    • None (default) when agents are provided instead

  • agents (list[Agent] | None) -- List of Agent instances. If None, measures must be provided. When agents are provided, crowd statistics will be calculated from them.

  • boundaries (Polygon | None) -- A shapely Polygon instance defining the boundaries. If None, a default large square boundary is created.

property agents: list[Agent]

Get the list of agents in the crowd.

Returns:

A list containing all the agents in the crowd.

Return type:

list[Agent]

property measures: CrowdMeasures

Get the measures of the crowd.

Returns:

A CrowdMeasures object containing the measures of the crowd.

Return type:

CrowdMeasures

property boundaries: Polygon

Get the boundaries of the room.

Returns:

The boundaries of the room as a shapely Polygon object.

Return type:

Polygon

get_number_agents()[source]

Get the number of agents in the crowd.

Returns:

The number of agents in the crowd.

Return type:

int

add_one_agent()[source]

Add a new agent to the crowd using available measures data.

The agent creation follows this priority: 1. Uses agent statistics if available 2. Uses the default ANSURII database

Return type:

None

create_agents(number_agents=4)[source]

Create multiple agents in the crowd from the given CrowdMeasures (ANSURII database by default).

Parameters:

number_agents (int) -- Number of agents to create.

Return type:

None

calculate_interpenetration()[source]

Compute the total interpenetration area between pedestrians and between pedestrians and boundaries.

Returns:

The total interpenetration area between pedestrians and between pedestrians and boundaries.

Return type:

float

calculate_covered_area()[source]

Calculate the total area covered by all 2D agents in the crowd.

Returns:

The total area covered by all 2D agents.

Return type:

float

static calculate_contact_force(agent_centroid, other_centroid)[source]

Compute the repulsive force between two centroids.

Parameters:
  • agent_centroid (Point) -- The centroid of the agent.

  • other_centroid (Point) -- The centroid of the other agent.

Returns:

The normalized direction of the repulsive force as a 1D NumPy array of floats. If the centroids coincide, a small random force is returned.

Return type:

NDArray[np.float64]

static calculate_repulsive_force(agent_centroid, other_centroid, repulsion_length)[source]

Compute the repulsive force between two centroids, exponentially decreasing with distance.

Parameters:
  • agent_centroid (Point) -- The centroid of the agent.

  • other_centroid (Point) -- The centroid of the other agent.

  • repulsion_length (float) -- Coefficient used to compute the magnitude of the repulsive force between agents. The force decreases exponentially with distance divided by this repulsion_length.

Returns:

A 1D NumPy array representing the repulsive force vector. If the centroids coincide, a small random force is returned.

Return type:

NDArray[np.float64]

static calculate_rotational_force(temperature)[source]

Generate a random rotational force value.

Parameters:

temperature (float) -- Current cooling system coefficient (0.0-1.0) that scales rotational forces.

Returns:

Random rotational force in degrees.

Return type:

float

calculate_boundary_forces(current_geo, temperature)[source]

Compute boundary interaction forces for an agent near environment edges.

Parameters:
  • current_geo (Polygon) -- Shapely Polygon representing the agent's current geometric position.

  • temperature (float) -- Current cooling system coefficient [0.0-1.0] that scales rotational forces.

Returns:

Updated force vector with boundary interactions.

Return type:

NDArray[np.float64]

Notes

  • Forces are only applied when the agent is outside the boundaries or touching boundary edges.

  • Force calculations:
    1. Contact force: Linear repulsion from nearest boundary point.

    2. Rotational force: Temperature-scaled random torque.

static check_validity_parameters_agents_packing(repulsion_length, desired_direction, variable_orientation)[source]

Validate the input parameters for agent packing.

Parameters:
  • repulsion_length (float) -- The repulsion length.

  • desired_direction (float) -- The desired direction.

  • variable_orientation (bool) -- A flag indicating whether variable orientation is enabled.

Return type:

None

update_shapes3D_based_on_shapes2D()[source]

Update the position and orientation of 3D shapes of all agents based on their 2D shapes.

This method iterates through each agent in the crowd and updates its 3D shapes position and orientation based on the corresponding 2D shapes.

Return type:

None

translate_crowd(dx, dy)[source]

Translate all agents in the crowd by a specified offset.

Parameters:
  • dx (float) -- The offset to translate in the x-direction.

  • dy (float) -- The offset to translate in the y-direction.

Return type:

None

pack_agents_with_forces(repulsion_length=5.0, desired_direction=0.0, variable_orientation=False)[source]

Simulate crowd dynamics using physics-based forces to resolve agent overlaps.

Iteratively calculates repulsive forces between agents and boundary constraints, while applying rotational adjustments. Implements a temperature-based cooling system to gradually reduce movement intensity over iterations.

Parameters:
  • repulsion_length (float) -- Exponential decay coefficient for repulsive forces between agents. Higher values increase the effective range of repulsion.

  • desired_direction (float) -- Initial orientation angle in degrees for all agents.

  • variable_orientation (bool) -- Whether to apply rotational forces during packing. When True, enables random angular adjustments based on collision forces.

Return type:

None

Notes

  • Boundary handling:
    • Uses Shapely Polygon objects for boundary constraints

    • Agents cannot move outside boundary polygons

    • Boundaries are treated as static

  • Force calculations:
    1. Agent-agent repulsion (exponential decay with distance)

    2. Contact forces for overlapping agents

    3. Boundary repulsion for agents near edges

    4. Rotational forces (only when variable_orientation=True)

unpack_crowd()[source]

Translate all agents in the crowd to the origin (0, 0).

Return type:

None

pack_agents_on_grid(grid_size_x=31.0, grid_size_y=60.0)[source]

Arrange the agents on a square 2D grid with specified cell sizes, ensuring that the smallest x and y coordinates are at (0, 0).

Parameters:
  • grid_size_x (float) -- Width of each grid cell (distance between agents in x-direction).

  • grid_size_y (float) -- Height of each grid cell (distance between agents in y-direction).

Return type:

None

static compute_stats(data, stats_key)[source]

Compute statistics.

Parameters:
  • data (list[float | None]) -- The list of numerical values to compute statistics for.

  • stats_key (str) -- The type of statistic to compute ('mean', 'std_dev', 'min', 'max').

Returns:

The computed statistic or None if data is empty or invalid.

Return type:

float | None

get_crowd_statistics()[source]

Measure the statistics of the crowd.

Returns:

A dictionary whose keys and values are:
  • stats_counts: A dictionary with counts of agents by type.

  • stats_lists: A dictionary with lists of measurements for each agent type.

  • measures: A dictionary of computed statistics for the crowd.

Return type:

dict[str, dict[str, int] | dict[str, list[float | None]] | dict[str, float | int | None]]

Notes

The dictionary containing the computed statistics for the crowd has keys formatted as follows:
  • "{kind}_proportion": Count of agents (e.g., "male_proportion" or "bike_proportion" or "pedestrian_proportion")

  • "{part}_mean": Mean value for each body/bike part measurement

  • "{part}_std_dev": Sample standard deviation for each part

  • "{part}_min": Minimum observed value for each part

  • "{part}_max": Maximum observed value for each part

The dictionary containing the counts of agents by type has keys formatted as follows:
  • "pedestrian_number": Total number of pedestrians

  • "male_number": Total number of males

  • "bike_number": Total number of bikes

The dictionary containing the lists of measurements for each agent type has keys formatted as follows:
  • "bike_weight": List of weights for all bikes

  • "male_bideltoid_breadth": List of bideltoid breadths for all male pedestrians

  • "male_chest_depth": List of chest depths for all male pedestrians

  • "male_height": List of heights for all male pedestrians

  • "male_weight": List of weights for all male pedestrians

  • "female_bideltoid_breadth": List of bideltoid breadths for all female pedestrians

  • "female_chest_depth": List of chest depths for all female pedestrians

  • "female_height": List of heights for all female pedestrians

  • "female_weight": List of weights for all female pedestrians

  • "wheel_width": List of wheel widths for all bikes

  • "total_length": List of total lengths for all bikes

  • "handlebar_length": List of handlebar lengths for all bikes

  • "top_tube_length": List of top tube lengths for all bikes

configuration.models.crowd.create_agents_from_dynamic_static_geometry_parameters(static_dict, dynamic_dict, geometry_dict)[source]

Create agents from dynamic and static geometry parameters.

Parameters:
  • static_dict (StaticCrowdDataType) -- Dictionary containing static crowd data.

  • dynamic_dict (DynamicCrowdDataType) -- Dictionary containing dynamic crowd data.

  • geometry_dict (GeometryDataType) -- Dictionary containing geometry data.

Returns:

A Crowd object containing the created agents and the scene boundaries.

Return type:

Crowd

initial_agents

Module defining the InitialPedestrian and InitialBike classes.

class configuration.models.initial_agents.InitialPedestrian(sex)[source]

Bases: object

Class representing the initial pedestrian state including its 2D shape data and basic measurements.

Parameters:

sex (Sex) -- Biological sex of the pedestrian, must be either "male" or "female".

property sex: Literal['male', 'female']

Get the biological sex of the pedestrian.

Returns:

The biological sex of the pedestrian as either "male" or "female".

Return type:

Sex

Raises:
  • ValueError -- If provided value is not "male" or "female"

  • TypeError -- If non-string value is provided

property agent_type: AgentTypes

Get the type of the agent.

Returns:

Enum member representing the agent's type classification (either "pedestrian", "bike" or "custom").

Return type:

AgentTypes

property shapes2D: dict[str, dict[str, Literal['disk', 'rectangle', 'polygon'] | Literal['concrete', 'human_naked', 'human_clothes'] | float]] | dict[str, dict[str, Literal['disk', 'rectangle', 'polygon'] | Literal['concrete', 'human_naked', 'human_clothes'] | float | Polygon | MultiPolygon]]

Get the 2D geometric representation of the pedestrian's body components.

Returns:

Dictionary containing circular disk representations of body parts with:
  • Keys: Format "disk{N}" where N ranges 0-4 (e.g., "disk0", "disk1")

  • Values: Dictionaries with properties:
    • type: "disk" (str from ShapeTypes enum name)

    • radius: Disk radius (cm)

    • material: Material name (str from MaterialNames enum)

    • x: x-coordinate (cm)

    • y: y-coordinate (cm)

Return type:

ShapeDataType

property measures: dict[str, float | Literal['male', 'female'] | None]

Get the measures of the pedestrian.

Returns:

A dictionary containing the pedestrian's measures. The keys are measure name.

Return type:

dict[str, float | Sex | None]

property shapes3D: dict[float, MultiPolygon]

Get the 3D body representation of the pedestrian.

Returns:

A dictionary where:
  • Keys are float representing the height of each pedestrian slice.

  • Values are "MultiPolygon" objects representing the 2D geometry of each layer or slice.

Return type:

dict[float, MultiPolygon]

get_position()[source]

Get the centroid position of the pedestrian based on their 2D shapes.

Returns:

A Point object representing the centroid of the pedestrian's geometry.

Return type:

Point

get_disk_centers()[source]

Retrieve the center coordinates of all disks of the agent physical shape.

Returns:

A list of Point objects representing the center coordinates of each disk (cm). The points are returned in the order of disk indices (disk0, disk1, ..., diskN-1).

Return type:

list[Point]

get_disk_radii()[source]

Retrieve the radii of all disks of the agent physical shape.

Returns:

A list containing the radii of the disks in the order they are stored.

Return type:

list[float]

get_reference_multipolygon()[source]

Get the reference multipolygon of the agent i.e. the one at torso height.

Returns:

The reference multipolygon of the agent.

Return type:

MultiPolygon

get_bideltoid_breadth()[source]

Compute the bideltoid breadth of the agent (that has not rotated) in cm.

Returns:

The bideltoid breadth of the agent (cm).

Return type:

float

get_chest_depth()[source]

Compute the chest depth of the agent (that has not rotated) in cm.

Returns:

The chest depth of the agent (cm).

Return type:

float

get_height()[source]

Compute the height of the agent (cm).

Returns:

The height of the agent (cm).

Return type:

float

class configuration.models.initial_agents.InitialBike[source]

Bases: object

Class representing the initial state of a bike, including its 2D shape data and derived measurements.

property agent_type: AgentTypes

Get the type of the agent.

Returns:

Enum member representing the agent's type classification (either "pedestrian", "bike" or "custom").

Return type:

AgentTypes

property shapes2D: dict[str, dict[str, Literal['disk', 'rectangle', 'polygon'] | Literal['concrete', 'human_naked', 'human_clothes'] | float]] | dict[str, dict[str, Literal['disk', 'rectangle', 'polygon'] | Literal['concrete', 'human_naked', 'human_clothes'] | float | Polygon | MultiPolygon]]

Get the 2D shapes of the agent.

Returns:

An object containing the 2D shapes of the agent.

Return type:

ShapeDataType

property measures: dict[str, float | None]

Get the measures of the agent.

Returns:

A dictionary containing the measures of the agent. Keys are measure names and values are measure values.

Return type:

dict[str, float | None]

get_position()[source]

Compute the centroid position of the agent based on all 2D shapes.

Returns:

A Point object representing the centroid of the agent's geometry.

Return type:

Point

Raises:

ValueError -- If no valid shapes are found in self.shapes2D.

measures

Module containing the AgentMeasures and CrowdMeasures dataclass to store body measures and crowd desired measures.

class configuration.models.measures.AgentMeasures(agent_type, measures=<factory>)[source]

Bases: object

Class to store body characteristics based on agent type.

Parameters:
agent_type: AgentTypes
measures: dict[str, Union[float, Literal['male', 'female']]]
number_of_measures()[source]

Return the number of measures stored.

Returns:

The number of measures stored in the "measures" attribute.

Return type:

int

class configuration.models.measures.CrowdMeasures(default_database=<factory>, agent_statistics=<factory>)[source]

Bases: object

Collection of dictionaries (databases and statistics) representing the characteristics of the crowd, used to create agents.

Parameters:
default_database: dict[int, dict[str, float]]
agent_statistics: dict[str, float]
configuration.models.measures.draw_agent_measures(agent_type, crowd_measures)[source]

Draw randomly a set of agent measures based on the agent type.

Parameters:
  • agent_type (AgentTypes) -- The type of agent for which to draw measures. Must be either AgentTypes.pedestrian or AgentTypes.bike.

  • crowd_measures (CrowdMeasures) -- An object containing statistical measures for the crowd, including both pedestrian and bike-specific measurements.

Returns:

An object containing the randomly drawn measures for the specified agent type.

Return type:

AgentMeasures

configuration.models.measures.draw_agent_type(crowd_measures)[source]

Draw a random agent type using tower sampling algorithm.

Parameters:

crowd_measures (CrowdMeasures) -- An instance of CrowdMeasures containing the statistics of different agent types in the crowd.

Returns:

The randomly selected agent type (pedestrian or bike) based on the given proportions.

Return type:

AgentTypes

Raises:

ValueError -- If the sum of pedestrian and bike proportions is not equal to 1.

configuration.models.measures.create_pedestrian_measures(agent_data)[source]

Create pedestrian-specific AgentMeasures object.

Parameters:

agent_data (dict[str, float]) --

A dictionary containing pedestrian measurements. Expected keys are:
  • "sex": The sex of the pedestrian (either "male" or "female").

  • "bideltoid breadth [cm]": Shoulder width in centimeters.

  • "chest depth [cm]": Depth of the chest in centimeters.

  • "height [cm]": Height of the pedestrian in centimeters.

  • "weight [kg]": Weight of the pedestrian in kilograms.

Returns:

An AgentMeasures object.

Return type:

AgentMeasures

configuration.models.measures.create_bike_measures(agent_data)[source]

Create bike-specific AgentMeasures object.

Parameters:

agent_data (dict[str, float]) --

A dictionary containing bike measurements. Expected keys are:
  • "wheel width [cm]": Width of the bike's wheel in centimeters.

  • "total length [cm]": Total length of the bike in centimeters.

  • "handlebar length [cm]": Length of the bike's handlebar in centimeters.

  • "top tube length [cm]": Length of the bike's top tube in centimeters.

Returns:

An AgentMeasures object with the following attributes:
  • agent_type: Set to AgentTypes.bike

  • measures: A dictionary mapping bike parts to their measurements

Return type:

AgentMeasures

shapes2D

Class to store body shapes based on agent type.

class configuration.models.shapes2D.Shapes2D(agent_type, shapes=<factory>)[source]

Bases: object

Class to store body shapes based on agent type.

This class allows you to manage shapes in two ways:

  1. Provide a dictionary of pre-defined Shapely shapes as input

  2. Specify the type of shape and its characteristics to create it

Parameters:
  • agent_type (AgentTypes)

  • shapes (dict[str, dict[str, Literal['disk', 'rectangle', 'polygon'] | ~typing.Literal['concrete', 'human_naked', 'human_clothes'] | float]] | dict[str, dict[str, ~typing.Literal['disk', 'rectangle', 'polygon'] | ~typing.Literal['concrete', 'human_naked', 'human_clothes'] | float | ~shapely.geometry.polygon.Polygon | ~shapely.geometry.multipolygon.MultiPolygon]])

agent_type: AgentTypes
shapes: dict[str, dict[str, Union[Literal['disk', 'rectangle', 'polygon'], Literal['concrete', 'human_naked', 'human_clothes'], float]]] | dict[str, dict[str, Union[Literal['disk', 'rectangle', 'polygon'], Literal['concrete', 'human_naked', 'human_clothes'], float, Polygon, MultiPolygon]]]
add_shape(name, shape_type, material, **kwargs)[source]

Create a shape and add it to the shapes dictionary.

Parameters:
  • name (str) -- The name of the shape.

  • shape_type (ShapeType) -- The type of the shape. Must be one of the following: {'disk', 'rectangle', 'polygon'}.

  • material (MaterialType) -- The material of the shape.

  • **kwargs (Any) --

    Additional keyword arguments specific to the shape type:

    • Disk:

      • x (float): The x-coordinate of the disk's center.

      • y (float): The y-coordinate of the disk's center.

      • radius (float): The radius of the disk.

      • material (str): The material of the disk.

    • Rectangle:

      • min_x (float): The minimum x-coordinate of the rectangle.

      • min_y (float): The minimum y-coordinate of the rectangle.

      • max_x (float): The maximum x-coordinate of the rectangle.

      • max_y (float): The maximum y-coordinate of the rectangle.

      • material (str): The material of the rectangle.

    • Polygon:

      • points (list of tuple[float, float]): A list of (x, y) coordinates representing

        the vertices of the polygon. Must contain at least 3 points, and the first and last points must match to close the polygon.

      • material (str): The material of the polygon.

Raises:

ValueError -- If the shape type is unsupported or if required keyword arguments are missing or invalid.

Return type:

None

Notes

This method validates that all required parameters are provided and ensures that shapes are correctly formatted before adding them to the dictionary.

get_additional_parameters()[source]

Retrieve the parameters for each stored shape.

Returns:

A dictionary where each key is the name of a shape, and the corresponding value is a dictionary containing the parameters for that shape. The structure of the parameter dictionary depends on the type of shape:

  • Disk:

    • type (str): The type of the shape (always 'disk').

    • radius (float): The radius of the disk.

    • material (str): The material of the disk's interior.

    • x (float): The x-coordinate of the disk's center.

    • y (float): The y-coordinate of the disk's center.

  • Rectangle:

    • type (str): The type of the shape (always 'rectangle').

    • material (str): The material of the rectangle's interior.

    • min_x (float): The x-coordinate of the rectangle's minimum bound.

    • min_y (float): The y-coordinate of the rectangle's minimum bound.

    • max_x (float): The x-coordinate of the rectangle's maximum bound.

    • max_y (float): The y-coordinate of the rectangle's maximum bound.

  • Polygon:

    • type (str): The type of the shape (always 'polygon').

    • material (str): The material of the polygon's interior.

    • points (list of tuple[float, float]): A list of (x, y) coordinates representing

      the vertices of the polygon.

Return type:

ShapeDataType

Notes

This method assumes that all shapes are stored with their respective parameters in a consistent format.

number_of_shapes()[source]

Return the total number of stored shapes.

Returns:

The total number of shapes stored in the shapes attribute.

Return type:

int

create_pedestrian_shapes(measurements)[source]

Create the shapes of a pedestrian based on the provided measures.

This method generates the shapes of a pedestrian agent by scaling initial disk centers and radii according to the provided measurements. To find the correct scalings, it uses an optimization algorithm to minimize the difference between the desired and actual chest depth and bideltoid breadth.

Parameters:

measurements (AgentMeasures) -- An object containing the measurements of the pedestrian agent.

Raises:

ValueError -- If the agent type is not 'pedestrian'.

Return type:

None

create_bike_shapes(measurements)[source]

Create and scale 2D shapes for a bike and its rider based on provided measurements.

This method uses an optimization process to generate bike and rider shapes that best match the provided measurements. It scales initial shapes to minimize the difference between desired and actual dimensions.

Parameters:

measurements (AgentMeasures) -- An object containing the target measurements for various bike parts and rider dimensions.

Raises:

ValueError -- If the agent type is not 'bike'.

Return type:

None

get_geometric_shapes()[source]

Return the geometric shapes that constitute a pedestrian physical shape.

Returns:

A list of Polygon objects representing the individual shapes.

Return type:

list[Polygon]

get_geometric_shape()[source]

Return the geometric union of all shapes that constitute a pedestrian physical shape.

Returns:

The union of all stored shapes as a single Polygon object.

Return type:

Polygon

get_area()[source]

Compute the area of the agent 2D representation.

Returns:

The area of the agent 2D representation (cm²).

Return type:

float

get_chest_depth()[source]

Compute the chest depth (anterior-posterior diameter) of a pedestrian agent in centimeters.

The chest depth is defined as twice the radius of 'disk2', converted from meters to centimeters.

Returns:

The chest depth of the agent in centimeters.

Return type:

float

Raises:

ValueError -- If the agent is not a pedestrian or required parameters are missing.

get_bideltoid_breadth()[source]

Compute the bideltoid breadth (shoulder width) of a pedestrian agent in centimeters.

Returns:

The bideltoid breadth of the agent in centimeters.

Return type:

float

Raises:

ValueError -- If the agent is not a pedestrian or required parameters are missing.

shapes3D

Class to store body shapes dynamically based on agent type.

class configuration.models.shapes3D.Shapes3D(agent_type, shapes=<factory>)[source]

Bases: object

Store and manage 3D body shapes for different agent types.

Parameters:
  • agent_type (AgentTypes)

  • shapes (dict[str, dict[str, Literal['disk', 'rectangle', 'polygon'] | ~typing.Literal['concrete', 'human_naked', 'human_clothes'] | float]] | dict[str, dict[str, ~typing.Literal['disk', 'rectangle', 'polygon'] | ~typing.Literal['concrete', 'human_naked', 'human_clothes'] | float | ~shapely.geometry.polygon.Polygon | ~shapely.geometry.multipolygon.MultiPolygon]])

agent_type: AgentTypes
shapes: dict[str, dict[str, Union[Literal['disk', 'rectangle', 'polygon'], Literal['concrete', 'human_naked', 'human_clothes'], float]]] | dict[str, dict[str, Union[Literal['disk', 'rectangle', 'polygon'], Literal['concrete', 'human_naked', 'human_clothes'], float, Polygon, MultiPolygon]]]
create_pedestrian3D(measurements)[source]

Create a 3D representation of a pedestrian based on provided measurements.

Parameters:

measurements (AgentMeasures) -- An object containing the target measurements of the pedestrian, including sex, bideltoid breadth, chest depth, and height.

Raises:

ValueError -- If the provided sex in "measurements" is not "male" or "female".

Return type:

None

Notes

  • The method uses an initial pedestrian representation based on the provided sex.

  • Scaling factors are calculated for each dimension (x, y, z) based on the ratio of target measurements to initial measurements.

get_height()[source]

Compute the height of the agent in meters.

Returns:

The height of the agent in meters.

Return type:

float

get_reference_multipolygon()[source]

Get the reference multipolygon of the agent i.e. the one at torso height.

Returns:

The reference multipolygon of the agent.

Return type:

MultiPolygon

get_bideltoid_breadth()[source]

Compute the bideltoid breadth of the agent (that has an orientation of 90°) in cm.

Returns:

The bideltoid breadth of the agent in cm.

Return type:

float

get_chest_depth()[source]

Compute the chest depth of the agent (that has an orientation of 90°) in cm.

Returns:

The chest depth of the agent in cm.

Return type:

float