LIBRARY
PlanarMechanics.FrameVisualizer2D
Visualizes a 2D frame as three colored axis cylinders (red=x, green=y, blue=z).
Attach to any Frame2D connector to display its coordinate axes. The z-axis is not part of the 2D frame but is drawn perpendicular to the plane for visual reference.
This component extends from MultibodyComponents.Renderable
Usage
MultibodyComponents.PlanarMechanics.FrameVisualizer2D(render=true, color=[0.5, 0.5, 0.5, 1.0], specular_coefficient=0.7, axis_length=0.1, axis_radius=axis_length / 20, z_position=0)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
render | – | true | |
color | – | [0.5, 0.5, 0.5, 1] | |
specular_coefficient | – | 0.7 | |
axis_length | Length of the axis arrows | – | 0.1 |
axis_radius | Radius of the axis cylinders | – | axis_length / 20 |
z_position | z-position in animations | – | 0 |
Connectors
frame_a- Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.
All variables are resolved in the planar world frame. (Frame2D)
Variables
| Name | Description | Units |
|---|---|---|
phi | Frame angle | rad |
Behavior
Dict{MIME{Symbol("text/plain")}, String} with 1 entry: MIME type text/plain => "Error displaying result"
Source
dyad
"""
Visualizes a 2D frame as three colored axis cylinders (red=x, green=y, blue=z).
Attach to any Frame2D connector to display its coordinate axes. The z-axis
is not part of the 2D frame but is drawn perpendicular to the plane for
visual reference.
"""
component FrameVisualizer2D
extends MultibodyComponents.Renderable
frame_a = Frame2D() {}
"X-axis shape (red)"
x_shape = MultibodyComponents.CylinderShape(color = [1, 0, 0, 1])
"Y-axis shape (green)"
y_shape = MultibodyComponents.CylinderShape(color = [0, 1, 0, 1])
"Z-axis shape (blue)"
z_shape = MultibodyComponents.CylinderShape(color = [0, 0, 1, 1])
"Length of the axis arrows"
parameter axis_length::Real = 0.1
"Radius of the axis cylinders"
parameter axis_radius::Real = axis_length / 20
"z-position in animations"
parameter z_position::Real = 0
"Frame angle"
variable phi::Angle
relations
phi = frame_a.phi
# Zero forces/torques (sensor-like, does not affect dynamics)
#frame_a.fx = 0
#frame_a.fy = 0
#frame_a.tau = 0
# X-axis: along local x direction, rotated by frame angle
x_shape.r = [frame_a.x, frame_a.y, z_position]
x_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
x_shape.r_shape = [0, 0, 0]
x_shape.length_direction = [1, 0, 0]
x_shape.width_direction = [0, 0, 1]
x_shape.length = axis_length
x_shape.width = 2 * axis_radius
x_shape.height = 2 * axis_radius
# Y-axis: along local y direction, same rotation
y_shape.r = [frame_a.x, frame_a.y, z_position]
y_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
y_shape.r_shape = [0, 0, 0]
y_shape.length_direction = [0, 1, 0]
y_shape.width_direction = [0, 0, 1]
y_shape.length = axis_length
y_shape.width = 2 * axis_radius
y_shape.height = 2 * axis_radius
# Z-axis: perpendicular to the plane, same rotation
z_shape.r = [frame_a.x, frame_a.y, z_position]
z_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
z_shape.r_shape = [0, 0, 0]
z_shape.length_direction = [0, 0, 1]
z_shape.width_direction = [1, 0, 0]
z_shape.length = axis_length
z_shape.width = 2 * axis_radius
z_shape.height = 2 * axis_radius
endFlattened Source
dyad
"""
Visualizes a 2D frame as three colored axis cylinders (red=x, green=y, blue=z).
Attach to any Frame2D connector to display its coordinate axes. The z-axis
is not part of the 2D frame but is drawn perpendicular to the plane for
visual reference.
"""
component FrameVisualizer2D
parameter render::Boolean = true
parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
parameter specular_coefficient::Real = 0.7
frame_a = Frame2D() {}
"X-axis shape (red)"
x_shape = MultibodyComponents.CylinderShape(color = [1, 0, 0, 1])
"Y-axis shape (green)"
y_shape = MultibodyComponents.CylinderShape(color = [0, 1, 0, 1])
"Z-axis shape (blue)"
z_shape = MultibodyComponents.CylinderShape(color = [0, 0, 1, 1])
"Length of the axis arrows"
parameter axis_length::Real = 0.1
"Radius of the axis cylinders"
parameter axis_radius::Real = axis_length / 20
"z-position in animations"
parameter z_position::Real = 0
"Frame angle"
variable phi::Angle
relations
phi = frame_a.phi
# Zero forces/torques (sensor-like, does not affect dynamics)
#frame_a.fx = 0
#frame_a.fy = 0
#frame_a.tau = 0
# X-axis: along local x direction, rotated by frame angle
x_shape.r = [frame_a.x, frame_a.y, z_position]
x_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
x_shape.r_shape = [0, 0, 0]
x_shape.length_direction = [1, 0, 0]
x_shape.width_direction = [0, 0, 1]
x_shape.length = axis_length
x_shape.width = 2 * axis_radius
x_shape.height = 2 * axis_radius
# Y-axis: along local y direction, same rotation
y_shape.r = [frame_a.x, frame_a.y, z_position]
y_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
y_shape.r_shape = [0, 0, 0]
y_shape.length_direction = [0, 1, 0]
y_shape.width_direction = [0, 0, 1]
y_shape.length = axis_length
y_shape.width = 2 * axis_radius
y_shape.height = 2 * axis_radius
# Z-axis: perpendicular to the plane, same rotation
z_shape.r = [frame_a.x, frame_a.y, z_position]
z_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
z_shape.r_shape = [0, 0, 0]
z_shape.length_direction = [0, 0, 1]
z_shape.width_direction = [1, 0, 0]
z_shape.length = axis_length
z_shape.width = 2 * axis_radius
z_shape.height = 2 * axis_radius
metadata {}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses