Estimate a wheel rotation axis with an OBB#
This example shows how to use the draft context to fit an oriented bounding box (OBB) to a set of wheel surfaces, then derive the rotation axis and radius of the wheel from that box. These values can be used to configure a rotating wall boundary condition or a rotating reference frame without measuring the geometry by hand.
import flow360 as fl
project = fl.Project.from_cloud("PROJECT_ID_HERE")
geometry = project.geometry
with fl.create_draft(
new_run_from=geometry,
face_grouping="face_grouping_tag",
) as draft:
# Select the surfaces that make up the wheel.
wheel_surfaces = draft.surfaces["wheel_*"]
# Fit the oriented bounding box to those surfaces. The result holds the
# box geometry only: center, principal axes and half-extents.
obb = fl.measure.oriented_bounding_box(
draft,
surfaces=wheel_surfaces,
)
# Derive the rotation axis and radius from the box. Pass a known
# direction with rotation_axis_hint (or an explicit axis_index). When
# neither is given the axis is inferred from the most circular
# cross-section and a warning is emitted.
rotation = obb.get_rotation_axis_and_radius(rotation_axis_hint=[0, 1, 0])
print("center:", obb.center)
print("rotation axis:", rotation.axis_of_rotation)
print("averaged radius:", rotation.averaged_radius)
# Printing the result also shows how the radius was averaged.
print(rotation)
Notes#
fl.measure.oriented_bounding_boxis available only for drafts created from a Geometry asset. Drafts created from a surface mesh or volume mesh do not carry the tessellation data required to fit the box.surfacesaccepts a single surface, a list of surfaces, a surface selector, or a surface view (e.g.draft.surfaces[...]). Unsupported or non-surface entities raiseFlow360ValueError.oriented_bounding_boxreturns anOBBResultthat describes the box geometry only:center,axes(the principal axes as row vectors) andextents(the half-extents along each axis). When the project has a length unit,centerandextentscarry that unit.The rotation axis and radius are obtained separately via
OBBResult.get_rotation_axis_and_radius(), which returns aRotationAxisAndRadiuswithaxis_of_rotation(a unit vector) andaveraged_radius. The averaged radius is the mean of the two box half-extents perpendicular to the rotation axis, and inherits the project length unit from thoseextents. Printing theRotationAxisAndRadiusshows the values that were averaged.Select the rotation axis with either
rotation_axis_hint(the principal axis most aligned with the given direction is used) oraxis_index(0, 1 or 2). Passing both, an out-of-range index, or a zero hint raisesFlow360ValueError. If neither is given, the axis is inferred from the most circular cross-section and a warning is emitted, since this is an inference rather than a known geometric property.draft.compute_obb(...)remains as a deprecated compatibility wrapper and is scheduled for removal in release 26.
Example use cases#
Automatic rotation setup for wheels and other cylindrical components
Estimating component size and orientation directly from geometry
See also
Draft API Reference (details of
OBBResultand the deprecated wrapper)Asset Drafts user guide (conceptual overview)