Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 15, 2025
1 parent 81f06c8 commit 4a5dfbf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 51 deletions.
26 changes: 9 additions & 17 deletions docs/snippets/all/archetypes/transform3d_partial_updates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,20 @@ float truncated_radians(float deg) {
}

int main() {
const auto rec = rerun::RecordingStream("rerun_example_transform3d_axes");
const auto rec = rerun::RecordingStream("rerun_example_transform3d_partial_updates");
rec.spawn().exit_on_failure();

auto step = 0;

rec.set_time_sequence("step", step);
// Set up a 3D box.
rec.log(
"box",
rerun::Boxes3D::from_half_sizes({{4.f, 2.f, 1.0f}}).with_fill_mode(rerun::FillMode::Solid),
rerun::Transform3D().with_axis_length(10.0)
);

// Update only the rotation of the box.
for (int deg = 0; deg <= 45; deg++) {
step++;
rec.set_time_sequence("step", step);

auto rad = truncated_radians(deg * 4);
// TODO(cmc): update_fields
// TODO(#8583): update_fields
rec.log(
"box",
rerun::Transform3D().with_rotation_axis_angle(
Expand All @@ -34,21 +30,18 @@ int main() {
);
}

// Update only the position of the box.
for (int t = 0; t <= 45; t++) {
step++;
rec.set_time_sequence("step", step);
rec.log(
"box",
rerun::Transform3D().with_translation({0.0f, 0.0f, static_cast<float>(t) / 10.0f})
);
}

// Update only the rotation of the box.
for (int deg = 0; deg <= 45; deg++) {
step++;
rec.set_time_sequence("step", step);

auto rad = truncated_radians((deg + 45) * 4);
// TODO(cmc): update_fields
// TODO(#8583): update_fields
rec.log(
"box",
rerun::Transform3D().with_rotation_axis_angle(
Expand All @@ -57,8 +50,7 @@ int main() {
);
}

step++;
rec.set_time_sequence("step", step);
// TODO(cmc): clear_fields
// Clear all of the box's attributes, and reset its axis length.
// TODO(#8583): clear_fields
rec.log("box", rerun::Transform3D().with_axis_length(15.0));
}
23 changes: 5 additions & 18 deletions docs/snippets/all/archetypes/transform3d_partial_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ def truncated_radians(deg: float) -> float:
return float(int(math.radians(deg) * 1000.0)) / 1000.0


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

step = 0
rr.set_time_sequence("step", step)
rr.init("rerun_example_transform3d_partial_updates", spawn=True)

rr.log(
"box",
Expand All @@ -21,11 +18,8 @@ def truncated_radians(deg: float) -> float:
)

for deg in range(46):
step += 1
rr.set_time_sequence("step", step)

rad = truncated_radians(deg * 4)
# TODO(cmc): update_fields
# TODO(#8582): update_fields
rr.log(
"box",
rr.Transform3D(
Expand All @@ -35,20 +29,15 @@ def truncated_radians(deg: float) -> float:
)

for t in range(51):
step += 1
rr.set_time_sequence("step", step)
# TODO(cmc): update_fields
# TODO(#8582): update_fields
rr.log(
"box",
rr.Transform3D(translation=[0, 0, t / 10.0]),
)

for deg in range(46):
step += 1
rr.set_time_sequence("step", step)

rad = truncated_radians((deg + 45) * 4)
# TODO(cmc): update_fields
# TODO(#8582): update_fields
rr.log(
"box",
rr.Transform3D(
Expand All @@ -57,9 +46,7 @@ def truncated_radians(deg: float) -> float:
),
)

step += 1
rr.set_time_sequence("step", step)
# TODO(cmc): update_fields(clear=True)
# TODO(#8582): update_fields(clear=True)
rr.log(
"box",
rr.Transform3D(axis_length=15),
Expand Down
21 changes: 7 additions & 14 deletions docs/snippets/all/archetypes/transform3d_partial_updates.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
//! Log different transforms with visualized coordinates axes.
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_transform3d_axes").spawn()?;
let rec =
rerun::RecordingStreamBuilder::new("rerun_example_transform3d_partial_updates").spawn()?;

let mut step = 0;

rec.set_time_sequence("step", step);
// Set up a 3D box.
rec.log(
"box",
&[
Expand All @@ -15,10 +14,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
],
)?;

// Update only the rotation of the box.
for deg in 0..=45 {
step += 1;
rec.set_time_sequence("step", step);

let rad = truncated_radians((deg * 4) as f32);
rec.log(
"box",
Expand All @@ -29,19 +26,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
)?;
}

// Update only the position of the box.
for t in 0..=50 {
step += 1;
rec.set_time_sequence("step", step);
rec.log(
"box",
&rerun::Transform3D::update_fields().with_translation([0.0, 0.0, t as f32 / 10.0]),
)?;
}

// Update only the rotation of the box.
for deg in 0..=45 {
step += 1;
rec.set_time_sequence("step", step);

let rad = truncated_radians(((deg + 45) * 4) as f32);
rec.log(
"box",
Expand All @@ -52,8 +46,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
)?;
}

step += 1;
rec.set_time_sequence("step", step);
// Clear all of the box's attributes, and reset its axis length.
rec.log(
"box",
&rerun::Transform3D::clear_fields().with_axis_length(15.0),
Expand Down
4 changes: 2 additions & 2 deletions docs/snippets/snippets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ quick_start = [ # These examples don't have exactly the same implementation.
"py",
]
"archetypes/transform3d_partial_updates" = [
"cpp", # TODO(cmc): remove once C++ partial updates APIs have shipped
"py", # TODO(cmc): remove once Python partial updates APIs have shipped
"cpp", # TODO(#8583): remove once C++ partial updates APIs have shipped
"py", # TODO(#8582): remove once Python partial updates APIs have shipped
]
"archetypes/instance_poses3d_combined" = [ # TODO(#3235): Slight floating point differences in point grid.
"cpp",
Expand Down

0 comments on commit 4a5dfbf

Please sign in to comment.