Implementation:CARLA simulator Carla Geometry API Spec
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Geometry, API Specification |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
YML specification file that defines geometry and math helper classes in the CARLA Python API, including Vector2D, Vector3D, Location, Rotation, Transform, and BoundingBox.
Description
This YML file specifies the core geometry classes for spatial operations in the CARLA simulator. Vector2D provides 2D vector operations with x and y components, including length(), squared_length(), and make_unit_vector() methods plus arithmetic operators. Vector3D extends this to 3D with an additional z component and cross/dot product support. Location represents 3D coordinates with a distance() method. Rotation stores pitch, yaw, and roll in degrees. Transform combines Location and Rotation, providing transform() for applying the transform to points. BoundingBox defines axis-aligned bounding volumes with location, extent, and rotation.
Usage
Use these geometry classes for spatial calculations, coordinate transformations, collision detection, and positioning actors within the CARLA simulation world.
Code Reference
Source Location
- Repository: CARLA
- File: PythonAPI/docs/geom.yml
Signature
- module_name: carla
classes:
- class_name: Vector2D
instance_variables:
- var_name: x # type: float
- var_name: y # type: float
methods:
- def_name: length # return: float
- def_name: squared_length # return: float
- def_name: make_unit_vector # return: carla.Vector3D
- def_name: __add__
- def_name: __sub__
- def_name: __mul__
- def_name: __truediv__
- class_name: Vector3D
instance_variables:
- var_name: x # type: float
- var_name: y # type: float
- var_name: z # type: float
methods:
- def_name: __init__(x=0.0, y=0.0, z=0.0)
- def_name: length
- def_name: squared_length
- def_name: cross
- def_name: dot
Import
import carla
v = carla.Vector3D(1.0, 2.0, 3.0)
loc = carla.Location(x=10.0, y=20.0, z=0.5)
rot = carla.Rotation(pitch=0, yaw=90, roll=0)
transform = carla.Transform(loc, rot)
I/O Contract
| Class | Properties | Description |
|---|---|---|
| Vector2D | x, y | 2D vector for planar operations |
| Vector3D | x, y, z | 3D vector for spatial operations |
| Location | x, y, z | 3D point in world coordinates (meters) |
| Rotation | pitch, yaw, roll | Euler angles in degrees |
| Transform | location, rotation | Combined position and orientation |
| BoundingBox | location, extent, rotation | Axis-aligned bounding volume |
Usage Examples
import carla
# Vector operations
v1 = carla.Vector3D(1.0, 0.0, 0.0)
v2 = carla.Vector3D(0.0, 1.0, 0.0)
cross = v1.cross(v2)
length = v1.length()
# Transform operations
location = carla.Location(x=100.0, y=200.0, z=0.0)
rotation = carla.Rotation(pitch=0, yaw=90, roll=0)
transform = carla.Transform(location, rotation)
# Apply transform to a point
point = carla.Location(x=1.0, y=0.0, z=0.0)
world_point = transform.transform(point)
# Distance calculation
dist = location.distance(carla.Location(x=0, y=0, z=0))