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

New transform components: Translation3D & TransformMat3x3 #6866

Merged
merged 27 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d88e1d5
new Translation3D & TransformMat3x3 components
Wumpf Jul 9, 2024
0375c20
add new translation & mat3x3 to transform3d archetype
Wumpf Jul 9, 2024
ca34b5b
Remote `transform` argument from Python's `Transform3D`, make unit te…
Wumpf Jul 10, 2024
444828d
start changelog & migration guide on transforms
Wumpf Jul 10, 2024
7007109
Transform context takes new TransformMat3x3 and Translation into account
Wumpf Jul 10, 2024
8f0460d
Adjust C++ constructors to use new translation & mat3x3 types, overha…
Wumpf Jul 10, 2024
b7ac362
fix C++ typos
Wumpf Jul 11, 2024
8015515
fix transform3d roundtrip tests
Wumpf Jul 11, 2024
9b87634
Remove `TranslationAndMat3x3` datatype/enum variant
Wumpf Jul 11, 2024
9816281
new component ui for the new transform and matrix components
Wumpf Jul 11, 2024
40a9622
remove Transform3D::IDENTITY from c++ and Rust as it stops making sen…
Wumpf Jul 11, 2024
7100140
add test for snippets included in transform_mat3x3
Wumpf Jul 11, 2024
146808b
fix missing unreleased attributes
Wumpf Jul 11, 2024
146ee98
fix missing IDENTITY removal
Wumpf Jul 11, 2024
105375c
fix gcc issues
Wumpf Jul 11, 2024
11fe2d1
more gcc fixing
Wumpf Jul 11, 2024
35bae82
fix C++ doc strings
Wumpf Jul 11, 2024
9d311ea
fix broken python import
Wumpf Jul 11, 2024
6a1aef2
Merge branch 'main' into andreas/translation-and-transformmat3-compon…
Wumpf Jul 15, 2024
21ff988
Merge remote-tracking branch 'origin/main' into andreas/translation-a…
Wumpf Jul 15, 2024
ab8d847
rust warning fixes following merge
Wumpf Jul 15, 2024
2dd00d9
Fix python examples
Wumpf Jul 15, 2024
681b386
Fix python lints in transform test
Wumpf Jul 15, 2024
bc4490b
py-fmt
Wumpf Jul 15, 2024
8b7d2a1
Merge remote-tracking branch 'origin/main' into andreas/translation-a…
Wumpf Jul 15, 2024
f5418ee
remove debug prints
Wumpf Jul 15, 2024
fe140e2
fix rust transform3d test
Wumpf Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# ⚠️ Breaking changes
* `mesh_material: Material` has been renamed to `albedo_factor: AlbedoFactor` [#6841](https://github.com/rerun-io/rerun/pull/6841)
* 3D transform APIs: Previously, the transform component was represented as one of several variants (an Arrow union, `enum` in Rust) depending on how the transform was expressed. Instead, there are now several components for translation/scale/rotation/matrices that can live side-by-side in the 3D transform archetype.
* Python: `NV12/YUY2` are now logged with the new `ImageChromaDownsampled`
* `ImageEncoded`:s `format` parameter has been replaced with `media_type` (MIME)

Expand Down
23 changes: 20 additions & 3 deletions crates/store/re_types/definitions/rerun/archetypes/transform3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@ namespace rerun.archetypes;

/// A transform between two 3D spaces, i.e. a pose.
///
/// All components are applied in the order they are listed here.
/// E.g. if both a 4x4 matrix with a translation and a translation vector are present,
/// the matrix is applied first, then the translation vector on top.
Comment on lines +12 to +13
Copy link
Member

Choose a reason for hiding this comment

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

We are more and more establishing an alternative pattern of elsewhere of "if X is set, then Y and Z are ignored, with a warning". I still wonder if this might be the better thing to do with mat4x4 and mat3x3+transform.

Copy link
Member Author

Choose a reason for hiding this comment

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

not a bad point, but the exclusion sets are arguably more complicated than including everything 🤔

Copy link
Member

Choose a reason for hiding this comment

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

exclusion sets are arguably more complicated than including everything

I agree with this. The new design is conceptually very simple: we have a bunch of different transform components, and we have a well-defined order in which they are applied.

///
/// Each transform component can be listed multiple times, but transform tree propagation is only possible
/// if there's only one instance for each transform component.
/// TODO(#6831): write more about the exact interaction with the to be written `OutOfTreeTransform` component.
///
/// \example archetypes/transform3d_simple title="Variety of 3D transforms" image="https://static.rerun.io/transform3d_simple/141368b07360ce3fcb1553079258ae3f42bdb9ac/1200w.png"
/// \example archetypes/transform3d_hierarchy title="Transform hierarchy" image="https://static.rerun.io/transform_hierarchy/cb7be7a5a31fcb2efc02ba38e434849248f87554/1200w.png"
// TODO(#6831): provide example with out of tree transform.
table Transform3D (
"attr.rust.derive": "PartialEq",
"attr.rust.derive": "Default, PartialEq",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection"
) {
/// The transform
transform: rerun.components.Transform3D ("attr.rerun.component_required", order: 1000);
// TODO(#6831): remove.
transform: rerun.components.Transform3D ("attr.rerun.component_optional", order: 1000);

/// 3x3 transformation matrices.
mat3x3: [rerun.components.TransformMat3x3] ("attr.rerun.component_optional", nullable, order: 1100);

/// Translation vectors.
translation: [rerun.components.Translation3D] ("attr.rerun.component_optional", nullable, order: 1200);

// --- Optional ---
// --- visual representation

/// Visual length of the 3 axes.
///
/// The length is interpreted in the local coordinate system of the transform.
/// If the transform is scaled, the axes will be scaled accordingly.
// TODO(#6831): Should be an array as well.
axis_length: rerun.components.AxisLength ("attr.rerun.component_optional", nullable, order: 2000);
}
2 changes: 2 additions & 0 deletions crates/store/re_types/definitions/rerun/components.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ include "./components/tensor_dimension_selection.fbs";
include "./components/texcoord2d.fbs";
include "./components/text_log_level.fbs";
include "./components/text.fbs";
include "./components/transform_mat3x3.fbs";
include "./components/transform3d.fbs";
include "./components/translation3d.fbs";
include "./components/triangle_indices.fbs";
include "./components/vector2d.fbs";
include "./components/vector3d.fbs";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace rerun.components;

/// A 3x3 transformation matrix Matrix.
///
/// 3x3 matrixes are able to represent any affine transformation in 3D space,
/// i.e. rotation, scaling, shearing, reflection etc.
///
/// Matrices in Rerun are stored as flat list of coefficients in column-major order:
/// ```text
/// column 0 column 1 column 2
/// -------------------------------------------------
/// row 0 | flat_columns[0] flat_columns[3] flat_columns[6]
/// row 1 | flat_columns[1] flat_columns[4] flat_columns[7]
/// row 2 | flat_columns[2] flat_columns[5] flat_columns[8]
/// ```
///
/// \py However, construction is done from a list of rows, which follows NumPy's convention:
/// \py ```python
/// \py np.testing.assert_array_equal(
/// \py rr.components.TransformMat3x3([1, 2, 3, 4, 5, 6, 7, 8, 9]).flat_columns, np.array([1, 4, 7, 2, 5, 8, 3, 6, 9], dtype=np.float32)
/// \py )
/// \py np.testing.assert_array_equal(
/// \py rr.components.TransformMat3x3([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).flat_columns,
/// \py np.array([1, 4, 7, 2, 5, 8, 3, 6, 9], dtype=np.float32),
/// \py )
/// \py ```
/// \py If you want to construct a matrix from a list of columns instead, use the named `columns` parameter:
/// \py ```python
/// \py np.testing.assert_array_equal(
/// \py rr.components.TransformMat3x3(columns=[1, 2, 3, 4, 5, 6, 7, 8, 9]).flat_columns,
/// \py np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.float32),
/// \py )
/// \py np.testing.assert_array_equal(
/// \py rr.components.TransformMat3x3(columns=[[1, 2, 3], [4, 5, 6], [7, 8, 9]]).flat_columns,
/// \py np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.float32),
/// \py )
/// \py ```
struct TransformMat3x3 (
"attr.docs.unreleased",
"attr.rust.derive": "Default, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
matrix: rerun.datatypes.Mat3x3 (order: 100);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace rerun.components;

/// A translation vector in 3D space.
struct Translation3D (
"attr.docs.unreleased",
"attr.rust.derive": "Default, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
vector: rerun.datatypes.Vec3D (order: 100);
}
1 change: 0 additions & 1 deletion crates/store/re_types/definitions/rerun/datatypes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ include "./datatypes/tensor_dimension_selection.fbs";
include "./datatypes/tensor_dimension.fbs";
include "./datatypes/time_int.fbs";
include "./datatypes/transform3d.fbs";
include "./datatypes/translation_and_mat3x3.fbs";
include "./datatypes/translation_rotation_scale3d.fbs";
include "./datatypes/uint32.fbs";
include "./datatypes/uint64.fbs";
Expand Down
3 changes: 2 additions & 1 deletion crates/store/re_types/definitions/rerun/datatypes/mat3x3.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace rerun.datatypes;
struct Mat3x3 (
"attr.arrow.transparent",
"attr.python.aliases": "npt.ArrayLike",
"attr.rust.derive": "Copy, PartialEq, PartialOrd",
"attr.rust.derive": "Copy, PartialEq, PartialOrd, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct"
) {
/// Flat list of matrix coefficients in column-major order.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ namespace rerun.datatypes;
union Transform3D (
"attr.rust.derive": "Copy, PartialEq"
) {
/// Translation plus a 3x3 matrix for scale, rotation, skew, etc.
TranslationAndMat3x3: TranslationAndMat3x3,

/// Translation, rotation and scale, decomposed.
TranslationRotationScale: TranslationRotationScale3D,

Expand Down

This file was deleted.

103 changes: 93 additions & 10 deletions crates/store/re_types/src/archetypes/transform3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading