Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flesh out archetype docs and simple code examples fo rmore types #2467

Merged
merged 14 commits into from
Jun 19, 2023
6 changes: 6 additions & 0 deletions docs/code-examples/arrow3d_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Log a single arrow."""
import rerun as rr

rr.init("arrow", spawn=True)

rr.log_arrow("simple", origin=[0, 0, 0], vector=[1, 0, 1], width_scale=0.05)
6 changes: 6 additions & 0 deletions docs/code-examples/box3d_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Log a single oriented bounding box."""
import rerun as rr

rr.init("box3d", spawn=True)

rr.log_obb("simple", half_size=[2.0, 2.0, 1.0])
12 changes: 12 additions & 0 deletions docs/code-examples/line_segments2d_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Log a simple set of line segments."""
import rerun as rr

rr.init("linesegments2d", spawn=True)

rr.log_line_segments(
"simple",
[[0, 0], [2, 1], [4, -1], [6, 0]],
)

# Log an extra rect to set the view bounds
rr.log_rect("bounds", [3, 0, 8, 6], rect_format=rr.RectFormat.XCYCWH)
18 changes: 18 additions & 0 deletions docs/code-examples/line_segments3d_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Log a simple set of line segments."""
import rerun as rr

rr.init("linesegments3d", spawn=True)

rr.log_line_segments(
"simple",
[
[0, 0, 0],
[0, 0, 1],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0],
[1, 1, 1],
[0, 1, 0],
[0, 1, 1],
],
)
12 changes: 12 additions & 0 deletions docs/code-examples/line_strip2d_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Log a simple line strip."""
import rerun as rr

rr.init("linestrip2d", spawn=True)

rr.log_line_strip(
"simple",
[[0, 0], [2, 1], [4, -1], [6, 0]],
)

# Log an extra rect to set the view bounds
rr.log_rect("bounds", [3, 0, 8, 6], rect_format=rr.RectFormat.XCYCWH)
18 changes: 18 additions & 0 deletions docs/code-examples/line_strip3d_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Log a simple line strip."""
import rerun as rr

rr.init("linestrip3d", spawn=True)

rr.log_line_strip(
"simple",
[
[0, 0, 0],
[0, 0, 1],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0],
[1, 1, 1],
[0, 1, 0],
[0, 1, 1],
],
)
24 changes: 24 additions & 0 deletions docs/code-examples/mesh_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Log a simple colored triangle."""
import rerun as rr

rr.init("mesh", spawn=True)

rr.log_mesh(
"triangle",
positions=[
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
],
indices=[0, 1, 2],
normals=[
[0.0, 0.0, 1.0],
[0.0, 0.0, 1.0],
[0.0, 0.0, 1.0],
],
vertex_colors=[
[255, 0, 0],
[0, 255, 0],
[0, 0, 255],
],
)
9 changes: 9 additions & 0 deletions docs/code-examples/rect2d_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Log a simple rectangle."""
import rerun as rr

rr.init("rect2d", spawn=True)

rr.log_rect("simple", [-1, -1, 2, 2], rect_format=rr.RectFormat.XYWH)

# Log an extra rect to set the view bounds
rr.log_rect("bounds", [0, 0, 4, 3], rect_format=rr.RectFormat.XCYCWH)
20 changes: 20 additions & 0 deletions docs/content/reference/data_types/arrow3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
title: Arrow3D
order: 1
---
`Arrow3D` represents a singular arrow in three-dimensional space. The `arrow3d` component is defined by an origin, and a
vector relative to that origin. The arrow tip will be drawn at the end of the vector, pointing away from the origin.
Additionally, arrows can be drawn with color, radius, and labels. The radius controls the thickness of the arrow.

Notes:
* In the python APIs `radius` is currently derived from `width_scale`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go ahead and merge without fixing this but we should really say what this relationship is @jleibs

* [Arrow APIs do not currently support batching](https://github.com/rerun-io/rerun/issues/2466)

## Components and APIs
Primary component: `arrow3d`

Expand All @@ -10,3 +18,15 @@ Secondary components: `colorrgba`, `radius`, `label`
Python APIs: [log_arrow](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_arrow)

Rust API: [Arrow3D](https://docs.rs/rerun/latest/rerun/components/struct.Arrow3D.html)

## Simple Example

code-example: arrow3d_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/b1ccd4e1fd2f1fba53ee81de89b02186dd8f76ad_arrow3d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/ef88127921ab6019465c866dfa562036d6d0325c_arrow3d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/1489a02534f9b0afedb6abb6ee222932cfdb2be5_arrow3d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/23342496350bd104617afdb4782cd95db21cab06_arrow3d_simple_1200w.png">
<img src="https://static.rerun.io/c8a8b1cbca40acdf02fb5bf264658ad66e07ca40_arrow3d_simple_full.png" alt="">
</picture>
20 changes: 20 additions & 0 deletions docs/content/reference/data_types/box3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
title: Box3D
order: 3
---
`Box3D` represents an oriented bounding box in three-dimensional space. The `box3d` component is defined by the
half-widths of the three box dimensions. By default the box will be centered at the origin and aligned with the axes.
The box can be positioned within it's local [space](../../concepts/spaces-and-transforms.md) by providing the `vec3d` position, or a `quaternion` orientation.

It is compatible with [`AnnotationContext`](../../concepts/annotation-context.md). `class_id` can be used to provide
colors and labels from the annotation context. See examples in the
[`AnnotationContext`](../../concepts/annotation-context.md) documentation.

## Components and APIs
Primary component: `box3d`,

Expand All @@ -10,3 +18,15 @@ Secondary components: `vec3d`, `quaternion`, `colorrgba`, `radius`, `label`, `cl
Python APIs: [log_obb](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_obb)

Rust API: [Box3D](https://docs.rs/rerun/latest/rerun/components/struct.Box3D.html)

## Simple Example

code-example: box3d_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/1342a41030eaddbe43439951076723298218e922_box3d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/05ed697e151dcb53a8a17dfac1bec2023e096083_box3d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/f47370115cb45b1085f87824d00ab38f95960732_box3d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/d8df3a0a665b4f5b034883684d73d767fcde6eef_box3d_simple_1200w.png">
<img src="https://static.rerun.io/d6a3f38d2e3360fbacac52bb43e44762635be9c8_box3d_simple_full.png" alt="">
</picture>
36 changes: 36 additions & 0 deletions docs/content/reference/data_types/linestrip2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
title: Linestrip2D
order: 4
---
`Linestrip2D` represents a series of connected line segments in two-dimensional space. The `linestrip2d` component is
defined by a list of 2d points, which are connected sequentially. Additionally, linestrips can be drawn with color and
radius. The radius controls the thickness of the line segments.

There are currently two python APIs that both use the same underlying `Linestrip2D` archetype.
* [log_line_strip](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_line_strip) outputs a single linestrip from the provided points.
* [log_line_segments](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_line_segments) outputs a batch of linestrips each made up of a single line.

`draw_order` can be used to control how the `Linestrip2D` entities are drawn relative to other objects within the scene.
Higher values are drawn on top of lower values.

Notes:
* There is not currently a python API for logging a batch of linestrips.
* In the python APIs `radius` is currently derived from `stroke_width`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jleibs I'll merge this now but we should explain how it's derived in the future


## Components and APIs
Primary component: `linestrip2d`
Expand All @@ -11,3 +25,25 @@ Secondary components: `colorrgba`, `radius`, `draw_order`
Python APIs: [log_line_strip](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_line_strip), [log_line_segments](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_line_segments)

Rust API: [LineStrip2D](https://docs.rs/rerun/latest/rerun/components/struct.LineStrip2D.html)

## Simple Examples

code-example: line_strip2d_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/53513e074a1d01388ac6ac9664ff9d452813870d_line_strip2d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/669c61837dc3464090945f6ade96f0205006e202_line_strip2d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/81cf822ebaa5faff8d129f2705872621835acc95_line_strip2d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/e549c9d69a19754803c648b665be5afbff9b7cad_line_strip2d_simple_1200w.png">
<img style="width: 75%;" src="https://static.rerun.io/c4e6ce937544e66b497450fd64ac3ac2f244f0e1_line_strip2d_simple_full.png" alt="">
</picture>

code-example: line_segments2d_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/3c3604e215d461340ffc8dd53223406d732b44ac_line_segment2d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/7b0a8e60b0d6f005618c0ac09113ce84a08fb778_line_segment2d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/3ee262f61cb74aaffd7fd0b506754ee11cab3c12_line_segment2d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/196e0f2fe2222526e9eba87fa39440ada08e273d_line_segment2d_simple_1200w.png">
<img style="width: 75%;" src="https://static.rerun.io/53df596662dd9ffaaea5d09d091ef95220346c83_line_segment2d_simple_full.png" alt="">
</picture>
34 changes: 34 additions & 0 deletions docs/content/reference/data_types/linestrip3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
title: Linestrip3D
order: 5
---
`Linestrip3D` represents a series of connected line segments in three-dimensional space. The `linestrip3d` component is
defined by a list of 3d points, which are connected sequentially. Additionally, linestrips can be drawn with color and
radius. The radius controls the thickness of the line segments.

There are currently two python APIs that both use the same underlying `Linestrip3D` archetype.
* [log_line_strip](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_line_strip) outputs a single linestrip from the provided points.
* [log_line_segments](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_line_segments) outputs a batch of linestrips each made up of a single line.

Notes:
* There is not currently a python API for logging a batch of linestrips.
* In the python APIs `radius` is currently derived from `stroke_width`

## Components and APIs
Primary component: `linestrip3d`

Expand All @@ -10,3 +22,25 @@ Secondary components: `colorrgba`, `radius`
Python APIs: [log_line_strip](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_line_strip), [log_line_segments](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_line_segments)

Rust API: [LineStrip3D](https://docs.rs/rerun/latest/rerun/components/struct.LineStrip3D.html)

## Simple Examples

code-example: line_strip3d_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/fd5b1ed1c42315ff5b1c2d1245ad655e4564d5f1_line_strip3d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/097f3c5086790e36e0b8a7f34a44e9eeac5227d2_line_strip3d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/ec76e1078e443fd4e71b751f84fe19f5b014272b_line_strip3d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/66b12e078e3a08d7a61f3f91f7ad847cbb4933dd_line_strip3d_simple_1200w.png">
<img style="width: 75%;" src="https://static.rerun.io/13036c0e71f78d3cec37d5724f97b47c4cf3c429_line_strip3d_simple_full.png" alt="">
</picture>

code-example: line_segments3d_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/83b63186b05794227010dc1d083161add5ec7f0b_line_segment3d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/cb005f7b4e629e9b88a91835edfa066101f94f65_line_segment3d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/140ddb2aa68b3e1a623cd1997df808e255a2136c_line_segment3d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/aeed681be95d6c974446f89a6fa26b7d3077adce_line_segment3d_simple_1200w.png">
<img style="width: 75%;" src="https://static.rerun.io/aa800b2a6e6a7b8e32e762b42861bae36f5014bb_line_segment3d_simple_full.png" alt="">
</picture>
15 changes: 15 additions & 0 deletions docs/content/reference/data_types/mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
title: Mesh
order: 6
---
`Mesh` represents a 3D mesh. It is defined by specifying its vertex positions, and optionally indices, normals,
albedo factor, and vertex-colors. `Mesh` entities will be drawn as part of the 3D Spatial SpaceView.

## Components and APIs
Primary component: `mesh3d`

Expand All @@ -10,3 +13,15 @@ Secondary components: `colorrgba`
Python APIs: [log_mesh](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_mesh), [log_meshes](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_meshes), [log_mesh_file](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_mesh_file)

Rust API: [Mesh3D](https://docs.rs/rerun/latest/rerun/components/enum.Mesh3D.html)

## Simple Examples

code-example: mesh_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/50a0201e08bfc843d8a544db2e0ed5ccb65a1fde_mesh_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/0660d59216f467be310507c6f1d93880d9cddd10_mesh_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/0113f054b20d365c14922cfdad2140a2f7e29045_mesh_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/cbb51e91b7aa65fa4774b32031e93d4718b8da77_mesh_simple_1200w.png">
<img src="https://static.rerun.io/c13648317223585abe28df8bcaa8c933587558b6_mesh_simple_full.png" alt="">
</picture>
27 changes: 25 additions & 2 deletions docs/content/reference/data_types/point3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
title: Point3D
order: 8
---
`Point3D` represents a singular point in three-dimensional space with optional color, radii, and label. `Point3D` entities will be drawn as part of the 3D Spatial SpaceView.

It is compatible with [`AnnotationContext`](../../concepts/annotation-context.md). `class_id` can be used to provide
colors and labels from the annotation context, and `keypoint_id` can be used to make connected edges between points. See
examples in the `AnnotationContext` documentation.

## Components and APIs
Primary component: `point3d`

Expand All @@ -11,8 +17,25 @@ Python APIs: [log_point](https://ref.rerun.io/docs/python/latest/common/spatial_

Rust API: [Point3D](https://docs.rs/rerun/latest/rerun/components/struct.Point3D.html)

### Simple Example
## Simple Example
code-example: point3d_simple

### Complex Example
<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/03df4bf186a8a348443183f20bbcf81aa6466e85_point3d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/56461e6835eebdbe1f9f3cc12025ccc017dd85ee_point3d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/eea941cf7d29cd7a41bc8aaeebec4a358b623081_point3d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/94689c15c391b9ab7e8fbfefd695bf46a63f45a5_point3d_simple_1200w.png">
<img src="https://static.rerun.io/32fb3e9b65bea8bd7ffff95ad839f2f8a157a933_point3d_simple_full.png" alt="">
</picture>

## Full Example

code-example: point3d_random

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/c86336081c2a3209a831abfd8d873c970839a212_point3d_random_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/3099783f049ce15d512aa701c16286fb0a8ef6af_point3d_random_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/9f69a53273ac85e7c7e8841fca36301356a6293a_point3d_random_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/609d4a8d4a545f1bdcfe432c9403a6deac00d4a9_point3d_random_1200w.png">
<img src="https://static.rerun.io/7e94e1806d2c381943748abbb3bedb68d564de24_point3d_random_full.png" alt="">
</picture>
28 changes: 28 additions & 0 deletions docs/content/reference/data_types/rect2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
title: Rect2D
order: 2
---
`Rect2D` represents a rectangle in two-dimensional space. The `rect2d` component is always defined by a 4-element list,
with one of several representations:
* XYWH = `[x, y, w, h]`, with x,y = left,top.
* YXHW = `[y, x, h, w]`, with x,y = left,top.
* XYXY = `[x0, y0, x1, y1]`, with x0,y0 = left,top and x1,y1 = right,bottom
* YXYX = `[y0, x0, y1, x1]`, with x0,y0 = left,top and x1,y1 = right,bottom
* XCYCWH = `[x_center, y_center, width, height]`
* XCYCW2H2 = `[x_center, y_center, width/2, height/2]`


It is compatible with [`AnnotationContext`](../../concepts/annotation-context.md). `class_id` can be used to provide
colors and labels from the annotation context. See examples in the
[`AnnotationContext`](../../concepts/annotation-context.md) documentation.

`draw_order` can be used to control how the `Rect2D` entities are drawn relative to other objects within the scene. Higher values are drawn on top of lower values.

## Components and APIs
Primary component: `rect2d`,

Expand All @@ -10,3 +26,15 @@ Secondary components: `colorrgba`, `radius`, `label`, `classid`, `draw_order`
Python APIs: [log_rect](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_rect), [log_rects](https://ref.rerun.io/docs/python/latest/common/spatial_primitives/#rerun.log_rects)

Rust API: [Rect2D](https://docs.rs/rerun/latest/rerun/components/enum.Rect2D.html)

## Simple Example

code-example: rect2d_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/2e655eb2d5381bbf0328b65d80fa5be29c052bdb_rect2d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/5f7135b0ea74ae93380fe74428abb2f2da638a7a_rect2d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/842be4a57ac5fd89e07e98cc31243a475a3f17c8_rect2d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/c61c9e843a7d1c92f15001d6cdc8cba17c6b13a8_rect2d_simple_1200w.png">
<img style="width: 75%;" src="https://static.rerun.io/8c06df0ca7e336f76a9ae933017e00493516d13b_rect2d_simple_full.png" alt="">
</picture>
9 changes: 8 additions & 1 deletion docs/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@
"xyzw",
"jleibs",
"Trimesh",
"srcset"
"srcset",
"XYWH",
"YXHW",
"XYXY",
"YXYX",
"XCYCWH",
"XCYCW2H2"
],
"words": [
"nyud",
Expand All @@ -78,6 +84,7 @@
"keypoints",
"lerp",
"linestrip",
"linestrips",
"linspace",
"loggable",
"meshgrid",
Expand Down