> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# PointCloud

> A class to represent a point cloud

```python theme={null}
from grid_types import PointCloud
```

A class to represent a point cloud.

## Fields

<ResponseField name="points" type="np.ndarray">
  Array of points with shape (N, D) where N is the number of points and D is the dimensionality of each point (e.g., D=3 for x,y,z). Each row is a point, and each column is a dimension/feature.
</ResponseField>

<ResponseField name="fields" type="List[str]">
  List of field names for the point cloud data. The order of field names must correspond to the columns in the points array. If not provided, defaults to \['x', 'y'] for 2D points (N,2) or \['x', 'y', 'z'] for 3D points (N,3). For other dimensions, fields must be explicitly provided.
</ResponseField>

## Constructor

```python Signature theme={null}
PointCloud(points: np.ndarray, fields: Optional[List[str]] = None)
```

## Methods

### `from_dict()`

```python Signature theme={null}
from_dict(data: dict) -> PointCloud
```

Deserialize from dictionary

### `to_dict()`

```python Signature theme={null}
to_dict() -> dict
```

Serialize to dictionary for JSON transfer

## Example

```python theme={null}
import numpy as np
# 3D points with x, y, z
points_data_3d = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float32)
pc1 = PointCloud(points=points_data_3d)
print(pc1.points)
print(pc1.fields)
# 2D points with x, y
points_data_2d = np.array([[1, 2], [3, 4]], dtype=np.float32)
pc2 = PointCloud(points=points_data_2d)
print(pc2.fields)
# 3D points with custom fields (e.g., x, y, intensity)
points_data_custom = np.array([[10, 20, 100], [30, 40, 150]], dtype=np.float32)
pc3 = PointCloud(points=points_data_custom, fields=['x', 'y', 'intensity'])
print(pc3.fields)
# Points with x, y, z, r, g, b
points_rgb = np.array([[1,2,3, 255,0,0], [4,5,6, 0,255,0]], dtype=np.float32)
fields_rgb = ['x', 'y', 'z', 'r', 'g', 'b']
pc4 = PointCloud(points=points_rgb, fields=fields_rgb)
print(pc4.points.shape)
print(pc4.fields)
```


## Related topics

- [Sensors](/simulation/isaac/sensors.md)
- [GRID Cortex Client](/models/cortex.md)
- [ROS2 Communication](/simulation/isaac/comms.md)
- [The Intelligence Grid for Physical AI](/introduction.md)
- [Your first session](/get-started/first-session.md)
