diff --git a/Modelica/Mechanics/MultiBody/Visualizers/Advanced/Arrow.mo b/Modelica/Mechanics/MultiBody/Visualizers/Advanced/Arrow.mo index d835a3d035..5c4d89db01 100644 --- a/Modelica/Mechanics/MultiBody/Visualizers/Advanced/Arrow.mo +++ b/Modelica/Mechanics/MultiBody/Visualizers/Advanced/Arrow.mo @@ -5,6 +5,7 @@ model Arrow import Modelica.Mechanics.MultiBody.Types; import Modelica.Mechanics.MultiBody.Frames; import T = Modelica.Mechanics.MultiBody.Frames.TransformationMatrices; + import Modelica.Units.Conversions.to_unit1; input Frames.Orientation R=Frames.nullRotation() "Orientation object to rotate the world frame into the arrow frame" annotation(Dialog); @@ -12,25 +13,49 @@ model Arrow "Position vector from origin of world frame to origin of arrow frame, resolved in world frame" annotation(Dialog); input SI.Position r_tail[3]={0,0,0} "Position vector from origin of arrow frame to arrow tail, resolved in arrow frame" annotation(Dialog); - input Real r_head[3]={0,0,0} - "Vector from arrow tail to the head of the arrow, resolved in arrow frame" annotation(Dialog); - input Types.Color color=Modelica.Mechanics.MultiBody.Types.Defaults.ArrowColor - "Color of arrow" annotation(Dialog(colorSelector=true)); + input SI.Position r_head[3]={0,0,0} + "Position vector from arrow tail to the head of the arrow, resolved in arrow frame" annotation(Dialog); + input SI.Diameter diameter=world.defaultArrowDiameter + "Diameter of arrow line" annotation(Dialog); + input SI.Diameter headDiameter=3*diameter "Diameter of arrow head" annotation(Dialog); + input SI.Length headLength=5*diameter "Length of arrow head" annotation(Dialog); + input Types.Color color=Types.Defaults.ArrowColor "Color of arrow" annotation(Dialog(colorSelector=true)); input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient - "Material property describing the reflecting of ambient light (= 0 means, that light is completely absorbed)" annotation(Dialog); - parameter Types.VectorQuantity quantity=Types.VectorQuantity.RelativePosition - "Kind of physical quantity represented by the vector" annotation(Dialog); - input Boolean headAtOrigin=false "= true, if the vector is pointing towards the origin of vector frame" annotation(Dialog); + "Material property describing the reflecting of ambient light (= 0 means, that light is completely absorbed)" + annotation(Dialog); + protected outer Modelica.Mechanics.MultiBody.World world; - SI.Position rvisobj[3] = r + T.resolve1(R.T, r_tail); - Visualizers.Advanced.Vector arrowLine( - coordinates=r_head, + + SI.Length length = Modelica.Math.Vectors.length(r_head) "Length of arrow"; + SI.Length headLengthMax = noEvent(min(length, headLength)); + SI.Length lineLength = length - headLengthMax; + SI.Position r_shape_cone[3] = r_tail + r_head*noEvent(if length < 1.e-7 then 0 else lineLength/length) + "Position vector from origin of arrow frame to origin of head's cone shape, resolved in arrow frame"; + + Visualizers.Advanced.Shape arrowLine( + length=lineLength, + width=diameter, + height=diameter, + lengthDirection=to_unit1(r_head), + widthDirection={0,1,0}, + shapeType="cylinder", + color=color, + specularCoefficient=specularCoefficient, + r_shape=r_tail, + r=r, + R=R) if world.enableAnimation; + Visualizers.Advanced.Shape arrowHead( + length=headLengthMax, + width=headDiameter, + height=headDiameter, + lengthDirection=to_unit1(r_head), + widthDirection={0,1,0}, + shapeType="cone", color=color, specularCoefficient=specularCoefficient, - r=rvisobj, - quantity=quantity, - headAtOrigin=headAtOrigin, + r_shape=r_shape_cone, + r=r, R=R) if world.enableAnimation; annotation ( @@ -38,7 +63,7 @@ protected
Model Arrow defines an arrow that is dynamically visualized at the defined location (see variables below). -If you want an arrow representing something that is not a relative position, use +If you want an arrow representing a physical quantity, consider using Vector instead.
@@ -47,9 +72,10 @@ If you want an arrow representing something that is not a relative position
-The dialog variables R, r, r_tail, r_head, color,
-specularCoefficient, and headAtOrigin
-are declared as (time varying) input variables.
+The dialog variables R, r, r_tail, r_head,
+diameter, headDiameter, headLength, color
+and specularCoefficient are declared as (time varying) input
+variables.
If the default equation is not appropriate, a corresponding
modifier equation has to be provided in the
model where an Arrow instance is used, e.g., in the form
diff --git a/Modelica/Mechanics/MultiBody/Visualizers/FixedFrame.mo b/Modelica/Mechanics/MultiBody/Visualizers/FixedFrame.mo
index 00246e8672..17aed34efc 100644
--- a/Modelica/Mechanics/MultiBody/Visualizers/FixedFrame.mo
+++ b/Modelica/Mechanics/MultiBody/Visualizers/FixedFrame.mo
@@ -11,8 +11,8 @@ model FixedFrame
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Distance diameter=length/world.defaultFrameDiameterFraction
"Diameter of axes arrows" annotation (Dialog(group="if animation = true", enable=animation));
- input Types.Color color_x=Modelica.Mechanics.MultiBody.Types.Defaults.
- FrameColor "Color of x-arrow"
+ input Types.Color color_x=Modelica.Mechanics.MultiBody.Types.Defaults.FrameColor
+ "Color of x-arrow"
annotation (Dialog(colorSelector=true,group="if animation = true", enable=animation));
input Types.Color color_y=color_x "Color of y-arrow"
annotation (Dialog(colorSelector=true,group="if animation = true", enable=animation));
@@ -26,38 +26,23 @@ protected
parameter Boolean showLabels2= world.enableAnimation and animation and showLabels;
// Parameters to define axes
- SI.Length headLength=min(length, diameter*Types.Defaults.FrameHeadLengthFraction);
+ SI.Length headLength=diameter*Types.Defaults.FrameHeadLengthFraction;
SI.Length headWidth=diameter*Types.Defaults.FrameHeadWidthFraction;
- SI.Length lineLength=max(0, length - headLength);
- SI.Length lineWidth=diameter;
// Parameters to define axes labels
- SI.Length scaledLabel=Modelica.Mechanics.MultiBody.Types.Defaults.FrameLabelHeightFraction*diameter;
+ SI.Length scaledLabel=diameter*Types.Defaults.FrameLabelHeightFraction;
SI.Length labelStart=1.05*length;
// x-axis
- Visualizers.Advanced.Shape x_arrowLine(
- shapeType="cylinder",
- length=lineLength,
- width=lineWidth,
- height=lineWidth,
- lengthDirection={1,0,0},
- widthDirection={0,1,0},
- color=color_x,
- specularCoefficient=specularCoefficient,
+ Visualizers.Advanced.Arrow x_arrow(
+ R=frame_a.R,
r=frame_a.r_0,
- R=frame_a.R) if animation2;
- Visualizers.Advanced.Shape x_arrowHead(
- shapeType="cone",
- length=headLength,
- width=headWidth,
- height=headWidth,
- lengthDirection={1,0,0},
- widthDirection={0,1,0},
+ r_head=length*{1,0,0},
+ diameter=diameter,
+ headDiameter=headWidth,
+ headLength=headLength,
color=color_x,
- specularCoefficient=specularCoefficient,
- r=frame_a.r_0 + Frames.resolve1(frame_a.R, {lineLength,0,0}),
- R=frame_a.R) if animation2;
+ specularCoefficient=specularCoefficient) if animation2;
Visualizers.Internal.Lines x_label(
lines=scaledLabel*{[0,0; 1,1],[0,1; 1,0]},
diameter=diameter,
@@ -70,28 +55,15 @@ protected
R=frame_a.R) if showLabels2;
// y-axis
- Visualizers.Advanced.Shape y_arrowLine(
- shapeType="cylinder",
- length=lineLength,
- width=lineWidth,
- height=lineWidth,
- lengthDirection={0,1,0},
- widthDirection={1,0,0},
- color=color_y,
- specularCoefficient=specularCoefficient,
+ Visualizers.Advanced.Arrow y_arrow(
+ R=frame_a.R,
r=frame_a.r_0,
- R=frame_a.R) if animation2;
- Visualizers.Advanced.Shape y_arrowHead(
- shapeType="cone",
- length=headLength,
- width=headWidth,
- height=headWidth,
- lengthDirection={0,1,0},
- widthDirection={1,0,0},
+ r_head=length*{0,1,0},
+ diameter=diameter,
+ headDiameter=headWidth,
+ headLength=headLength,
color=color_y,
- specularCoefficient=specularCoefficient,
- r=frame_a.r_0 + Frames.resolve1(frame_a.R, {0,lineLength,0}),
- R=frame_a.R) if animation2;
+ specularCoefficient=specularCoefficient) if animation2;
Visualizers.Internal.Lines y_label(
lines=scaledLabel*{[0,0; 1,1.5],[0,1.5; 0.5,0.75]},
diameter=diameter,
@@ -104,28 +76,15 @@ protected
R=frame_a.R) if showLabels2;
// z-axis
- Visualizers.Advanced.Shape z_arrowLine(
- shapeType="cylinder",
- length=lineLength,
- width=lineWidth,
- height=lineWidth,
- lengthDirection={0,0,1},
- widthDirection={0,1,0},
- color=color_z,
- specularCoefficient=specularCoefficient,
+ Visualizers.Advanced.Arrow z_arrow(
+ R=frame_a.R,
r=frame_a.r_0,
- R=frame_a.R) if animation2;
- Visualizers.Advanced.Shape z_arrowHead(
- shapeType="cone",
- length=headLength,
- width=headWidth,
- height=headWidth,
- lengthDirection={0,0,1},
- widthDirection={0,1,0},
+ r_head=length*{0,0,1},
+ diameter=diameter,
+ headDiameter=headWidth,
+ headLength=headLength,
color=color_z,
- specularCoefficient=specularCoefficient,
- r=frame_a.r_0 + Frames.resolve1(frame_a.R, {0,0,lineLength}),
- R=frame_a.R) if animation2;
+ specularCoefficient=specularCoefficient) if animation2;
Visualizers.Internal.Lines z_label(
lines=scaledLabel*{[0,0; 1,0],[0,1; 1,1],[0,1; 1,0]},
diameter=diameter,
diff --git a/Modelica/Mechanics/MultiBody/package.mo b/Modelica/Mechanics/MultiBody/package.mo
index 54847424d3..ad1c47a072 100644
--- a/Modelica/Mechanics/MultiBody/package.mo
+++ b/Modelica/Mechanics/MultiBody/package.mo
@@ -170,37 +170,20 @@ model World
*/
protected
// Parameters to define axes
- parameter SI.Length headLength=min(axisLength, axisDiameter*Types.Defaults.
- FrameHeadLengthFraction);
- parameter SI.Length headWidth=axisDiameter*Types.Defaults.
- FrameHeadWidthFraction;
- parameter SI.Length lineLength=max(0, axisLength - headLength);
- parameter SI.Length lineWidth=axisDiameter;
+ parameter SI.Length headLength=axisDiameter*Types.Defaults.FrameHeadLengthFraction;
+ parameter SI.Length headWidth=axisDiameter*Types.Defaults.FrameHeadWidthFraction;
// Parameters to define axes labels
- parameter SI.Length scaledLabel=Modelica.Mechanics.MultiBody.Types.Defaults.FrameLabelHeightFraction*
- axisDiameter;
+ parameter SI.Length scaledLabel=axisDiameter*Types.Defaults.FrameLabelHeightFraction;
parameter SI.Length labelStart=1.05*axisLength;
// x-axis
- Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape x_arrowLine(
- shapeType="cylinder",
- length=lineLength,
- width=lineWidth,
- height=lineWidth,
- lengthDirection={1,0,0},
- widthDirection={0,1,0},
- color=axisColor_x,
- specularCoefficient=0) if enableAnimation and animateWorld;
- Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape x_arrowHead(
- shapeType="cone",
- length=headLength,
- width=headWidth,
- height=headWidth,
- lengthDirection={1,0,0},
- widthDirection={0,1,0},
+ Modelica.Mechanics.MultiBody.Visualizers.Advanced.Arrow x_arrow(
+ r_head=axisLength*{1,0,0},
+ diameter=axisDiameter,
+ headDiameter=headWidth,
+ headLength=headLength,
color=axisColor_x,
- r={lineLength,0,0},
specularCoefficient=0) if enableAnimation and animateWorld;
Modelica.Mechanics.MultiBody.Visualizers.Internal.Lines x_label(
lines=scaledLabel*{[0, 0; 1, 1],[0, 1; 1, 0]},
@@ -212,24 +195,12 @@ protected
specularCoefficient=0) if enableAnimation and animateWorld and axisShowLabels;
// y-axis
- Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape y_arrowLine(
- shapeType="cylinder",
- length=lineLength,
- width=lineWidth,
- height=lineWidth,
- lengthDirection={0,1,0},
- widthDirection={1,0,0},
- color=axisColor_y,
- specularCoefficient=0) if enableAnimation and animateWorld;
- Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape y_arrowHead(
- shapeType="cone",
- length=headLength,
- width=headWidth,
- height=headWidth,
- lengthDirection={0,1,0},
- widthDirection={1,0,0},
+ Modelica.Mechanics.MultiBody.Visualizers.Advanced.Arrow y_arrow(
+ r_head=axisLength*{0,1,0},
+ diameter=axisDiameter,
+ headDiameter=headWidth,
+ headLength=headLength,
color=axisColor_y,
- r={0,lineLength,0},
specularCoefficient=0) if enableAnimation and animateWorld;
Modelica.Mechanics.MultiBody.Visualizers.Internal.Lines y_label(
lines=scaledLabel*{[0, 0; 1, 1.5],[0, 1.5; 0.5, 0.75]},
@@ -241,24 +212,12 @@ protected
specularCoefficient=0) if enableAnimation and animateWorld and axisShowLabels;
// z-axis
- Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape z_arrowLine(
- shapeType="cylinder",
- length=lineLength,
- width=lineWidth,
- height=lineWidth,
- lengthDirection={0,0,1},
- widthDirection={0,1,0},
- color=axisColor_z,
- specularCoefficient=0) if enableAnimation and animateWorld;
- Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape z_arrowHead(
- shapeType="cone",
- length=headLength,
- width=headWidth,
- height=headWidth,
- lengthDirection={0,0,1},
- widthDirection={0,1,0},
+ Modelica.Mechanics.MultiBody.Visualizers.Advanced.Arrow z_arrow(
+ r_head=axisLength*{0,0,1},
+ diameter=axisDiameter,
+ headDiameter=headWidth,
+ headLength=headLength,
color=axisColor_z,
- r={0,0,lineLength},
specularCoefficient=0) if enableAnimation and animateWorld;
Modelica.Mechanics.MultiBody.Visualizers.Internal.Lines z_label(
lines=scaledLabel*{[0, 0; 1, 0],[0, 1; 1, 1],[0, 1; 1, 0]},
@@ -270,30 +229,14 @@ protected
specularCoefficient=0) if enableAnimation and animateWorld and axisShowLabels;
// Uniform gravity visualization
- parameter SI.Length gravityHeadLength=min(gravityArrowLength,
- gravityArrowDiameter*Types.Defaults.ArrowHeadLengthFraction);
+ parameter SI.Length gravityheadLength=gravityArrowDiameter*Types.Defaults.ArrowHeadLengthFraction;
parameter SI.Length gravityHeadWidth=gravityArrowDiameter*Types.Defaults.ArrowHeadWidthFraction;
- parameter SI.Length gravityLineLength=max(0, gravityArrowLength - gravityHeadLength);
- Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape gravityArrowLine(
- shapeType="cylinder",
- length=gravityLineLength,
- width=gravityArrowDiameter,
- height=gravityArrowDiameter,
- lengthDirection=n,
- widthDirection={0,1,0},
- color=gravityArrowColor,
- r_shape=gravityArrowTail,
- specularCoefficient=0) if enableAnimation and animateGravity and gravityType == GravityTypes.UniformGravity;
- Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape gravityArrowHead(
- shapeType="cone",
- length=gravityHeadLength,
- width=gravityHeadWidth,
- height=gravityHeadWidth,
- lengthDirection=n,
- widthDirection={0,1,0},
+ Modelica.Mechanics.MultiBody.Visualizers.Advanced.Arrow gravityArrow(
+ r_head=gravityArrowLength*n,
+ diameter=gravityArrowDiameter,
+ headDiameter=gravityHeadWidth,
+ headLength=gravityheadLength,
color=gravityArrowColor,
- r_shape=gravityArrowTail + Modelica.Math.Vectors.normalize(
- n)*gravityLineLength,
specularCoefficient=0) if enableAnimation and animateGravity and gravityType == GravityTypes.UniformGravity;
// Point gravity visualization