Skip to content

Commit

Permalink
Improved visualization of couple of components, esp. from 'Parts'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobolar committed Mar 12, 2015
1 parent a843460 commit 1adde8a
Show file tree
Hide file tree
Showing 22 changed files with 137 additions and 254 deletions.
4 changes: 2 additions & 2 deletions PlanarMechanics/Joints/Prismatic.mo
Expand Up @@ -31,11 +31,11 @@ model Prismatic "A prismatic joint"
"Width of prismatic joint box"
annotation (Dialog(tab="Animation",
group="if animation = true", enable=animate));
input Types.Color boxColor=Types.Defaults.JointColor
input PlanarMechanics.Types.Color boxColor=Types.Defaults.JointColor
"Color of prismatic joint box"
annotation (HideResult=true, Dialog(tab="Animation",
group="if animation = true", enable=animate, colorSelector=true));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient
input PlanarMechanics.Types.SpecularCoefficient
specularCoefficient = planarWorld.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (HideResult=true, Dialog(tab="Animation",
Expand Down
4 changes: 2 additions & 2 deletions PlanarMechanics/Joints/Revolute.mo
Expand Up @@ -31,11 +31,11 @@ model Revolute "A revolute joint"
"Diameter of cylinder representing the joint axis"
annotation (Dialog(tab="Animation",
group="if animation = true", enable=animate));
input Modelica.Mechanics.MultiBody.Types.Color cylinderColor=Types.Defaults.JointColor
input PlanarMechanics.Types.Color cylinderColor=Types.Defaults.JointColor
"Color of cylinder representing the joint axis"
annotation (HideResult=true, Dialog(colorSelector=true,tab="Animation",
group="if animation = true", enable=animate));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient
input PlanarMechanics.Types.SpecularCoefficient
specularCoefficient = planarWorld.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (HideResult=true, Dialog(tab="Animation",
Expand Down
13 changes: 9 additions & 4 deletions PlanarMechanics/Parts/Body.mo
Expand Up @@ -23,13 +23,18 @@ model Body "Body component with mass and inertia"
tab="Animation",
group="if animation = true",
enable=animate));
parameter Boolean enableGravity = true
parameter Boolean enableGravity = true
"= true, if gravity effects should be taken into account" annotation (
Evaluate=true,
HideResult=true,
choices(checkBox=true));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient
specularCoefficient = planarWorld.defaultSpecularCoefficient
input Types.Color sphereColor=Types.Defaults.BodyColor "Color of sphere"
annotation (HideResult = true, Dialog(
colorSelector=true,
tab="Animation",
group="if animation = true",
enable=animate));
input Types.SpecularCoefficient specularCoefficient = planarWorld.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (HideResult = true, Dialog(tab="Animation", group="if animation = true", enable=animate));
SI.Force f[2] "Force";
Expand All @@ -45,7 +50,7 @@ model Body "Body component with mass and inertia"
//Visualization
MB.Visualizers.Advanced.Shape sphere(
shapeType="sphere",
color={63,63,255},
color=sphereColor,
specularCoefficient=specularCoefficient,
length=sphereDiameter,
width=sphereDiameter,
Expand Down
38 changes: 11 additions & 27 deletions PlanarMechanics/Parts/Damper.mo
@@ -1,6 +1,6 @@
within PlanarMechanics.Parts;
model Damper "Linear (velocity dependent) damper"
extends PlanarMechanics.Interfaces.PartialTwoFrames;
extends BaseClasses.TwoConnectorShapes;
extends
Modelica.Thermal.HeatTransfer.Interfaces.PartialElementaryConditionalHeatPort(
final T=293.15);
Expand All @@ -21,33 +21,26 @@ model Damper "Linear (velocity dependent) damper"
"Cause an assert when the distance between frame_a and frame_b < s_small" annotation (Dialog(
tab="Advanced"));

parameter SI.Length zPosition = planarWorld.defaultZPosition
"Position z of cylinder representing the fixed translation" annotation (Dialog(
tab="Animation", group="if animation = true", enable=animate));
//Visualization
parameter SI.Length length_a = planarWorld.defaultForceLength
"Length of cylinder at frame_a side"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Damper cylinders (if animation = true)", enable=animate));
input SI.Diameter diameter_a = planarWorld.defaultForceWidth
"Diameter of cylinder at frame_a side"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Damper cylinders (if animation = true)", enable=animate));
input SI.Diameter diameter_b = 0.6*diameter_a
"Diameter of cylinder at frame_b side"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
input Types.Color color_a = {100,100,100} "Color at frame_a"
annotation (HideResult=true, Dialog(tab="Animation", group="if animation = true", enable=animate, colorSelector=true));
input Types.Color color_b = {155,155,155} "Color at frame_b"
annotation (HideResult=true, Dialog(tab="Animation", group="if animation = true", enable=animate, colorSelector=true));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient specularCoefficient = planarWorld.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (HideResult=true, Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Damper cylinders (if animation = true)", enable=animate));
input Types.Color color_a = {100,100,100} "Color of cylinder at frame_a side"
annotation (HideResult=true, Dialog(tab="Animation", group="Damper cylinders (if animation = true)", enable=animate, colorSelector=true));
input Types.Color color_b = {155,155,155} "Color of cylinder at frame_b side"
annotation (HideResult=true, Dialog(tab="Animation", group="Damper cylinders (if animation = true)", enable=animate, colorSelector=true));

SI.Distance length
"Distance between the origin of frame_a and the origin of frame_b";
parameter Boolean animate = true "Enable animation"
annotation(Dialog(group="Animation"));
protected
SI.Position r0_b[3] = {d0[1], d0[2], 0} * noEvent(min(length_a, length));
MB.Visualizers.Advanced.Shape shape_a(
MB.Visualizers.Advanced.Shape cylinder_a(
shapeType="cylinder",
color=color_a,
specularCoefficient=specularCoefficient,
Expand All @@ -58,8 +51,7 @@ protected
widthDirection={0,0,1},
r=MB.Frames.resolve1(planarWorld.R,{frame_a.x,frame_a.y,zPosition})+planarWorld.r_0,
R=planarWorld.R) if planarWorld.enableAnimation and animate;

MB.Visualizers.Advanced.Shape shape_b(
MB.Visualizers.Advanced.Shape cylinder_b(
shapeType="cylinder",
color=color_b,
specularCoefficient=specularCoefficient,
Expand Down Expand Up @@ -125,14 +117,6 @@ equation
extent={{-150,80},{150,40}},
textString="%name",
lineColor={0,0,255}),
Text(
extent={{-108,-24},{-72,-49}},
lineColor={128,128,128},
textString="a"),
Text(
extent={{72,-24},{108,-49}},
lineColor={128,128,128},
textString="b"),
Text(
extent={{-100,-50},{100,-80}},
lineColor={0,0,0},
Expand Down
8 changes: 4 additions & 4 deletions PlanarMechanics/Parts/FixedRotation.mo
Expand Up @@ -4,7 +4,7 @@ model FixedRotation "A fixed translation between two components (rigid rod)"

parameter SI.Angle alpha "Fixed rotation angle";
parameter Boolean animate = true "= true, if animation shall be enabled"
annotation(Dialog(group="Animation"));
annotation(Dialog(group="Animation"));
parameter SI.Length zPosition = planarWorld.defaultZPosition
"Position z of cylinder representing the fixed rotation" annotation (Dialog(
tab="Animation",
Expand All @@ -16,17 +16,17 @@ model FixedRotation "A fixed translation between two components (rigid rod)"
parameter SI.Length cylinderDiameter=planarWorld.defaultJointWidth
"Diameter of cylinder representing the fixed rotation"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
input Modelica.Mechanics.MultiBody.Types.Color cylinderColor={155,155,155}
input PlanarMechanics.Types.Color color=Types.Defaults.RodColor
"Color of cylinder representing the fixed rotation"
annotation (HideResult = true, Dialog(colorSelector=true,tab="Animation", group="if animation = true", enable=animate));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient
input PlanarMechanics.Types.SpecularCoefficient
specularCoefficient = planarWorld.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (HideResult = true, Dialog(tab="Animation", group="if animation = true", enable=animate));
//Visualization
MB.Visualizers.Advanced.Shape cylinder(
shapeType="cylinder",
color=cylinderColor,
color=color,
specularCoefficient=specularCoefficient,
length=cylinderLength,
width=cylinderDiameter,
Expand Down
20 changes: 14 additions & 6 deletions PlanarMechanics/Parts/FixedTranslation.mo
Expand Up @@ -4,25 +4,33 @@ model FixedTranslation "A fixed translation between two components (rigid rod)"

parameter SI.Length r[2] = {1,0}
"Fixed x,y-length of the rod resolved w.r.t to body frame_a at phi = 0";
final parameter SI.Length l = sqrt(r*r) "Length of vector r";
final parameter SI.Length l = Modelica.Math.Vectors.length(r)
"Length of vector r";
SI.Position r0[2] "Length of the rod resolved w.r.t to inertal frame";
Real R[2,2] "Rotation matrix";

parameter Boolean animate = true "= true, if animation shall be enabled"
annotation(Dialog(group="Animation"));
annotation(Dialog(group="Animation"));
parameter SI.Length zPosition = planarWorld.defaultZPosition
"Position z of cylinder representing the fixed translation" annotation (Dialog(
tab="Animation", group="if animation = true", enable=animate));
parameter SI.Distance width=l/planarWorld.defaultWidthFraction
"Width of shape"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
input PlanarMechanics.Types.Color color=Types.Defaults.RodColor
"Color of shape" annotation (HideResult = true, Dialog(
colorSelector=true,
tab="Animation",
group="if animation = true",
enable=animate));
input PlanarMechanics.Types.SpecularCoefficient
specularCoefficient = planarWorld.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (HideResult = true, Dialog(tab="Animation", group="if animation = true", enable=animation));
annotation (HideResult = true, Dialog(tab="Animation", group="if animation = true", enable=animate));
//Visualization
MB.Visualizers.Advanced.Shape cylinder(
shapeType="cylinder",
color={128,128,128},
color=color,
specularCoefficient=specularCoefficient,
length=l,
width=width,
Expand Down
61 changes: 11 additions & 50 deletions PlanarMechanics/Parts/Spring.mo
@@ -1,6 +1,6 @@
within PlanarMechanics.Parts;
model Spring "Linear 2D translational spring"
extends PlanarMechanics.Interfaces.PartialTwoFrames;
extends BaseClasses.TwoConnectorShapes;

parameter StateSelect stateSelect=StateSelect.default
"Priority to use phi and w as states" annotation(HideResult=true,Dialog(tab="Advanced"));
Expand Down Expand Up @@ -32,21 +32,15 @@ model Spring "Linear 2D translational spring"
"Cause an assert when the distance between frame_a and frame_b < s_small" annotation (Dialog(
tab="Advanced"));

parameter SI.Length zPosition = planarWorld.defaultZPosition
"Position z of cylinder representing the fixed translation" annotation (Dialog(
tab="Animation", group="if animation = true", enable=animate));
//Visualization
parameter Integer numberOfWindings = 5 "Number of spring windings"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
input SI.Position width = planarWorld.defaultForceWidth "Width of spring"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
input SI.Position coilWidth = width/10 "Width of spring coil"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Spring coil (if animation = true)", enable=animate));
input SI.Length width = planarWorld.defaultJointWidth "Width of spring"
annotation (Dialog(tab="Animation", group="Spring coil (if animation = true)", enable=animate));
input SI.Length coilWidth = width/10 "Width of spring coil"
annotation (Dialog(tab="Animation", group="Spring coil (if animation = true)", enable=animate));
input Types.Color color = Types.Defaults.SpringColor "Color of spring"
annotation (HideResult=true, Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animate));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient
specularCoefficient = planarWorld.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (HideResult=true, Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (HideResult=true, Dialog(tab="Animation", group="Spring coil (if animation = true)", enable=animate, colorSelector=true));

SI.Length length
"Distance between the origin of frame_a and the origin of frame_b";
Expand All @@ -55,33 +49,8 @@ model Spring "Linear 2D translational spring"
Real e_rel_0[3](each final unit="1")
"Unit vector (3D) in direction from frame_a to frame_b, resolved in multibody world frame";

//Visualization
import MB = Modelica.Mechanics.MultiBody;
parameter Boolean animate = true "Enable animation"
annotation(Dialog(group="Animation"));
MB.Visualizers.Advanced.Shape contactA(
shapeType="cylinder",
specularCoefficient=specularCoefficient,
length=0.1,
width=0.1,
height=0.1,
lengthDirection={0,0,1},
widthDirection={1,0,0},
r_shape={0,0,-0.06},
r=MB.Frames.resolve1(planarWorld.R,{frame_a.x,frame_a.y,zPosition})+planarWorld.r_0,
R=planarWorld.R) if planarWorld.enableAnimation and animate;
MB.Visualizers.Advanced.Shape contactB(
shapeType="cylinder",
specularCoefficient=specularCoefficient,
length=0.1,
width=0.1,
height=0.1,
lengthDirection={0,0,1},
widthDirection={1,0,0},
r_shape={0,0,-0.06},
r=MB.Frames.resolve1(planarWorld.R,{frame_b.x,frame_b.y,zPosition})+planarWorld.r_0,
R=planarWorld.R) if planarWorld.enableAnimation and animate;
MB.Visualizers.Advanced.Shape lineShape(
protected
MB.Visualizers.Advanced.Shape shapeCoil(
shapeType="spring",
color=color,
specularCoefficient=specularCoefficient,
Expand Down Expand Up @@ -161,15 +130,7 @@ for this situation:
Text(
extent={{-150,80},{150,40}},
textString="%name",
lineColor={0,0,255}),
Text(
extent={{-108,-24},{-72,-49}},
lineColor={128,128,128},
textString="a"),
Text(
extent={{72,-24},{108,-49}},
lineColor={128,128,128},
textString="b")}),
lineColor={0,0,255})}),
Diagram(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}},
Expand Down

0 comments on commit 1adde8a

Please sign in to comment.