Distance
Measure the distance between the origins of two frame connectors
Library
PlanarMechanics/Sensors
Description
The distance between the origins of frame_a
and of frame_b
are determined and provided at theoutput signal connector distance
. Thisdistance is always positive. Derivatives of thissignal can be easily obtained by connecting theblockModelica.Blocks.Continuous.Derto distance
(this block performs analytic differentiationof the input signal using the der(…)
operator).
In the following figure the animation of thesensor is shown. The light blue coordinate system isframe_a
, the dark blue coordinate system is frame_b
,and the yellow arrow is the animated sensor.

If the distance is smaller then the parameter s_small
(in the "Advanced" menu), it is approximated such that its derivative isfinite for zero distance. Without such an approximation, the derivative wouldbe infinite and a division by zero would occur. The approximation is performedin the following way: If distance > ssmall, it iscomputed as sqrt(r*r) where r is theposition vector from the origin of frame_a
to the origin of frame_b
.If the distance becomes smaller then ssmall, the "sqrt()"function is approximated by a second order polynomial, such that the functionvalue and its first derivative are identical for sqrt() and the polynomial atssmall.Furthermore, the polynomial passes through zero. The effect is, that the distancefunction is continuous and differentiable everywhere. The derivative at zero distanceis 3/(2*ssmall).
Parameters
Name | Label | Description | Data Type | Valid Values |
---|---|---|---|---|
mo_animation | animation | = true, if animation shall be enabled (show arrow) | Scalar | true |
mo_arrowDiameter | arrowDiameter | Diameter of relative arrow from frame_a to frame_b | Scalar | |
mo_arrowColor | arrowColor | Color of relative arrow from frame_a to frame_b | Vector of size 3 | |
mo_specularCoefficient | specularCoefficient | Reflection of ambient light (= 0: light is completely absorbed) | Scalar |
Name | Label | Description | Data Type | Valid Values |
---|---|---|---|---|
mo_s_small | s_small | Prevent zero-division if distance between frame_a and frame_b is zero | Scalar |
Name | Label | Description | Data Type | Valid Values |
---|---|---|---|---|
mo__nmodifiers | Number of Modifiers | Specifies the number of modifiers | Number | |
mo__modifiers | Modifiers | Add new modifier | Structure | |
mo__modifiers/varname | Variable name | Cell of strings | 'r_rel_0' | |
mo__modifiers/attribute | Attribute | Cell of strings | 'start' | |
mo__modifiers/value | Value |
Ports
Name | Type | Description | IO Type | Number |
---|---|---|---|---|
frame_a | implicit | Coordinate system fixed to the component with one cut-force and cut-torque | input | 1 |
frame_b | implicit | Coordinate system fixed to the component with one cut-force and cut-torque | input | 2 |
distance | implicit | Distance between the origin of frame_a and the origin of frame_b | output | 1 |