Ticket #1403: CutForceAndTorque1Total.mo

File CutForceAndTorque1Total.mo, 237.7 KB (added by Leonardo Laguna, 14 years ago)
Line 
1package Modelica "Modelica Standard Library (Version 3.1)"
2 extends Modelica.Icons.Library;
3 annotation(preferredView="info", version="3.1", versionBuild=5, versionDate="2009-08-14", dateModified="2009-12-18 08:49:49Z", revisionId="$Id:: package.mo 3222 2009-12-18 08:53:50Z #$", conversion(noneFromVersion="3.0.1", noneFromVersion="3.0", from(version="2.1", script="Scripts/ConvertModelica_from_2.2.2_to_3.0.mos"), from(version="2.2", script="Scripts/ConvertModelica_from_2.2.2_to_3.0.mos"), from(version="2.2.1", script="Scripts/ConvertModelica_from_2.2.2_to_3.0.mos"), from(version="2.2.2", script="Scripts/ConvertModelica_from_2.2.2_to_3.0.mos")), __Dymola_classOrder={"UsersGuide","Blocks","StateGraph","Electrical","Magnetic","Mechanics","Fluid","Media","Thermal","Math","Utilities","Constants","Icons","SIunits"}, Settings(NewStateSelection=true), Documentation(info="<HTML>
4<p>
5Package <b>Modelica</b> is a <b>standardized</b> and <b>free</b> package
6that is developed together with the Modelica language from the
7Modelica Association, see
8<a href=\"http://www.Modelica.org\">http://www.Modelica.org</a>.
9It is also called <b>Modelica Standard Library</b>.
10It provides model components in many domains that are based on
11standardized interface definitions. Some typical examples are shown
12in the next figure:
13</p>
14
15<p>
16<img src=\"Images/UsersGuide/ModelicaLibraries.png\">
17</p>
18
19<p>
20For an introduction, have especially a look at:
21</p>
22<ul>
23<li> <a href=\"Modelica://Modelica.UsersGuide.Overview\">Overview</a>
24 provides an overview of the Modelica Standard Library
25 inside the <a href=\"Modelica://Modelica.UsersGuide\">User's Guide</a>.</li>
26<li><a href=\"Modelica://Modelica.UsersGuide.ReleaseNotes\">Release Notes</a>
27 summarizes the changes of new versions of this package.</li>
28<li> <a href=\"Modelica://Modelica.UsersGuide.Contact\">Contact</a>
29 lists the contributors of the Modelica Standard Library.</li>
30<li> The <b>Examples</b> packages in the various libraries, demonstrate
31 how to use the components of the corresponding sublibrary.</li>
32</ul>
33
34<p>
35This version of the Modelica Standard Library consists of
36</p>
37<ul>
38<li> <b>922</b> models and blocks, and</li>
39<li> <b>615</b> functions
40</ul>
41<p>
42that are directly usable (= number of public, non-partial classes).
43</p>
44
45
46<p>
47<b>Licensed by the Modelica Association under the Modelica License 2</b><br>
48Copyright &copy; 1998-2009, ABB, arsenal research, T.&nbsp;Bödrich, DLR, Dynasim, Fraunhofer, Modelon,
49TU Hamburg-Harburg, Politecnico di Milano.
50</p>
51
52<p>
53<i>This Modelica package is <u>free</u> software and
54the use is completely at <u>your own risk</u>;
55it can be redistributed and/or modified under the terms of the
56Modelica license 2, see the license conditions (including the
57disclaimer of warranty)
58<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a></u>
59or at
60<a href=\"http://www.Modelica.org/licenses/ModelicaLicense2\">
61http://www.Modelica.org/licenses/ModelicaLicense2</a>.
62</p>
63
64</HTML>
65"));
66 package Utilities "Library of utility functions dedicated to scripting (operating on files, streams, strings, system)"
67 extends Modelica.Icons.Library;
68 annotation(Documentation(info="<html>
69<p>
70This package contains Modelica <b>functions</b> that are
71especially suited for <b>scripting</b>. The functions might
72be used to work with strings, read data from file, write data
73to file or copy, move and remove files.
74</p>
75<p>
76For an introduction, have especially a look at:
77</p>
78<ul>
79<li> <a href=\"Modelica://Modelica.Utilities.UsersGuide\">Modelica.Utilities.User's Guide</a>
80 discusses the most important aspects of this library.</li>
81<li> <a href=\"Modelica://Modelica.Utilities.Examples\">Modelica.Utilities.Examples</a>
82 contains examples that demonstrate the usage of this library.</li>
83</ul>
84<p>
85The following main sublibraries are available:
86</p>
87<ul>
88<li> <a href=\"Modelica://Modelica.Utilities.Files\">Files</a>
89 provides functions to operate on files and directories, e.g.,
90 to copy, move, remove files.</li>
91<li> <a href=\"Modelica://Modelica.Utilities.Streams\">Streams</a>
92 provides functions to read from files and write to files.</li>
93<li> <a href=\"Modelica://Modelica.Utilities.Strings\">Strings</a>
94 provides functions to operate on strings. E.g.
95 substring, find, replace, sort, scanToken.</li>
96<li> <a href=\"Modelica://Modelica.Utilities.System\">System</a>
97 provides functions to interact with the environment.
98 E.g., get or set the working directory or environment
99 variables and to send a command to the default shell.</li>
100</ul>
101
102<p>
103Copyright &copy; 1998-2009, Modelica Association, DLR and Dynasim.
104</p>
105<p>
106<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
107under the terms of the <b>Modelica license</b>, see the license conditions
108and the accompanying <b>disclaimer</b>
109<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a>.</i>
110</p><br>
111</html>
112"));
113 package Internal "Internal components that a user should usually not directly utilize"
114 partial package PartialModelicaServices "Interfaces of components requiring a tool specific implementation"
115 package Animation "Models and functions for 3-dim. animation"
116 partial model PartialShape "Different visual shapes with variable size; all data have to be set as modifiers"
117 import SI = Modelica.SIunits;
118 import Modelica.Mechanics.MultiBody.Frames;
119 import Modelica.Mechanics.MultiBody.Types;
120 parameter Types.ShapeType shapeType="box" "Type of shape (box, sphere, cylinder, pipecylinder, cone, pipe, beam, gearwheel, spring)";
121 input Frames.Orientation R=Frames.nullRotation() "Orientation object to rotate the world frame into the object frame" annotation(Dialog);
122 input SI.Position r[3]={0,0,0} "Position vector from origin of world frame to origin of object frame, resolved in world frame" annotation(Dialog);
123 input SI.Position r_shape[3]={0,0,0} "Position vector from origin of object frame to shape origin, resolved in object frame" annotation(Dialog);
124 input Real lengthDirection[3](each final unit="1")={1,0,0} "Vector in length direction, resolved in object frame" annotation(Dialog);
125 input Real widthDirection[3](each final unit="1")={0,1,0} "Vector in width direction, resolved in object frame" annotation(Dialog);
126 input SI.Length length=0 "Length of visual object" annotation(Dialog);
127 input SI.Length width=0 "Width of visual object" annotation(Dialog);
128 input SI.Length height=0 "Height of visual object" annotation(Dialog);
129 input Types.ShapeExtra extra=0.0 "Additional size data for some of the shape types" annotation(Dialog);
130 input Real color[3]={255,0,0} "Color of shape" annotation(Dialog);
131 input Types.SpecularCoefficient specularCoefficient=0.7 "Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog);
132 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Rectangle(extent={{-100,-100},{80,60}}, lineColor={0,0,255}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Polygon(points={{-100,60},{-80,100},{100,100},{80,60},{-100,60}}, lineColor={0,0,255}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Polygon(points={{100,100},{100,-60},{80,-100},{80,60},{100,100}}, lineColor={0,0,255}, fillColor={160,160,164}, fillPattern=FillPattern.Solid),Text(extent={{-100,-100},{80,60}}, lineColor={0,0,0}, textString="%shapeType"),Text(extent={{-132,160},{128,100}}, textString="%name", lineColor={0,0,255})}), Documentation(info="<html>
133
134<p>
135This model is documented at
136<a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape\">Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape</a>.
137</p>
138
139</html>
140"));
141 end PartialShape;
142
143 end Animation;
144
145 annotation(Documentation(info="<html>
146
147<p>
148This package contains interfaces of a set of functions and models used in the
149Modelica Standard Library that requires a <u>tool specific implementation</u>.
150There is an associated package called <u>ModelicaServices</u>. A tool vendor
151should provide a proper implementation of this library for the corresponding
152tool. The default implementation is \"do nothing\".
153In the Modelica Standard Library, the models and functions of ModelicaServices
154are used.
155</p>
156
157</html>"));
158 end PartialModelicaServices;
159
160 end Internal;
161
162 end Utilities;
163
164 package Mechanics "Library of 1-dim. and 3-dim. mechanical components (multi-body, rotational, translational)"
165 extends Modelica.Icons.Library2;
166 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-5,-40},{45,-70}}, lineColor={0,0,0}, fillPattern=FillPattern.HorizontalCylinder, fillColor={192,192,192}),Ellipse(extent={{-90,-50},{-80,-60}}, lineColor={0,0,0}),Line(points={{-85,-55},{-60,-21}}, color={0,0,0}, thickness=0.5),Ellipse(extent={{-65,-16},{-55,-26}}, lineColor={0,0,0}),Line(points={{-60,-21},{9,-55}}, color={0,0,0}, thickness=0.5),Ellipse(extent={{4,-50},{14,-60}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Line(points={{-10,-34},{72,-34},{72,-76},{-10,-76}}, color={0,0,0})}), Documentation(info="<HTML>
167<p>
168This package contains components to model the movement
169of 1-dim. rotational, 1-dim. translational, and
1703-dim. <b>mechanical systems</b>.
171</p>
172</HTML>
173"));
174 package MultiBody "Library to model 3-dimensional mechanical systems"
175 import SI = Modelica.SIunits;
176 extends Modelica.Icons.Library;
177 model World "World coordinate system + gravity field + default animation definition"
178 import SI = Modelica.SIunits;
179 import Modelica.Mechanics.MultiBody.Types.GravityTypes;
180 import Modelica.Mechanics.MultiBody.Types;
181 Interfaces.Frame_b frame_b "Coordinate system fixed in the origin of the world frame" annotation(Placement(transformation(extent={{84,-16},{116,16}}, rotation=0)));
182 parameter Boolean enableAnimation=true "= true, if animation of all components is enabled";
183 parameter Boolean animateWorld=true "= true, if world coordinate system shall be visualized" annotation(Dialog(enable=enableAnimation));
184 parameter Boolean animateGravity=true "= true, if gravity field shall be visualized (acceleration vector or field center)" annotation(Dialog(enable=enableAnimation));
185 parameter Types.AxisLabel label1="x" "Label of horizontal axis in icon";
186 parameter Types.AxisLabel label2="y" "Label of vertical axis in icon";
187 parameter Types.GravityTypes gravityType=GravityTypes.UniformGravity "Type of gravity field" annotation(Evaluate=true);
188 parameter SI.Acceleration g=9.81 "Constant gravity acceleration" annotation(Dialog(enable=gravityType == GravityTypes.UniformGravity));
189 parameter Types.Axis n={0,-1,0} "Direction of gravity resolved in world frame (gravity = g*n/length(n))" annotation(Evaluate=true, Dialog(enable=gravityType == Modelica.Mechanics.MultiBody.Types.GravityTypes.UniformGravity));
190 parameter Real mue(unit="m3/s2", min=0)=398600000000000.0 "Gravity field constant (default = field constant of earth)" annotation(Dialog(enable=gravityType == Types.GravityTypes.PointGravity));
191 parameter Boolean driveTrainMechanics3D=true "= true, if 3-dim. mechanical effects of Parts.Mounting1D/Rotor1D/BevelGear1D shall be taken into account";
192 parameter SI.Distance axisLength=nominalLength/2 "Length of world axes arrows" annotation(Dialog(tab="Animation", group="if animateWorld = true", enable=enableAnimation and animateWorld));
193 parameter SI.Distance axisDiameter=axisLength/defaultFrameDiameterFraction "Diameter of world axes arrows" annotation(Dialog(tab="Animation", group="if animateWorld = true", enable=enableAnimation and animateWorld));
194 parameter Boolean axisShowLabels=true "= true, if labels shall be shown" annotation(Dialog(tab="Animation", group="if animateWorld = true", enable=enableAnimation and animateWorld));
195 input Types.Color axisColor_x=Modelica.Mechanics.MultiBody.Types.Defaults.FrameColor "Color of x-arrow" annotation(Dialog(tab="Animation", group="if animateWorld = true", enable=enableAnimation and animateWorld));
196 input Types.Color axisColor_y=axisColor_x annotation(Dialog(tab="Animation", group="if animateWorld = true", enable=enableAnimation and animateWorld));
197 input Types.Color axisColor_z=axisColor_x "Color of z-arrow" annotation(Dialog(tab="Animation", group="if animateWorld = true", enable=enableAnimation and animateWorld));
198 parameter SI.Position gravityArrowTail[3]={0,0,0} "Position vector from origin of world frame to arrow tail, resolved in world frame" annotation(Dialog(tab="Animation", group="if animateGravity = true and gravityType = UniformGravity", enable=enableAnimation and animateGravity and gravityType == GravityTypes.UniformGravity));
199 parameter SI.Length gravityArrowLength=axisLength/2 "Length of gravity arrow" annotation(Dialog(tab="Animation", group="if animateGravity = true and gravityType = UniformGravity", enable=enableAnimation and animateGravity and gravityType == GravityTypes.UniformGravity));
200 parameter SI.Diameter gravityArrowDiameter=gravityArrowLength/defaultWidthFraction "Diameter of gravity arrow" annotation(Dialog(tab="Animation", group="if animateGravity = true and gravityType = UniformGravity", enable=enableAnimation and animateGravity and gravityType == GravityTypes.UniformGravity));
201 input Types.Color gravityArrowColor={0,230,0} "Color of gravity arrow" annotation(Dialog(tab="Animation", group="if animateGravity = true and gravityType = UniformGravity", enable=enableAnimation and animateGravity and gravityType == GravityTypes.UniformGravity));
202 parameter SI.Diameter gravitySphereDiameter=12742000 "Diameter of sphere representing gravity center (default = mean diameter of earth)" annotation(Dialog(tab="Animation", group="if animateGravity = true and gravityType = PointGravity", enable=enableAnimation and animateGravity and gravityType == GravityTypes.PointGravity));
203 input Types.Color gravitySphereColor={0,230,0} "Color of gravity sphere" annotation(Dialog(tab="Animation", group="if animateGravity = true and gravityType = PointGravity", enable=enableAnimation and animateGravity and gravityType == GravityTypes.PointGravity));
204 parameter SI.Length nominalLength=1 "\"Nominal\" length of multi-body system" annotation(Dialog(tab="Defaults"));
205 parameter SI.Length defaultAxisLength=nominalLength/5 "Default for length of a frame axis (but not world frame)" annotation(Dialog(tab="Defaults"));
206 parameter SI.Length defaultJointLength=nominalLength/10 "Default for the fixed length of a shape representing a joint" annotation(Dialog(tab="Defaults"));
207 parameter SI.Length defaultJointWidth=nominalLength/20 "Default for the fixed width of a shape representing a joint" annotation(Dialog(tab="Defaults"));
208 parameter SI.Length defaultForceLength=nominalLength/10 "Default for the fixed length of a shape representing a force (e.g. damper)" annotation(Dialog(tab="Defaults"));
209 parameter SI.Length defaultForceWidth=nominalLength/20 "Default for the fixed width of a shape represening a force (e.g. spring, bushing)" annotation(Dialog(tab="Defaults"));
210 parameter SI.Length defaultBodyDiameter=nominalLength/9 "Default for diameter of sphere representing the center of mass of a body" annotation(Dialog(tab="Defaults"));
211 parameter Real defaultWidthFraction=20 "Default for shape width as a fraction of shape length (e.g., for Parts.FixedTranslation)" annotation(Dialog(tab="Defaults"));
212 parameter SI.Length defaultArrowDiameter=nominalLength/40 "Default for arrow diameter (e.g., of forces, torques, sensors)" annotation(Dialog(tab="Defaults"));
213 parameter Real defaultFrameDiameterFraction=40 "Default for arrow diameter of a coordinate system as a fraction of axis length" annotation(Dialog(tab="Defaults"));
214 parameter Real defaultSpecularCoefficient(min=0)=0.7 "Default reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog(tab="Defaults"));
215 parameter Real defaultN_to_m(unit="N/m", min=0)=1000 "Default scaling of force arrows (length = force/defaultN_to_m)" annotation(Dialog(tab="Defaults"));
216 parameter Real defaultNm_to_m(unit="N.m/m", min=0)=1000 "Default scaling of torque arrows (length = torque/defaultNm_to_m)" annotation(Dialog(tab="Defaults"));
217 protected
218 parameter Integer ndim=if enableAnimation and animateWorld then 1 else 0;
219 parameter Integer ndim2=if enableAnimation and animateWorld and axisShowLabels then 1 else 0;
220 parameter SI.Length headLength=min(axisLength, axisDiameter*Types.Defaults.FrameHeadLengthFraction);
221 parameter SI.Length headWidth=axisDiameter*Types.Defaults.FrameHeadWidthFraction;
222 parameter SI.Length lineLength=max(0, axisLength - headLength);
223 parameter SI.Length lineWidth=axisDiameter;
224 parameter SI.Length scaledLabel=Modelica.Mechanics.MultiBody.Types.Defaults.FrameLabelHeightFraction*axisDiameter;
225 parameter SI.Length labelStart=1.05*axisLength;
226 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;
227 Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape x_arrowHead(shapeType="cone", length=headLength, width=headWidth, height=headWidth, lengthDirection={1,0,0}, widthDirection={0,1,0}, color=axisColor_x, r={lineLength,0,0}, specularCoefficient=0) if enableAnimation and animateWorld;
228 Modelica.Mechanics.MultiBody.Visualizers.Internal.Lines x_label(lines=scaledLabel*{[0,0;1,1],[0,1;1,0]}, diameter=axisDiameter, color=axisColor_x, r_lines={labelStart,0,0}, n_x={1,0,0}, n_y={0,1,0}, specularCoefficient=0) if enableAnimation and animateWorld and axisShowLabels;
229 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;
230 Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape y_arrowHead(shapeType="cone", length=headLength, width=headWidth, height=headWidth, lengthDirection={0,1,0}, widthDirection={1,0,0}, color=axisColor_y, r={0,lineLength,0}, specularCoefficient=0) if enableAnimation and animateWorld;
231 Modelica.Mechanics.MultiBody.Visualizers.Internal.Lines y_label(lines=scaledLabel*{[0,0;1,1.5],[0,1.5;0.5,0.75]}, diameter=axisDiameter, color=axisColor_y, r_lines={0,labelStart,0}, n_x={0,1,0}, n_y={-1,0,0}, specularCoefficient=0) if enableAnimation and animateWorld and axisShowLabels;
232 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;
233 Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape z_arrowHead(shapeType="cone", length=headLength, width=headWidth, height=headWidth, lengthDirection={0,0,1}, widthDirection={0,1,0}, color=axisColor_z, r={0,0,lineLength}, specularCoefficient=0) if enableAnimation and animateWorld;
234 Modelica.Mechanics.MultiBody.Visualizers.Internal.Lines z_label(lines=scaledLabel*{[0,0;1,0],[0,1;1,1],[0,1;1,0]}, diameter=axisDiameter, color=axisColor_z, r_lines={0,0,labelStart}, n_x={0,0,1}, n_y={0,1,0}, specularCoefficient=0) if enableAnimation and animateWorld and axisShowLabels;
235 parameter SI.Length gravityHeadLength=min(gravityArrowLength, gravityArrowDiameter*Types.Defaults.ArrowHeadLengthFraction);
236 parameter SI.Length gravityHeadWidth=gravityArrowDiameter*Types.Defaults.ArrowHeadWidthFraction;
237 parameter SI.Length gravityLineLength=max(0, gravityArrowLength - gravityHeadLength);
238 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;
239 Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape gravityArrowHead(shapeType="cone", length=gravityHeadLength, width=gravityHeadWidth, height=gravityHeadWidth, lengthDirection=n, widthDirection={0,1,0}, color=gravityArrowColor, r_shape=gravityArrowTail + Modelica.Math.Vectors.normalize(n)*gravityLineLength, specularCoefficient=0) if enableAnimation and animateGravity and gravityType == GravityTypes.UniformGravity;
240 parameter Integer ndim_pointGravity=if enableAnimation and animateGravity and gravityType == 2 then 1 else 0;
241 Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape gravitySphere(shapeType="sphere", r_shape={-gravitySphereDiameter/2,0,0}, lengthDirection={1,0,0}, length=gravitySphereDiameter, width=gravitySphereDiameter, height=gravitySphereDiameter, color=gravitySphereColor, specularCoefficient=0) if enableAnimation and animateGravity and gravityType == GravityTypes.PointGravity;
242 function gravityAcceleration= gravityAccelerationTypes(gravityType=gravityType, g=g*Modelica.Math.Vectors.normalize(n), mue=mue);
243 protected
244 function gravityAccelerationTypes "Gravity field acceleration depending on field type and position"
245 import Modelica.Mechanics.MultiBody.Types.GravityTypes;
246 extends Modelica.Icons.Function;
247 input SI.Position r[3] "Position vector from world frame to actual point, resolved in world frame";
248 input GravityTypes gravityType "Type of gravity field";
249 input SI.Acceleration g[3] "Constant gravity acceleration, resolved in world frame, if gravityType=1";
250 input Real mue(unit="m3/s2") "Field constant of point gravity field, if gravityType=2";
251 output SI.Acceleration gravity[3] "Gravity acceleration at point r, resolved in world frame";
252 algorithm
253 gravity:=if gravityType == GravityTypes.UniformGravity then g else if gravityType == GravityTypes.PointGravity then -mue/(r*r)*(r/Modelica.Math.Vectors.length(r)) else zeros(3);
254 end gravityAccelerationTypes;
255
256 equation
257 Connections.root(frame_b.R);
258 assert(Modelica.Math.Vectors.length(n) > 1e-10, "Parameter n of World object is wrong (lenght(n) > 0 required)");
259 frame_b.r_0=zeros(3);
260 frame_b.R=Frames.nullRotation();
261 annotation(defaultComponentName="world", defaultComponentPrefixes="inner", missingInnerMessage="No \"world\" component is defined. A default world
262component with the default gravity field will be used
263(g=9.81 in negative y-axis). If this is not desired,
264drag Modelica.Mechanics.MultiBody.World into the top level of your model.", Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Line(points={{-100,-118},{-100,61}}, color={0,0,0}, thickness=0.5),Polygon(points={{-100,100},{-120,60},{-80,60},{-100,100},{-100,100}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Line(points={{-119,-100},{59,-100}}, color={0,0,0}, thickness=0.5),Polygon(points={{99,-100},{59,-80},{59,-120},{99,-100}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Text(extent={{-140,165},{140,103}}, textString="%name", lineColor={0,0,255}),Text(extent={{95,-113},{144,-162}}, lineColor={0,0,0}, textString="%label1"),Text(extent={{-170,127},{-119,77}}, lineColor={0,0,0}, textString="%label2"),Line(points={{-56,78},{-56,-26}}, color={0,0,255}),Polygon(points={{-68,-26},{-56,-66},{-44,-26},{-68,-26}}, fillColor={0,0,255}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Line(points={{2,78},{2,-26}}, color={0,0,255}),Polygon(points={{-10,-26},{2,-66},{14,-26},{-10,-26}}, fillColor={0,0,255}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Line(points={{66,80},{66,-26}}, color={0,0,255}),Polygon(points={{54,-26},{66,-66},{78,-26},{54,-26}}, fillColor={0,0,255}, fillPattern=FillPattern.Solid, lineColor={0,0,255})}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics), Documentation(info="<HTML>
265<p>
266Model <b>World</b> represents a global coordinate system fixed in
267ground. This model serves several purposes:
268<ul>
269<li> It is used as <b>inertial system</b> in which
270 the equations of all elements of the MultiBody library
271 are defined.</li>
272<li> It is the world frame of an <b>animation window</b> in which
273 all elements of the MultiBody library are visualized.</li>
274<li> It is used to define the <b>gravity field</b> in which a
275 multi-body model is present. Default is a uniform gravity
276 field where the gravity acceleration vector g is the
277 same at every position. Additionally, a point gravity field
278 can be selected.</li>
279<li> It is used to define <b>default settings</b> of animation properties
280 (e.g. the diameter of a sphere representing by default
281 the center of mass of a body, or the diameters of the cylinders
282 representing a revolute joint).</li>
283<li> It is used to define a <b>visual representation</b> of the
284 world model (= 3 coordinate axes with labels) and of the defined
285 gravity field.<br>
286 <IMG SRC=\"../../Images/MultiBody/world.png\" ALT=\"MultiBodys.World\">
287</li>
288</ul>
289<p>
290Since the gravity field function is required from all bodies with mass
291and the default settings of animation properties are required
292from nearly every component, exactly one instance of model World needs
293to be present in every model on the top level. The basic declaration
294needs to be:
295</p>
296<pre>
297 <b>inner</b> Modelica.Mechanics.MultiBody.World world
298</pre>
299<p>
300Note, it must be an <b>inner</b> declaration with instance name <b>world</b>
301in order that this world object can be accessed from all objects in the
302model. When dragging the \"World\" object from the package browser into
303the diagram layer, this declaration is automatically generated
304(this is defined via annotations in model World).
305</p>
306<p>
307All vectors and tensors of a mechanical system are resolved in a
308frame that is local to the corresponding component. Usually,
309if all relative joint coordinates vanish, the local frames
310of all components are parallel to each other, as well as to the
311world frame (this holds as long as a Parts.FixedRotation,
312component is <b>not</b> used). In this \"reference configuration\"
313it is therefore
314alternatively possible to resolve all vectors in the world
315frame, since all frames are parallel to each other.
316This is often very convenient. In order to give some visual
317support in such a situation, in the icon of a World instance
318two axes of the world frame are shown and the labels
319of these axes can be set via parameters.
320</p>
321</HTML>
322"));
323 end World;
324
325 annotation(Documentation(info="<HTML>
326<p>
327Library <b>MultiBody</b> is a <b>free</b> Modelica package providing
3283-dimensional mechanical components to model in a convenient way
329<b>mechanical systems</b>, such as robots, mechanisms, vehicles.
330Typical animations generated with this library are shown
331in the next figure:
332</p>
333<p>
334<img src=\"../../Images/MultiBody/MultiBody.png\">
335</p>
336<p>
337For an introduction, have especially a look at:
338</p>
339<ul>
340<li> <a href=\"Modelica://Modelica.Mechanics.MultiBody.UsersGuide\">MultiBody.UsersGuide</a>
341 discusses the most important aspects how to use this library.</li>
342<li> <a href=\"Modelica://Modelica.Mechanics.MultiBody.Examples\">MultiBody.Examples</a>
343 contains examples that demonstrate the usage of this library.</li>
344</ul>
345
346<p>
347Copyright &copy; 1998-2009, Modelica Association and DLR.
348</p>
349<p>
350<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
351under the terms of the <b>Modelica license</b>, see the license conditions
352and the accompanying <b>disclaimer</b>
353<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a>.</i>
354</p><br>
355</HTML>"));
356 package Visualizers "3-dimensional visual objects used for animation"
357 extends Modelica.Icons.Library;
358 package Advanced "Visualizers that require basic knowledge about Modelica in order to use them"
359 extends Modelica.Icons.Library;
360 model Arrow "Visualizing an arrow with variable size; all data have to be set as modifiers (see info layer)"
361 import SI = Modelica.SIunits;
362 import Modelica.Mechanics.MultiBody.Types;
363 import Modelica.Mechanics.MultiBody.Frames;
364 input Frames.Orientation R=Frames.nullRotation() "Orientation object to rotate the world frame into the arrow frame." annotation(Dialog);
365 input SI.Position r[3]={0,0,0} "Position vector from origin of world frame to origin of arrow frame, resolved in world frame" annotation(Dialog);
366 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);
367 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);
368 input SI.Diameter diameter=world.defaultArrowDiameter "Diameter of arrow line" annotation(Dialog);
369 input Modelica.Mechanics.MultiBody.Types.Color color=Modelica.Mechanics.MultiBody.Types.Defaults.ArrowColor "Color of arrow" annotation(Dialog);
370 input Types.SpecularCoefficient specularCoefficient=world.defaultSpecularCoefficient "Material property describing the reflecting of ambient light (= 0 means, that light is completely absorbed)" annotation(Dialog);
371 protected
372 outer Modelica.Mechanics.MultiBody.World world;
373 SI.Length length=Modelica.Math.Vectors.length(r_head) "Length of arrow";
374 Visualizers.Advanced.Shape arrowLine(length=noEvent(max(0, length - diameter*Types.Defaults.ArrowHeadLengthFraction)), width=diameter, height=diameter, lengthDirection=r_head, widthDirection={0,1,0}, shapeType="cylinder", color=color, specularCoefficient=specularCoefficient, r_shape=r_tail, r=r, R=R) if world.enableAnimation;
375 Visualizers.Advanced.Shape arrowHead(length=noEvent(max(0, min(length, diameter*Types.Defaults.ArrowHeadLengthFraction))), width=noEvent(max(0, diameter*MultiBody.Types.Defaults.ArrowHeadWidthFraction)), height=noEvent(max(0, diameter*MultiBody.Types.Defaults.ArrowHeadWidthFraction)), lengthDirection=r_head, widthDirection={0,1,0}, shapeType="cone", color=color, specularCoefficient=specularCoefficient, r=arrowLine.rvisobj + arrowLine.rxvisobj*arrowLine.length, R=R) if world.enableAnimation;
376 annotation(Documentation(info="<HTML>
377<p>
378Model <b>Arrow</b> defines an arrow that is dynamically
379visualized at the defined location (see variables below).
380</p>
381<IMG SRC=\"../../Images/MultiBody/Visualizers/Arrow.png\" ALT=\"model Visualizers.Advanced.Arrow\">
382<p>
383The variables under heading <b>Parameters</b> below
384are declared as (time varying) <b>input</b> variables.
385If the default equation is not appropriate, a corresponding
386modifier equation has to be provided in the
387model where an <b>Arrow</b> instance is used, e.g., in the form
388</p>
389<pre>
390 Visualizers.Advanced.Arrow arrow(diameter = sin(time));
391</pre>
392
393<p>
394Variable <b>color</b> is an Integer vector with 3 elements,
395{r, g, b}, and specifies the color of the shape.
396{r,g,b} are the \"red\", \"green\" and \"blue\" color parts.
397Note, r g, b are given in the range 0 .. 255.
398The predefined type <b>MultiBody.Types.Color</b> contains
399a menu definition of the colors used in the MultiBody
400library (will be replaced by a color editor).
401</p>
402</HTML>"), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,28},{20,-30}}, lineColor={128,128,128}, fillColor={128,128,128}, fillPattern=FillPattern.Solid),Polygon(points={{20,60},{100,0},{20,-60},{20,60}}, lineColor={128,128,128}, fillColor={128,128,128}, fillPattern=FillPattern.Solid),Text(extent={{-146,124},{142,62}}, textString="%name", lineColor={0,0,255})}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics));
403 end Arrow;
404
405 model DoubleArrow "Visualizing a double arrow with variable size; all data have to be set as modifiers (see info layer)"
406 import SI = Modelica.SIunits;
407 import Modelica.Mechanics.MultiBody.Types;
408 import Modelica.Mechanics.MultiBody.Frames;
409 input Frames.Orientation R=Frames.nullRotation() "Orientation object to rotate the world frame into the arrow frame." annotation(Dialog);
410 input SI.Position r[3]={0,0,0} "Position vector from origin of world frame to origin of arrow frame, resolved in world frame" annotation(Dialog);
411 input SI.Position r_tail[3]={0,0,0} "Position vector from origin of arrow frame to double arrow tail, resolved in arrow frame" annotation(Dialog);
412 input SI.Position r_head[3]={0,0,0} "Position vector from double arrow tail to the head of the double arrow, resolved in arrow frame" annotation(Dialog);
413 input SI.Diameter diameter=world.defaultArrowDiameter "Diameter of arrow line" annotation(Dialog);
414 input Modelica.Mechanics.MultiBody.Types.Color color=Modelica.Mechanics.MultiBody.Types.Defaults.ArrowColor "Color of double arrow" annotation(Dialog);
415 input Types.SpecularCoefficient specularCoefficient=world.defaultSpecularCoefficient "Material property describing the reflecting of ambient light (= 0 means, that light is completely absorbed)" annotation(Dialog);
416 protected
417 outer Modelica.Mechanics.MultiBody.World world;
418 SI.Length length=Modelica.Math.Vectors.length(r_head) "Length of arrow";
419 SI.Length headLength=noEvent(max(0, min(length, diameter*MultiBody.Types.Defaults.ArrowHeadLengthFraction)));
420 SI.Length headWidth=noEvent(max(0, diameter*MultiBody.Types.Defaults.ArrowHeadWidthFraction));
421 Visualizers.Advanced.Shape arrowLine(length=noEvent(max(0, length - 1.5*diameter*MultiBody.Types.Defaults.ArrowHeadLengthFraction)), width=diameter, height=diameter, lengthDirection=r_head, widthDirection={0,1,0}, shapeType="cylinder", color=color, specularCoefficient=specularCoefficient, r_shape=r_tail, r=r, R=R) if world.enableAnimation;
422 Visualizers.Advanced.Shape arrowHead1(length=headLength, width=headWidth, height=headWidth, lengthDirection=r_head, widthDirection={0,1,0}, shapeType="cone", color=color, specularCoefficient=specularCoefficient, r=arrowLine.rvisobj + arrowLine.rxvisobj*arrowLine.length, R=R) if world.enableAnimation;
423 Visualizers.Advanced.Shape arrowHead2(length=headLength, width=headWidth, height=headWidth, lengthDirection=r_head, widthDirection={0,1,0}, shapeType="cone", color=color, specularCoefficient=specularCoefficient, r=arrowLine.rvisobj + arrowLine.rxvisobj*(arrowLine.length + 0.5*arrowHead1.length), R=R) if world.enableAnimation;
424 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,28},{0,-28}}, lineColor={128,128,128}, fillColor={128,128,128}, fillPattern=FillPattern.Solid),Polygon(points={{40,60},{100,0},{40,-60},{40,60}}, lineColor={128,128,128}, fillColor={128,128,128}, fillPattern=FillPattern.Solid),Text(extent={{-146,124},{142,62}}, textString="%name", lineColor={0,0,255}),Polygon(points={{0,60},{60,0},{0,-60},{0,60}}, lineColor={128,128,128}, fillColor={128,128,128}, fillPattern=FillPattern.Solid)}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics), Documentation(info="<HTML>
425<p>
426Model <b>DoubleArrow</b> defines a double arrow that is dynamically
427visualized at the defined location (see variables below).
428</p>
429<IMG SRC=\"../../Images/MultiBody/Visualizers/DoubleArrow.png\" ALT=\"model Visualizers.Advanced.DoubleArrow\">
430<p>
431The variables under heading <b>Parameters</b> below
432are declared as (time varying) <b>input</b> variables.
433If the default equation is not appropriate, a corresponding
434modifier equation has to be provided in the
435model where an <b>Arrow</b> instance is used, e.g., in the form
436</p>
437<pre>
438 Visualizers.Advanced.DoubleArrow doubleArrow(diameter = sin(time));
439</pre>
440<p>
441Variable <b>color</b> is an Integer vector with 3 elements,
442{r, g, b}, and specifies the color of the shape.
443{r,g,b} are the \"red\", \"green\" and \"blue\" color parts.
444Note, r g, b are given in the range 0 .. 255.
445The predefined type <b>MultiBody.Types.Color</b> contains
446a menu definition of the colors used in the MultiBody
447library (will be replaced by a color editor).
448</p>
449</HTML>"));
450 end DoubleArrow;
451
452 model Shape "Different visual shapes with variable size; all data have to be set as modifiers (see info layer)"
453 extends Modelica.Utilities.Internal.PartialModelicaServices.Animation.PartialShape;
454 extends ModelicaServices.Animation.Shape;
455 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Rectangle(extent={{-100,-100},{80,60}}, lineColor={0,0,255}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Polygon(points={{-100,60},{-80,100},{100,100},{80,60},{-100,60}}, lineColor={0,0,255}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Polygon(points={{100,100},{100,-60},{80,-100},{80,60},{100,100}}, lineColor={0,0,255}, fillColor={160,160,164}, fillPattern=FillPattern.Solid),Text(extent={{-100,-100},{80,60}}, lineColor={0,0,0}, textString="%shapeType"),Text(extent={{-132,160},{128,100}}, textString="%name", lineColor={0,0,255})}), Documentation(info="<HTML>
456<p>
457Model <b>Shape</b> defines a visual shape that is
458shown at the location of its reference coordinate system, called
459'object frame' below. All describing variables such
460as size and color can vary dynamically (with the only exception
461of parameter shapeType). The default equations in the
462declarations should be modified by providing appropriate equations.
463Model <b>Shape</b> is usually used as a basic building block to
464implement simpler to use graphical components.
465</p>
466<p>
467The following shapes are supported via
468parameter <b>shapeType</b> (e.g., shapeType=\"box\"):<br>&nbsp;
469</p>
470<IMG SRC=\"../../Images/MultiBody/Shape.png\" ALT=\"model Visualizers.FixedShape\">
471<p>&nbsp;<br>
472The dark blue arrows in the figure above are directed along
473variable <b>lengthDirection</b>. The light blue arrows are directed
474along variable <b>widthDirection</b>. The <b>coordinate systems</b>
475in the figure represent frame_a of the Shape component.
476</p>
477<p>
478Additionally, external shapes are specified as DXF-files
479(only 3-dim.Face is supported). External shapes must be named \"1\", \"2\"
480etc.. The corresponding definitions should be in files \"1.dxf\",
481\"2.dxf\" etc.Since the DXF-files contain color and dimensions for
482the individual faces, the corresponding information in the model
483is currently ignored. The DXF-files must be found either in the current
484directory or in the directory where the Shape instance is stored
485that references the DXF file.
486</p>
487
488<p>
489Via input variable <b>extra</b> additional sizing data is defined
490according to:
491</p>
492<table border=1 cellspacing=0 cellpadding=2>
493<tr><th><b>shapeType</b></th><th>Meaning of variable <b>extra</b></th></tr>
494<tr>
495 <td valign=\"top\">\"cylinder\"</td>
496 <td valign=\"top\">if extra &gt; 0, a black line is included in the
497 cylinder to show the rotation of it.</td>
498</tr>
499<tr>
500 <td valign=\"top\">\"cone\"</td>
501 <td valign=\"top\">extra = diameter-left-side / diameter-right-side, i.e.,<br>
502 extra = 1: cylinder<br>
503 extra = 0: \"real\" cone.</td>
504</tr>
505<tr>
506 <td valign=\"top\">\"pipe\"</td>
507 <td valign=\"top\">extra = outer-diameter / inner-diameter, i.e, <br>
508 extra = 1: cylinder that is completely hollow<br>
509 extra = 0: cylinder without a hole.</td>
510</tr>
511<tr>
512 <td valign=\"top\">\"gearwheel\"</td>
513 <td valign=\"top\">extra is the number of teeth of the gear.</td>
514</tr>
515<tr>
516 <td valign=\"top\">\"spring\"</td>
517 <td valign=\"top\">extra is the number of windings of the spring.
518 Additionally, \"height\" is <b>not</b> the \"height\" but
519 2*coil-width.</td>
520</tr>
521</table>
522
523<p>
524Parameter <b>color</b> is an Integer vector with 3 elements,
525{r, g, b}, and specifies the color of the shape.
526{r,g,b} are the \"red\", \"green\" and \"blue\" color parts.
527Note, r g, b are given in the range 0 .. 255.
528The predefined type <b>MultiBody.Types.Color</b> contains
529a menu definition of the colors used in the MultiBody
530library (will be replaced by a color editor).
531</p>
532
533<p>
534The variables under heading <b>Parameters</b> below
535are declared as (time varying) <b>input</b> variables.
536If the default equation is not appropriate, a corresponding
537modifier equation has to be provided in the
538model where a <b>Shape</b> instance is used, e.g., in the form
539</p>
540<pre>
541 Visualizers.Advanced.Shape shape(length = sin(time));
542</pre>
543</HTML>
544"));
545 end Shape;
546
547 annotation(Documentation(info="<HTML>
548<p>
549Package <b>Visualizers.Advanced</b> contains components to visualize
5503-dimensional shapes with dynamical sizes. None of the components
551has a frame connector. The position and orientation is set via
552modifiers. Basic knowledge of Modelica
553is needed in order to utilize the components of this package.
554These components have also to be used for models,
555where the forces and torques in the frame connector are set via
556equations (in this case, the models of the Visualizers package cannot be used,
557since they all have frame connectors).
558<p>
559<h4>Content</h4>
560<table border=1 cellspacing=0 cellpadding=2>
561 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Arrow\">Arrow</a></td>
562 <td valign=\"top\">Visualizing an arrow where all parts of the arrow can vary dynamically:<br>
563 <IMG SRC=\"../../Images/MultiBody/Visualizers/Arrow.png\" ALT=\"model Visualizers.Advanced.Arrow\">
564 </td>
565 </tr>
566 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.DoubleArrow\">DoubleArrow</a></td>
567 <td valign=\"top\">Visualizing a double arrow where all parts of the arrow can vary dynamically:<br>
568 <IMG SRC=\"../../Images/MultiBody/Visualizers/DoubleArrow.png\" ALT=\"model Visualizers.Advanced.DoubleArrow\">
569 </td>
570 </tr>
571 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape\">Shape</a></td>
572 <td valign=\"top\">Animation shape of a part with dynamically varying sizes.
573 The following shape types are supported:<br>&nbsp;<br>
574 <IMG SRC=\"../../Images/MultiBody/FixedShape.png\" ALT=\"model Visualizers.Advanced.Shape\">
575 </td>
576 </tr>
577</table>
578</HTML>"));
579 end Advanced;
580
581 package Internal "Visualizers that will be replaced by improved versions in the future (don't use them)"
582 extends Modelica.Icons.Library;
583 model Lines "Visualizing a set of lines as cylinders with variable size, e.g., used to display characters (no Frame connector)"
584 import SI = Modelica.SIunits;
585 import Modelica.Mechanics.MultiBody;
586 import Modelica.Mechanics.MultiBody.Types;
587 import Modelica.Mechanics.MultiBody.Frames;
588 import T = Modelica.Mechanics.MultiBody.Frames.TransformationMatrices;
589 input Modelica.Mechanics.MultiBody.Frames.Orientation R=Frames.nullRotation() "Orientation object to rotate the world frame into the object frame" annotation(Dialog);
590 input SI.Position r[3]={0,0,0} "Position vector from origin of world frame to origin of object frame, resolved in world frame" annotation(Dialog);
591 input SI.Position r_lines[3]={0,0,0} "Position vector from origin of object frame to the origin of 'lines' frame, resolved in object frame" annotation(Dialog);
592 input Real n_x[3](each final unit="1")={1,0,0} "Vector in direction of x-axis of 'lines' frame, resolved in object frame" annotation(Dialog);
593 input Real n_y[3](each final unit="1")={0,1,0} "Vector in direction of y-axis of 'lines' frame, resolved in object frame" annotation(Dialog);
594 input SI.Position lines[:,2,2]=zeros(0, 2, 2) "List of start and end points of cylinders resolved in an x-y frame defined by n_x, n_y, e.g., {[0,0;1,1], [0,1;1,0], [2,0; 3,1]}" annotation(Dialog);
595 input SI.Length diameter(min=0)=0.05 "Diameter of the cylinders defined by lines" annotation(Dialog);
596 input Modelica.Mechanics.MultiBody.Types.Color color={0,128,255} "Color of cylinders" annotation(Dialog);
597 input Types.SpecularCoefficient specularCoefficient=0.7 "Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog);
598 protected
599 parameter Integer n=size(lines, 1) "Number of cylinders";
600 T.Orientation R_rel=T.from_nxy(n_x, n_y);
601 T.Orientation R_lines=T.absoluteRotation(R.T, R_rel);
602 Modelica.SIunits.Position r_abs[3]=r + T.resolve1(R.T, r_lines);
603 Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape cylinders[n](each shapeType="cylinder", lengthDirection=array(T.resolve1(R_rel, vector([lines[i,2,:] - lines[i,1,:];0])) for i in 1:n), length=array(Modelica.Math.Vectors.length(lines[i,2,:] - lines[i,1,:]) for i in 1:n), r=array(r_abs + T.resolve1(R_lines, vector([lines[i,1,:];0])) for i in 1:n), each width=diameter, each height=diameter, each widthDirection={0,1,0}, each color=color, each R=R, each specularCoefficient=specularCoefficient);
604 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,100},{100,-100}}, lineColor={128,128,128}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Polygon(points={{-24,-34},{-82,40},{-72,46},{-14,-26},{-24,-34}}, lineColor={0,127,255}, fillColor={0,127,255}, fillPattern=FillPattern.Solid),Polygon(points={{-82,-24},{-20,46},{-10,38},{-72,-32},{-82,-24}}, lineColor={0,127,255}, fillColor={0,127,255}, fillPattern=FillPattern.Solid),Polygon(points={{42,-18},{10,40},{20,48},{50,-6},{42,-18}}, lineColor={0,127,255}, fillColor={0,127,255}, fillPattern=FillPattern.Solid),Polygon(points={{10,-68},{84,48},{96,42},{24,-72},{10,-68}}, lineColor={0,127,255}, fillColor={0,127,255}, fillPattern=FillPattern.Solid),Text(extent={{-140,164},{148,102}}, textString="%name", lineColor={0,0,255})}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics), Documentation(info="<HTML>
605<p>
606With model <b>Lines</b> a set of dynamic lines is defined
607that are located relatively to frame_a. Every line
608is represented by a cylinder. This allows, e.g., to define simple shaped
6093-dimensional characters. Note, if the lines are fixed relatively to frame_a,
610it is more convenient to use model <b>Visualizers.FixedLines</b>.
611An example for dynamic lines is shown in the following figure:<br>&nbsp;
612</p>
613<IMG SRC=\"../../Images/MultiBody/FixedLines.png\" ALT=\"model Visualizers.FixedLines\">
614<p>&nbsp;<br>
615The two letters \"x\" and \"y\" are constructed with 4 lines
616by providing the following data for input variable <b>lines</b>
617</p>
618<pre>
619 lines = {[0, 0; 1, 1],[0, 1; 1, 0],[1.5, -0.5; 2.5, 1],[1.5, 1; 2, 0.25]}
620</pre>
621<p>
622Via vectors <b>n_x</b> and <b>n_y</b> a two-dimensional
623coordinate system is defined. The points defined with variable
624<b>lines</b> are with respect to this coordinate system. For example
625\"[0, 0; 1, 1]\" defines a line that starts at {0,0} and ends at {1,1}.
626The diameter and color of all line cylinders are identical
627and are defined by parameters.
628</p>
629
630</HTML>
631"));
632 end Lines;
633
634 annotation(Documentation(info="<html>
635<p>
636This package contains components to construct 3-dim. fonts
637with \"cylinder\" elements for the animation window.
638This is just a temporary hack until 3-dim. fonts are supported in
639Modelica tools. The components are used to construct the \"x\", \"y\",
640\"z\" labels of coordinates systems in the animation.
641</p>
642</html>"));
643 end Internal;
644
645 annotation(Documentation(info="<HTML>
646<p>
647Package <b>Visualizers</b> contains components to visualize
6483-dimensional shapes. These components are the basis for the
649animation features of the MultiBody library.
650<p>
651<h4>Content</h4>
652<table border=1 cellspacing=0 cellpadding=2>
653 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.FixedShape\">FixedShape</a><br>
654 <a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.FixedShape2\">FixedShape2</a></td>
655 <td valign=\"top\">Animation shape of a part with fixed sizes. FixedShape2 has additionally
656 a frame_b for easier connection to further visual objects.
657 The following shape types are supported:<br>&nbsp;<br>
658 <IMG SRC=\"../../Images/MultiBody/FixedShape.png\" ALT=\"model Visualizers.FixedShape\">
659 </td>
660 </tr>
661 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.FixedFrame\">FixedFrame</a></td>
662 <td valign=\"top\">Visualizing a coordinate system including axes labels with fixed sizes:<br>
663 <IMG SRC=\"../../Images/MultiBody/FixedFrame2.png\"
664 ALT=\"model Visualizers.FixedFrame\">
665 </td>
666 </tr>
667 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.FixedArrow\">FixedArrow</a>,<br>
668<a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.SignalArrow\">SignalArrow</a></td>
669 <td valign=\"top\">Visualizing an arrow. Model \"FixedArrow\" provides
670 a fixed sized arrow, model \"SignalArrow\" provides
671 an arrow with dynamically varying length that is defined
672 by an input signal vector:<br>
673 <IMG SRC=\"../../Images/MultiBody/Visualizers/Arrow.png\" \">
674 </td>
675 </tr>
676<tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced\">Advanced</a></td>
677 <td valign=\"top\"> <b>Package</b> that contains components to visualize
678 3-dimensional shapes where all parts of the shape
679 can vary dynamically. Basic knowledge of Modelica is
680 needed in order to utilize the components of this package.
681 </td>
682 </tr>
683</table>
684<p>
685The colors of the visualization components are declared with
686the predefined type <b>MultiBody.Types.Color</b>.
687This is a vector with 3 elements,
688{r, g, b}, and specifies the color of the shape.
689{r,g,b} are the \"red\", \"green\" and \"blue\" color parts.
690Note, r g, b are given as Integer[3] in the ranges 0 .. 255,
691respectively.
692</p>
693</HTML>"));
694 end Visualizers;
695
696 package Types "Constants and types with choices, especially to build menus"
697 extends Modelica.Icons.Library;
698 type Axis= Modelica.Icons.TypeReal[3](each final unit="1") "Axis vector with choices for menus" annotation(preferedView="text", Evaluate=true, choices(choice={1,0,0} "{1,0,0} \"x axis\"", choice={0,1,0} "{0,1,0} \"y axis\"", choice={0,0,1} "{0,0,1} \"z axis\"", choice={-1,0,0} "{-1,0,0} \"negative x axis\"", choice={0,-1,0} "{0,-1,0} \"negative y axis\"", choice={0,0,-1} "{0,0,-1} \"negative z axis\""), Documentation(info="<html>
699</html>"));
700 type AxisLabel= Modelica.Icons.TypeString "Label of axis with choices for menus" annotation(preferedView="text", choices(choice="x" "x", choice="y" "y", choice="z" "z"));
701 type RotationSequence= Modelica.Icons.TypeInteger[3](min={1,1,1}, max={3,3,3}) "Sequence of planar frame rotations with choices for menus" annotation(preferedView="text", Evaluate=true, choices(choice={1,2,3} "{1,2,3} \"Cardan/Tait-Bryan angles\"", choice={3,1,3} "{3,1,3} \"Euler angles\"", choice={3,2,1} "{3,2,1}"));
702 type Color= Modelica.Icons.TypeInteger[3](each min=0, each max=255) "RGB representation of color (will be improved with a color editor)" annotation(Dialog(colorSelector), choices(choice={0,0,0} "{0,0,0} \"black\"", choice={155,0,0} "{155,0,0} \"dark red\"", choice={255,0,0} "{255,0,0 } \"red\"", choice={255,65,65} "{255,65,65} \"light red\"", choice={0,128,0} "{0,128,0} \"dark green\"", choice={0,180,0} "{0,180,0} \"green\"", choice={0,230,0} "{0,230,0} \"light green\"", choice={0,0,200} "{0,0,200} \"dark blue\"", choice={0,0,255} "{0,0,255} \"blue\"", choice={0,128,255} "{0,128,255} \"light blue\"", choice={255,255,0} "{255,255,0} \"yellow\"", choice={255,0,255} "{255,0,255} \"pink\"", choice={100,100,100} "{100,100,100} \"dark grey\"", choice={155,155,155} "{155,155,155} \"grey\"", choice={255,255,255} "{255,255,255} \"white\""), Documentation(info="<html>
703<p>
704Type <b>Color</b> is an Integer vector with 3 elements,
705{r, g, b}, and specifies the color of a shape.
706{r,g,b} are the \"red\", \"green\" and \"blue\" color parts.
707Note, r g, b are given in the range 0 .. 255.
708</p>
709</html>"));
710 type SpecularCoefficient= Modelica.Icons.TypeReal "Reflection of ambient light (= 0: light is completely absorbed)" annotation(min=0, choices(choice=0 "\"0.0 (dull)\"", choice=0.7 "\"0.7 (medium)\"", choice=1 "\"1.0 (glossy)\""), Documentation(info="<html>
711<p>
712Type <b>SpecularCoefficient</b> defines the reflection of
713ambient light on shape surfaces. If value = 0, the light
714is completely absorbed. Often, 0.7 is a reasonable value.
715It might be that from some viewing directions, a body is no
716longer visible, if the SpecularCoefficient value is too high.
717In the following image, the different values of SpecularCoefficient
718are shown for a cylinder:
719</p>
720
721<p>
722<img src=\"../Images/MultiBody/Visualizers/SpecularCoefficient.png\"
723</p>
724</html>"));
725 type ShapeType= Modelica.Icons.TypeString "Type of shape (box, sphere, cylinder, pipecylinder, cone, pipe, beam, gearwheel, spring, dxf-file)" annotation(choices(choice="box" "\"box\"", choice="sphere" "\"sphere\"", choice="cylinder" "\"cylinder\"", choice="pipecylinder" "\"pipecylinder\"", choice="cone" "\"cone\"", choice="pipe" "\"pipe\"", choice="beam" "\"beam\"", choice="gearwheel" "\"gearwheel\"", choice="spring" "\"spring\"", choice="1" "File \"1.dxf\" in current directory", choice="2" "File \"2.dxf\" in current directory", choice="3" "File \"3.dxf\" in current directory", choice="4" "File \"4.dxf\" in current directory", choice="5" "File \"5.dxf\" in current directory", choice="6" "File \"6.dxf\" in current directory", choice="7" "File \"7.dxf\" in current directory", choice="8" "File \"8.dxf\" in current directory", choice="9" "File \"9.dxf\" in current directory"), Documentation(info="<html>
726<p>
727Type <b>ShapeType</b> is used to define the shape of the
728visual object as parameter String. Usually, \"shapeType\" is used
729as instance name. The following
730values for shapeType are possible, e.g., shapeType=\"box\":
731</p>
732<IMG SRC=\"../Images/MultiBody/Shape.png\" ALT=\"model Visualizers.FixedShape\">
733<p>&nbsp;<br>
734The dark blue arrows in the figure above are directed along
735variable <b>lengthDirection</b>. The light blue arrows are directed
736along variable <b>widthDirection</b>. The <b>coordinate systems</b>
737in the figure represent frame_a of the Shape component.
738</p>
739<p>
740Additionally, external shapes are specified as DXF-files
741(only 3-dim.Face is supported). External shapes must be named \"1\", \"2\"
742etc.. The corresponding definitions should be in files \"1.dxf\",
743\"2.dxf\" etc.Since the DXF-files contain color and dimensions for
744the individual faces, the corresponding information in the model
745is currently ignored. The DXF-files must be found either in the current
746directory or in the directory where the Shape instance is stored
747that references the DXF file.
748</p>
749</html>"));
750 type ShapeExtra= Modelica.Icons.TypeReal "Reflection of ambient light (= 0: light is completely absorbed)" annotation(min=0, Documentation(info="<html>
751<p>
752This type is used in shapes of visual objects to define
753extra data depending on the shape type. Usually, input
754variable <b>extra</b> is used as instance name:
755</p>
756<table border=1 cellspacing=0 cellpadding=2>
757<tr><th><b>shapeType</b></th><th>Meaning of variable <b>extra</b></th></tr>
758<tr>
759 <td valign=\"top\">\"cylinder\"</td>
760 <td valign=\"top\">if extra &gt; 0, a black line is included in the
761 cylinder to show the rotation of it.</td>
762</tr>
763<tr>
764 <td valign=\"top\">\"cone\"</td>
765 <td valign=\"top\">extra = diameter-left-side / diameter-right-side, i.e.,<br>
766 extra = 1: cylinder<br>
767 extra = 0: \"real\" cone.</td>
768</tr>
769<tr>
770 <td valign=\"top\">\"pipe\"</td>
771 <td valign=\"top\">extra = outer-diameter / inner-diameter, i.e, <br>
772 extra = 1: cylinder that is completely hollow<br>
773 extra = 0: cylinder without a hole.</td>
774</tr>
775<tr>
776 <td valign=\"top\">\"gearwheel\"</td>
777 <td valign=\"top\">extra is the number of teeth of the gear.</td>
778</tr>
779<tr>
780 <td valign=\"top\">\"spring\"</td>
781 <td valign=\"top\">extra is the number of windings of the spring.
782 Additionally, \"height\" is <b>not</b> the \"height\" but
783 2*coil-width.</td>
784</tr>
785</table>
786</html>"));
787 type RotationTypes= enumeration(RotationAxis "Rotating frame_a around an angle with a fixed axis", TwoAxesVectors "Resolve two vectors of frame_b in frame_a", PlanarRotationSequence "Planar rotation sequence") "Enumeration defining in which way the fixed orientation of frame_b with respect to frame_a is specified" annotation(Evaluate=true, Documentation(info="<html>
788<table border=1 cellspacing=0 cellpadding=2>
789<tr><th><b>Types.RotationTypes.</b></th><th><b>Meaning</b></th></tr>
790<tr><td valign=\"top\">RotationAxis</td>
791 <td valign=\"top\">frame_b is defined by rotating the coordinate system along
792 an axis fixed in frame_a and with a fixed angle.</td></tr>
793
794<tr><td valign=\"top\">TwoAxesVectors</td>
795 <td valign=\"top\">frame_b is defined by resolving two vectors of frame_b in frame_a.</td></tr>
796
797<tr><td valign=\"top\">PlanarRotationSequence</td>
798 <td valign=\"top\">frame_b is defined by rotating the coordinate system along
799 3 consecutive axes vectors with fixed rotation angles
800 (e.g. Cardan or Euler angle sequence rotation).</td></tr>
801</table>
802</html>"));
803 type GravityTypes= enumeration(NoGravity "No gravity field", UniformGravity "Uniform gravity field", PointGravity "Point gravity field") "Enumeration defining the type of the gravity field" annotation(Documentation(info="<html>
804<table border=1 cellspacing=0 cellpadding=2>
805<tr><th><b>Types.GravityTypes.</b></th><th><b>Meaning</b></th></tr>
806<tr><td valign=\"top\">NoGravity</td>
807 <td valign=\"top\">No gravity field</td></tr>
808
809<tr><td valign=\"top\">UniformGravity</td>
810 <td valign=\"top\">Gravity field is described by a vector of constant gravity acceleration</td></tr>
811
812<tr><td valign=\"top\">PointGravity</td>
813 <td valign=\"top\">Central gravity field. The gravity acceleration vector is directed to
814 the field center and the gravity is proportional to 1/r^2, where
815 r is the distance to the field center.</td></tr>
816</table>
817</html>"));
818 package Defaults "Default settings of the MultiBody library via constants"
819 extends Modelica.Icons.Library;
820 constant Types.Color BodyColor={0,128,255} "Default color for body shapes that have mass (light blue)";
821 constant Types.Color RodColor={155,155,155} "Default color for massless rod shapes (grey)";
822 constant Types.Color JointColor={255,0,0} "Default color for elementary joints (red)";
823 constant Types.Color ForceColor={0,128,0} "Default color for force arrow (dark green)";
824 constant Types.Color TorqueColor={0,128,0} "Default color for torque arrow (dark green)";
825 constant Types.Color SpringColor={0,0,255} "Default color for a spring (blue)";
826 constant Types.Color SensorColor={255,255,0} "Default color for sensors (yellow)";
827 constant Types.Color FrameColor={0,0,0} "Default color for frame axes and labels (black)";
828 constant Types.Color ArrowColor={0,0,255} "Default color for arrows and double arrows (blue)";
829 constant Real FrameHeadLengthFraction=5.0 "Frame arrow head length / arrow diameter";
830 constant Real FrameHeadWidthFraction=3.0 "Frame arrow head width / arrow diameter";
831 constant Real FrameLabelHeightFraction=3.0 "Height of frame label / arrow diameter";
832 constant Real ArrowHeadLengthFraction=4.0 "Arrow head length / arrow diameter";
833 constant Real ArrowHeadWidthFraction=3.0 "Arrow head width / arrow diameter";
834 constant SI.Diameter BodyCylinderDiameterFraction=3 "Default for body cylinder diameter as a fraction of body sphere diameter";
835 constant Real JointRodDiameterFraction=2 "Default for rod diameter as a fraction of joint sphere diameter attached to rod";
836 annotation(Documentation(info="<html>
837<p>
838This package contains constants used as default setting
839in the MultiBody library.
840</p>
841</html>"));
842 end Defaults;
843
844 annotation(Documentation(info="<HTML>
845<p>
846In this package <b>types</b> and <b>constants</b> are defined that are used in the
847MultiBody library. The types have additional annotation choices
848definitions that define the menus to be built up in the graphical
849user interface when the type is used as parameter in a declaration.
850</p>
851</HTML>"));
852 end Types;
853
854 package Parts "Rigid components such as bodies with mass and inertia and massless rods"
855 import SI = Modelica.SIunits;
856 extends Modelica.Icons.Library;
857 model FixedTranslation "Fixed translation of frame_b with respect to frame_a"
858 import SI = Modelica.SIunits;
859 import Modelica.Mechanics.MultiBody.Types;
860 Interfaces.Frame_a frame_a "Coordinate system fixed to the component with one cut-force and cut-torque" annotation(Placement(transformation(extent={{-116,-16},{-84,16}}, rotation=0)));
861 Interfaces.Frame_b frame_b "Coordinate system fixed to the component with one cut-force and cut-torque" annotation(Placement(transformation(extent={{84,-16},{116,16}}, rotation=0)));
862 parameter Boolean animation=true "= true, if animation shall be enabled";
863 parameter SI.Position r[3](start={0,0,0}) "Vector from frame_a to frame_b resolved in frame_a";
864 parameter Types.ShapeType shapeType="cylinder" " Type of shape" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
865 parameter SI.Position r_shape[3]={0,0,0} " Vector from frame_a to shape origin, resolved in frame_a" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
866 parameter Types.Axis lengthDirection=r - r_shape " Vector in length direction of shape, resolved in frame_a" annotation(Evaluate=true, Dialog(tab="Animation", group="if animation = true", enable=animation));
867 parameter Types.Axis widthDirection={0,1,0} " Vector in width direction of shape, resolved in frame_a" annotation(Evaluate=true, Dialog(tab="Animation", group="if animation = true", enable=animation));
868 parameter SI.Length length=Modelica.Math.Vectors.length(r - r_shape) " Length of shape" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
869 parameter SI.Distance width=length/world.defaultWidthFraction " Width of shape" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
870 parameter SI.Distance height=width " Height of shape." annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
871 parameter Types.ShapeExtra extra=0.0 " Additional parameter depending on shapeType (see docu of Visualizers.Advanced.Shape)." annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
872 input Types.Color color=Modelica.Mechanics.MultiBody.Types.Defaults.RodColor " Color of shape" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
873 input Types.SpecularCoefficient specularCoefficient=world.defaultSpecularCoefficient "Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
874 protected
875 outer Modelica.Mechanics.MultiBody.World world;
876 Visualizers.Advanced.Shape shape(shapeType=shapeType, color=color, specularCoefficient=specularCoefficient, r_shape=r_shape, lengthDirection=lengthDirection, widthDirection=widthDirection, length=length, width=width, height=height, extra=extra, r=frame_a.r_0, R=frame_a.R) if world.enableAnimation and animation;
877 equation
878 Connections.branch(frame_a.R, frame_b.R);
879 assert(cardinality(frame_a) > 0 or cardinality(frame_b) > 0, "Neither connector frame_a nor frame_b of FixedTranslation object is connected");
880 frame_b.r_0=frame_a.r_0 + Frames.resolve1(frame_a.R, r);
881 frame_b.R=frame_a.R;
882 zeros(3)=frame_a.f + frame_b.f;
883 zeros(3)=frame_a.t + frame_b.t + cross(r, frame_b.f);
884 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Rectangle(extent={{-99,5},{101,-5}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Text(extent={{-131,101},{129,41}}, textString="%name", lineColor={0,0,255}),Text(extent={{127,-72},{-133,-22}}, lineColor={0,0,0}, textString="%=r"),Text(extent={{-89,38},{-53,13}}, lineColor={128,128,128}, textString="a"),Text(extent={{57,39},{93,14}}, lineColor={128,128,128}, textString="b")}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Rectangle(extent={{-100,5},{100,-5}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Line(points={{-95,20},{-58,20}}, color={128,128,128}, arrow={Arrow.None,Arrow.Filled}),Line(points={{-94,18},{-94,50}}, color={128,128,128}, arrow={Arrow.None,Arrow.Filled}),Text(extent={{-72,35},{-58,24}}, lineColor={128,128,128}, textString="x"),Text(extent={{-113,57},{-98,45}}, lineColor={128,128,128}, textString="y"),Line(points={{-100,-4},{-100,-69}}, color={128,128,128}),Line(points={{-100,-63},{90,-63}}, color={128,128,128}),Text(extent={{-22,-39},{16,-63}}, lineColor={128,128,128}, textString="r"),Polygon(points={{88,-59},{88,-68},{100,-63},{88,-59}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Line(points={{100,-3},{100,-68}}, color={128,128,128}),Line(points={{69,20},{106,20}}, color={128,128,128}, arrow={Arrow.None,Arrow.Filled}),Line(points={{70,18},{70,50}}, color={128,128,128}, arrow={Arrow.None,Arrow.Filled}),Text(extent={{92,35},{106,24}}, lineColor={128,128,128}, textString="x"),Text(extent={{51,57},{66,45}}, lineColor={128,128,128}, textString="y")}), Documentation(info="<HTML>
885<p>
886Component for a <b>fixed translation</b> of frame_b with respect
887to frame_a, i.e., the relationship between connectors frame_a and frame_b
888remains constant and frame_a is always <b>parallel</b> to frame_b.
889</p>
890<p>
891By default, this component is visualized by a cylinder connecting
892frame_a and frame_b, as shown in the figure below. Note, that the
893two visualized frames are not part of the component animation and that
894the animation may be switched off via parameter animation = <b>false</b>.
895</p>
896<IMG SRC=\"../../Images/MultiBody/FixedTranslation.png\" ALT=\"Parts.FixedTranslation\">
897</HTML>"));
898 end FixedTranslation;
899
900 model FixedRotation "Fixed translation followed by a fixed rotation of frame_b with respect to frame_a"
901 import Modelica.Mechanics.MultiBody.Frames;
902 import Modelica.Mechanics.MultiBody.Types;
903 import SI = Modelica.SIunits;
904 import Cv = Modelica.SIunits.Conversions;
905 Interfaces.Frame_a frame_a "Coordinate system fixed to the component with one cut-force and cut-torque" annotation(Placement(transformation(extent={{-116,-16},{-84,16}}, rotation=0)));
906 Interfaces.Frame_b frame_b "Coordinate system fixed to the component with one cut-force and cut-torque" annotation(Placement(transformation(extent={{84,-16},{116,16}}, rotation=0)));
907 parameter Boolean animation=true "= true, if animation shall be enabled";
908 parameter SI.Position r[3]={0,0,0} "Vector from frame_a to frame_b resolved in frame_a";
909 parameter Modelica.Mechanics.MultiBody.Types.RotationTypes rotationType=Modelica.Mechanics.MultiBody.Types.RotationTypes.RotationAxis "Type of rotation description" annotation(Evaluate=true);
910 parameter Types.Axis n={1,0,0} " Axis of rotation in frame_a (= same as in frame_b)" annotation(Evaluate=true, Dialog(group="if rotationType = RotationAxis", enable=rotationType == Modelica.Mechanics.MultiBody.Types.RotationTypes.RotationAxis));
911 parameter Cv.NonSIunits.Angle_deg angle=0 " Angle to rotate frame_a around axis n into frame_b" annotation(Dialog(group="if rotationType = RotationAxis", enable=rotationType == Modelica.Mechanics.MultiBody.Types.RotationTypes.RotationAxis));
912 parameter Types.Axis n_x={1,0,0} " Vector along x-axis of frame_b resolved in frame_a" annotation(Evaluate=true, Dialog(group="if rotationType = TwoAxesVectors", enable=rotationType == Types.RotationTypes.TwoAxesVectors));
913 parameter Types.Axis n_y={0,1,0} " Vector along y-axis of frame_b resolved in frame_a" annotation(Evaluate=true, Dialog(group="if rotationType = TwoAxesVectors", enable=rotationType == Types.RotationTypes.TwoAxesVectors));
914 parameter Types.RotationSequence sequence(min={1,1,1}, max={3,3,3})={1,2,3} " Sequence of rotations" annotation(Evaluate=true, Dialog(group="if rotationType = PlanarRotationSequence", enable=rotationType == Types.RotationTypes.PlanarRotationSequence));
915 parameter Cv.NonSIunits.Angle_deg angles[3]={0,0,0} " Rotation angles around the axes defined in 'sequence'" annotation(Dialog(group="if rotationType = PlanarRotationSequence", enable=rotationType == Types.RotationTypes.PlanarRotationSequence));
916 parameter Types.ShapeType shapeType="cylinder" " Type of shape" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
917 parameter SI.Position r_shape[3]={0,0,0} " Vector from frame_a to shape origin, resolved in frame_a" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
918 parameter Types.Axis lengthDirection=r - r_shape " Vector in length direction of shape, resolved in frame_a" annotation(Evaluate=true, Dialog(tab="Animation", group="if animation = true", enable=animation));
919 parameter Types.Axis widthDirection={0,1,0} " Vector in width direction of shape, resolved in frame_a" annotation(Evaluate=true, Dialog(tab="Animation", group="if animation = true", enable=animation));
920 parameter SI.Length length=Modelica.Math.Vectors.length(r - r_shape) " Length of shape" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
921 parameter SI.Distance width=length/world.defaultWidthFraction " Width of shape" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
922 parameter SI.Distance height=width " Height of shape." annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
923 parameter Types.ShapeExtra extra=0.0 " Additional parameter depending on shapeType (see docu of Visualizers.Advanced.Shape)." annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
924 input Types.Color color=Modelica.Mechanics.MultiBody.Types.Defaults.RodColor " Color of shape" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
925 input Types.SpecularCoefficient specularCoefficient=world.defaultSpecularCoefficient "Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
926 final parameter Frames.Orientation R_rel=if rotationType == 1 then Frames.planarRotation(Modelica.Math.Vectors.normalize(n), Cv.from_deg(angle), 0) else if rotationType == 2 then Frames.from_nxy(n_x, n_y) else Frames.axesRotations(sequence, Cv.from_deg(angles), zeros(3)) "Fixed rotation object from frame_a to frame_b";
927 protected
928 outer Modelica.Mechanics.MultiBody.World world;
929 parameter Frames.Orientation R_rel_inv=Frames.from_T(transpose(R_rel.T), zeros(3)) "Inverse of R_rel (rotate from frame_b to frame_a)";
930 Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape shape(shapeType=shapeType, color=color, specularCoefficient=specularCoefficient, r_shape=r_shape, lengthDirection=lengthDirection, widthDirection=widthDirection, length=length, width=width, height=height, extra=extra, r=frame_a.r_0, R=frame_a.R) if world.enableAnimation and animation;
931 equation
932 Connections.branch(frame_a.R, frame_b.R);
933 assert(cardinality(frame_a) > 0 or cardinality(frame_b) > 0, "Neither connector frame_a nor frame_b of FixedRotation object is connected");
934 frame_b.r_0=frame_a.r_0 + Frames.resolve1(frame_a.R, r);
935 if rooted(frame_a.R) then
936 frame_b.R=Frames.absoluteRotation(frame_a.R, R_rel);
937 zeros(3)=frame_a.f + Frames.resolve1(R_rel, frame_b.f);
938 zeros(3)=frame_a.t + Frames.resolve1(R_rel, frame_b.t) - cross(r, frame_a.f);
939 else
940 frame_a.R=Frames.absoluteRotation(frame_b.R, R_rel_inv);
941 zeros(3)=frame_b.f + Frames.resolve1(R_rel_inv, frame_a.f);
942 zeros(3)=frame_b.t + Frames.resolve1(R_rel_inv, frame_a.t) + cross(Frames.resolve1(R_rel_inv, r), frame_b.f);
943 end if;
944 annotation(Documentation(info="<HTML>
945<p>
946Component for a <b>fixed translation</b> and <b>fixed rotation</b> of frame_b with respect
947to frame_a, i.e., the relationship between connectors frame_a and frame_b
948remains constant. There are several possibilities to define the
949orientation of frame_b with respect to frame_a:
950</p>
951<ul>
952<li><b>Planar rotation</b> along axis 'n' (that is fixed and resolved
953 in frame_a) with a fixed angle 'angle'.</li>
954<li><b>Vectors n_x</b> and <b>n_y</b> that are directed along the corresponding axes
955 direction of frame_b and are resolved in frame_a (if n_y is not
956 orthogonal to n_x, the y-axis of frame_b is selected such that it is
957 orthogonal to n_x and in the plane of n_x and n_y).</li>
958<li><b>Sequence</b> of <b>three planar axes rotations</b>.
959 For example, \"sequence = {1,2,3}\" and \"angles = {90, 45, -90}\"
960 means to rotate frame_a around the x axis with 90 degrees, around the new
961 y axis with 45 degrees and around the new z axis around -90 degrees to
962 arrive at frame_b. Note, that sequence={1,2,3}
963 is the Cardan angle sequence and sequence = {3,1,3} is the Euler angle
964 sequence.</li>
965</ul>
966<p>
967By default, this component is visualized by a cylinder connecting
968frame_a and frame_b, as shown in the figure below. In this figure
969frame_b is rotated along the z-axis of frame_a with 60 degree. Note, that the
970two visualized frames are not part of the component animation and that
971the animation may be switched off via parameter animation = <b>false</b>.
972</p>
973<IMG SRC=\"../../Images/MultiBody/FixedRotation.png\" ALT=\"Parts.FixedRotation\">
974</HTML>", revisions="<HTML><p><b>Release Notes:</b></p>
975<ul>
976 <li><i>July 28, 2003</i><br>
977 Bug fixed: if rotationType = PlanarRotationSequence, then 'angles'
978 was used with unit [rad] instead of [deg].</li>
979</ul>
980</HTML>"), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Text(extent={{-136,79},{132,139}}, textString="%name", lineColor={0,0,255}),Rectangle(extent={{-100,5},{100,-4}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Line(points={{80,20},{129,50}}, color={0,0,0}),Line(points={{80,20},{57,59}}, color={0,0,0}),Polygon(points={{144,60},{117,59},{132,37},{144,60}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Polygon(points={{43,80},{46,50},{68,65},{43,80}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Text(extent={{-144,-52},{143,-89}}, lineColor={0,0,0}, textString="r=%r"),Text(extent={{-117,51},{-81,26}}, lineColor={128,128,128}, textString="a"),Text(extent={{84,-24},{120,-49}}, lineColor={128,128,128}, textString="b")}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Line(points={{-100,-1},{-100,-66}}, color={128,128,128}),Line(points={{100,0},{100,-65}}, color={128,128,128}),Line(points={{-100,-60},{89,-60}}, color={128,128,128}),Text(extent={{-22,-36},{16,-60}}, lineColor={128,128,128}, textString="r"),Rectangle(extent={{-100,5},{100,-5}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Line(points={{69,29},{97,45}}, color={128,128,128}, arrow={Arrow.None,Arrow.Filled}),Line(points={{70,27},{55,54}}, color={128,128,128}, arrow={Arrow.None,Arrow.Filled}),Text(extent={{95,42},{109,31}}, lineColor={128,128,128}, textString="x"),Text(extent={{42,70},{57,58}}, lineColor={128,128,128}, textString="y"),Line(points={{-95,22},{-58,22}}, color={128,128,128}, arrow={Arrow.None,Arrow.Filled}),Line(points={{-94,20},{-94,52}}, color={128,128,128}, arrow={Arrow.None,Arrow.Filled}),Text(extent={{-72,37},{-58,26}}, lineColor={128,128,128}, textString="x"),Text(extent={{-113,59},{-98,47}}, lineColor={128,128,128}, textString="y"),Polygon(points={{88,-56},{88,-65},{100,-60},{88,-56}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid)}));
981 end FixedRotation;
982
983 model Body "Rigid body with mass, inertia tensor and one frame connector (12 potential states)"
984 import SI = Modelica.SIunits;
985 import C = Modelica.Constants;
986 import Modelica.Math.*;
987 import Modelica.Mechanics.MultiBody.Types;
988 import Modelica.Mechanics.MultiBody.Frames;
989 Interfaces.Frame_a frame_a "Coordinate system fixed at body" annotation(Placement(transformation(extent={{-116,-16},{-84,16}}, rotation=0)));
990 parameter Boolean animation=true "= true, if animation shall be enabled (show cylinder and sphere)";
991 parameter SI.Position r_CM[3](start={0,0,0}) "Vector from frame_a to center of mass, resolved in frame_a";
992 parameter SI.Mass m(min=0, start=1) "Mass of rigid body";
993 parameter SI.Inertia I_11(min=0)=0.001 " (1,1) element of inertia tensor" annotation(Dialog(group="Inertia tensor (resolved in center of mass, parallel to frame_a)"));
994 parameter SI.Inertia I_22(min=0)=0.001 " (2,2) element of inertia tensor" annotation(Dialog(group="Inertia tensor (resolved in center of mass, parallel to frame_a)"));
995 parameter SI.Inertia I_33(min=0)=0.001 " (3,3) element of inertia tensor" annotation(Dialog(group="Inertia tensor (resolved in center of mass, parallel to frame_a)"));
996 parameter SI.Inertia I_21(min=-C.inf)=0 " (2,1) element of inertia tensor" annotation(Dialog(group="Inertia tensor (resolved in center of mass, parallel to frame_a)"));
997 parameter SI.Inertia I_31(min=-C.inf)=0 " (3,1) element of inertia tensor" annotation(Dialog(group="Inertia tensor (resolved in center of mass, parallel to frame_a)"));
998 parameter SI.Inertia I_32(min=-C.inf)=0 " (3,2) element of inertia tensor" annotation(Dialog(group="Inertia tensor (resolved in center of mass, parallel to frame_a)"));
999 SI.Position r_0[3](start={0,0,0}, stateSelect=if enforceStates then StateSelect.always else StateSelect.avoid) "Position vector from origin of world frame to origin of frame_a" annotation(Dialog(tab="Initialization", __Dymola_initialDialog=true));
1000 SI.Velocity v_0[3](start={0,0,0}, stateSelect=if enforceStates then StateSelect.always else StateSelect.avoid) "Absolute velocity of frame_a, resolved in world frame (= der(r_0))" annotation(Dialog(tab="Initialization", __Dymola_initialDialog=true));
1001 SI.Acceleration a_0[3](start={0,0,0}) "Absolute acceleration of frame_a resolved in world frame (= der(v_0))" annotation(Dialog(tab="Initialization", __Dymola_initialDialog=true));
1002 parameter Boolean angles_fixed=false "= true, if angles_start are used as initial values, else as guess values" annotation(Evaluate=true, choices(__Dymola_checkBox=true), Dialog(tab="Initialization"));
1003 parameter SI.Angle angles_start[3]={0,0,0} "Initial values of angles to rotate frame_a around 'sequence_start' axes into frame_b" annotation(Dialog(tab="Initialization"));
1004 parameter Types.RotationSequence sequence_start={1,2,3} "Sequence of rotations to rotate frame_a into frame_b at initial time" annotation(Evaluate=true, Dialog(tab="Initialization"));
1005 parameter Boolean w_0_fixed=false "= true, if w_0_start are used as initial values, else as guess values" annotation(Evaluate=true, choices(__Dymola_checkBox=true), Dialog(tab="Initialization"));
1006 parameter SI.AngularVelocity w_0_start[3]={0,0,0} "Initial or guess values of angular velocity of frame_a resolved in world frame" annotation(Dialog(tab="Initialization"));
1007 parameter Boolean z_0_fixed=false "= true, if z_0_start are used as initial values, else as guess values" annotation(Evaluate=true, choices(__Dymola_checkBox=true), Dialog(tab="Initialization"));
1008 parameter SI.AngularAcceleration z_0_start[3]={0,0,0} "Initial values of angular acceleration z_0 = der(w_0)" annotation(Dialog(tab="Initialization"));
1009 parameter SI.Diameter sphereDiameter=world.defaultBodyDiameter "Diameter of sphere" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
1010 input Types.Color sphereColor=Modelica.Mechanics.MultiBody.Types.Defaults.BodyColor "Color of sphere" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
1011 parameter SI.Diameter cylinderDiameter=sphereDiameter/Types.Defaults.BodyCylinderDiameterFraction "Diameter of cylinder" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
1012 input Types.Color cylinderColor=sphereColor "Color of cylinder" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
1013 input Types.SpecularCoefficient specularCoefficient=world.defaultSpecularCoefficient "Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog(tab="Animation", group="if animation = true", enable=animation));
1014 parameter Boolean enforceStates=false " = true, if absolute variables of body object shall be used as states (StateSelect.always)" annotation(Evaluate=true, Dialog(tab="Advanced"));
1015 parameter Boolean useQuaternions=true " = true, if quaternions shall be used as potential states otherwise use 3 angles as potential states" annotation(Evaluate=true, Dialog(tab="Advanced"));
1016 parameter Types.RotationSequence sequence_angleStates={1,2,3} " Sequence of rotations to rotate world frame into frame_a around the 3 angles used as potential states" annotation(Evaluate=true, Dialog(tab="Advanced", enable=not useQuaternions));
1017 final parameter SI.Inertia I[3,3]=[I_11,I_21,I_31;I_21,I_22,I_32;I_31,I_32,I_33] "inertia tensor";
1018 final parameter Frames.Orientation R_start=Modelica.Mechanics.MultiBody.Frames.axesRotations(sequence_start, angles_start, zeros(3)) "Orientation object from world frame to frame_a at initial time";
1019 final parameter SI.AngularAcceleration z_a_start[3]=Frames.resolve2(R_start, z_0_start) "Initial values of angular acceleration z_a = der(w_a), i.e., time derivative of angular velocity resolved in frame_a";
1020 SI.AngularVelocity w_a[3](start=Frames.resolve2(R_start, w_0_start), fixed=fill(w_0_fixed, 3), stateSelect=if enforceStates then if useQuaternions then StateSelect.always else StateSelect.never else StateSelect.avoid) "Absolute angular velocity of frame_a resolved in frame_a";
1021 SI.AngularAcceleration z_a[3](start=Frames.resolve2(R_start, z_0_start), fixed=fill(z_0_fixed, 3)) "Absolute angular acceleration of frame_a resolved in frame_a";
1022 SI.Acceleration g_0[3] "Gravity acceleration resolved in world frame";
1023 protected
1024 outer Modelica.Mechanics.MultiBody.World world;
1025 parameter Frames.Quaternions.Orientation Q_start=Frames.to_Q(R_start) "Quaternion orientation object from world frame to frame_a at initial time";
1026 Frames.Quaternions.Orientation Q(start=Q_start, stateSelect=if enforceStates then if useQuaternions then StateSelect.prefer else StateSelect.never else StateSelect.avoid) "Quaternion orientation object from world frame to frame_a (dummy value, if quaternions are not used as states)";
1027 parameter SI.Angle phi_start[3]=if sequence_start[1] == sequence_angleStates[1] and sequence_start[2] == sequence_angleStates[2] and sequence_start[3] == sequence_angleStates[3] then angles_start else Frames.axesRotationsAngles(R_start, sequence_angleStates) "Potential angle states at initial time";
1028 SI.Angle phi[3](start=phi_start, stateSelect=if enforceStates then if useQuaternions then StateSelect.never else StateSelect.always else StateSelect.avoid) "Dummy or 3 angles to rotate world frame into frame_a of body";
1029 SI.AngularVelocity phi_d[3](stateSelect=if enforceStates then if useQuaternions then StateSelect.never else StateSelect.always else StateSelect.avoid) "= der(phi)";
1030 SI.AngularAcceleration phi_dd[3] "= der(phi_d)";
1031 Visualizers.Advanced.Shape cylinder(shapeType="cylinder", color=cylinderColor, specularCoefficient=specularCoefficient, length=if Modelica.Math.Vectors.length(r_CM) > sphereDiameter/2 then Modelica.Math.Vectors.length(r_CM) - (if cylinderDiameter > 1.1*sphereDiameter then sphereDiameter/2 else 0) else 0, width=cylinderDiameter, height=cylinderDiameter, lengthDirection=r_CM, widthDirection={0,1,0}, r=frame_a.r_0, R=frame_a.R) if world.enableAnimation and animation;
1032 Visualizers.Advanced.Shape sphere(shapeType="sphere", color=sphereColor, specularCoefficient=specularCoefficient, length=sphereDiameter, width=sphereDiameter, height=sphereDiameter, lengthDirection={1,0,0}, widthDirection={0,1,0}, r_shape=r_CM - {1,0,0}*sphereDiameter/2, r=frame_a.r_0, R=frame_a.R) if world.enableAnimation and animation and sphereDiameter > 0;
1033 initial equation
1034 if angles_fixed then
1035 if not Connections.isRoot(frame_a.R) then
1036 zeros(3)=Frames.Orientation.equalityConstraint(frame_a.R, R_start);
1037 elseif useQuaternions then
1038 zeros(3)=Frames.Quaternions.Orientation.equalityConstraint(Q, Q_start);
1039 else
1040 phi=phi_start;
1041 end if;
1042 end if;
1043 equation
1044 if enforceStates then
1045 Connections.root(frame_a.R);
1046 else
1047 Connections.potentialRoot(frame_a.R);
1048 end if;
1049 r_0=frame_a.r_0;
1050 if not Connections.isRoot(frame_a.R) then
1051 Q={0,0,0,1};
1052 phi=zeros(3);
1053 phi_d=zeros(3);
1054 phi_dd=zeros(3);
1055 elseif useQuaternions then
1056 frame_a.R=Frames.from_Q(Q, Frames.Quaternions.angularVelocity2(Q, der(Q)));
1057 {0}=Frames.Quaternions.orientationConstraint(Q);
1058 phi=zeros(3);
1059 phi_d=zeros(3);
1060 phi_dd=zeros(3);
1061 else
1062 phi_d=der(phi);
1063 phi_dd=der(phi_d);
1064 frame_a.R=Frames.axesRotations(sequence_angleStates, phi, phi_d);
1065 Q={0,0,0,1};
1066 end if;
1067 g_0=world.gravityAcceleration(frame_a.r_0 + Frames.resolve1(frame_a.R, r_CM));
1068 v_0=der(frame_a.r_0);
1069 a_0=der(v_0);
1070 w_a=Frames.angularVelocity2(frame_a.R);
1071 z_a=der(w_a);
1072 frame_a.f=m*(Frames.resolve2(frame_a.R, a_0 - g_0) + cross(z_a, r_CM) + cross(w_a, cross(w_a, r_CM)));
1073 frame_a.t=I*z_a + cross(w_a, I*w_a) + cross(r_CM, frame_a.f);
1074 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Rectangle(extent={{-100,30},{-3,-31}}, lineColor={0,0,0}, fillPattern=FillPattern.HorizontalCylinder, fillColor={0,127,255}),Text(extent={{131,-123},{-129,-73}}, lineColor={0,0,0}, textString="m=%m"),Text(extent={{-128,132},{132,72}}, textString="%name", lineColor={0,0,255}),Ellipse(extent={{-20,60},{100,-60}}, lineColor={0,0,0}, fillPattern=FillPattern.Sphere, fillColor={0,127,255})}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics), Documentation(info="<HTML>
1075<p>
1076<b>Rigid body</b> with mass and inertia tensor.
1077All parameter vectors have to be resolved in frame_a.
1078The <b>inertia tensor</b> has to be defined with respect to a
1079coordinate system that is parallel to frame_a with the
1080origin at the center of mass of the body.
1081</p>
1082<p>
1083By default, this component is visualized by a <b>cylinder</b> located
1084between frame_a and the center of mass and by a <b>sphere</b> that has
1085its center at the center of mass. If the cylinder length is smaller as
1086the radius of the sphere, e.g., since frame_a is located at the
1087center of mass, the cylinder is not displayed. Note, that
1088the animation may be switched off via parameter animation = <b>false</b>.
1089</p>
1090<IMG SRC=\"../../Images/MultiBody/Body.png\" ALT=\"Parts.Body\">
1091<p>
1092<b>States of Body Components</b>
1093</p>
1094<p>
1095Every body has potential states. If possible a tool will select
1096the states of joints and not the states of bodies because this is
1097usually the most efficient choice. In this case the position, orientation,
1098velocity and angular velocity of frame_a of the body will be computed
1099by the component that is connected to frame_a. However, if a body is moving
1100freely in space, variables of the body have to be used as states. The potential
1101states of the body are:
1102</p>
1103<ul>
1104<li> The <b>position vector</b> frame_a.r_0 from the origin of the
1105 world frame to the origin of frame_a of the body, resolved in
1106 the world frame and the <b>absolute velocity</b> v_0 of the origin of
1107 frame_a, resolved in the world frame (= der(frame_a.r_0)).</li>
1108</li>
1109<li> If parameter <b>useQuaternions</b> in the \"Advanced\" menu
1110 is <b>true</b> (this is the default), then <b>4 quaternions</b>
1111 are potential states. Additionally, the coordinates of the
1112 absolute angular velocity vector of the
1113 body are 3 potential states.<br>
1114 If <b>useQuaternions</b> in the \"Advanced\" menu
1115 is <b>false</b>, then <b>3 angles</b> and the derivatives of
1116 these angles are potential states. The orientation of frame_a
1117 is computed by rotating the world frame along the axes defined
1118 in parameter vector \"sequence_angleStates\" (default = {1,2,3}, i.e.,
1119 the Cardan angle sequence) around the angles used as potential states.
1120 For example, the default is to rotate the x-axis of the world frame
1121 around angles[1], the new y-axis around angles[2] and the new z-axis
1122 around angles[3], arriving at frame_a.
1123 </li>
1124</ul>
1125<p>
1126The quaternions have the slight disadvantage that there is a
1127non-linear constraint equation between the 4 quaternions.
1128Therefore, at least one non-linear equation has to be solved
1129during simulation. A tool might, however, analytically solve this
1130simple constraint equation. Using the 3 angles as states has the
1131disadvantage that there is a singular configuration in which a
1132division by zero will occur. If it is possible to determine in advance
1133for an application class that this singular configuration is outside
1134of the operating region, the 3 angles might be used as potential
1135states by setting <b>useQuaternions</b> = <b>false</b>.
1136</p>
1137<p>
1138In text books about 3-dimensional mechanics often 3 angles and the
1139angular velocity are used as states. This is not the case here, since
11403 angles and their derivatives are used as potential states
1141(if useQuaternions = false). The reason
1142is that for real-time simulation the discretization formula of the
1143integrator might be \"inlined\" and solved together with the body equations.
1144By appropriate symbolic transformation the performance is
1145drastically increased if angles and their
1146derivatives are used as states, instead of angles and the angular
1147velocity.
1148</p>
1149<p>
1150Whether or not variables of the body are used as states is usually
1151automatically selected by the Modelica translator. If parameter
1152<b>enforceStates</b> is set to <b>true</b> in the \"Advanced\" menu,
1153then body variables are forced to be used as states according
1154to the setting of parameters \"useQuaternions\" and
1155\"sequence_angleStates\".
1156</p>
1157</HTML>"));
1158 end Body;
1159
1160 annotation(Documentation(info="<HTML>
1161<p>
1162Package <b>Parts</b> contains <b>rigid components</b> of a
1163multi-body system. These components may be used to build up
1164more complicated structures. For example, a part may be built up of
1165a \"Body\" and of several \"FixedTranslation\" components.
1166</p>
1167<h4>Content</h4>
1168<table border=1 cellspacing=0 cellpadding=2>
1169 <tr><th><b><i>Model</i></b></th><th><b><i>Description</i></b></th></tr>
1170 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.Fixed\">Fixed</a></td>
1171 <td valign=\"top\">Frame fixed in world frame at a given position.
1172 It is visualized with a shape, see <b>shapeType</b> below
1173 (the frames on the two
1174 sides do not belong to the component):<br>&nbsp;<br>
1175 <IMG SRC=\"../../Images/MultiBody/Fixed.png\" ALT=\"model Parts.Fixed\">
1176 </td>
1177 </tr>
1178 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.FixedTranslation\">FixedTranslation</a></td>
1179 <td valign=\"top\">Fixed translation of frame_b with respect to frame_a.
1180 It is visualized with a shape, see <b>shapeType</b> below
1181 (the frames on the two sides do not belong to the component):<br>&nbsp;<br>
1182 <IMG SRC=\"../../Images/MultiBody/FixedTranslation.png\" ALT=\"model Parts.FixedTranslation\">
1183 </td>
1184 </tr>
1185 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.FixedRotation\">FixedRotation</a></td>
1186 <td valign=\"top\">Fixed translation and fixed rotation of frame_b with respect to frame_a
1187 It is visualized with a shape, see <b>shapeType</b> below
1188 (the frames on the two sides do not belong to the component):<br>&nbsp;<br>
1189 <IMG SRC=\"../../Images/MultiBody/FixedRotation.png\" ALT=\"model Parts.FixedRotation\">
1190 </td>
1191 </tr>
1192 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.Body\">Body</a></td>
1193 <td valign=\"top\">Rigid body with mass, inertia tensor and one frame connector.
1194 It is visualized with a cylinder and a sphere at the
1195 center of mass:<br>&nbsp;<br>
1196 <IMG SRC=\"../../Images/MultiBody/Body.png\" ALT=\"model Parts.Body\">
1197 </td>
1198 </tr>
1199 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.BodyShape\">BodyShape</a></td>
1200 <td valign=\"top\">Rigid body with mass, inertia tensor, different shapes
1201 (see <b>shapeType</b> below)
1202 for animation, and two frame connectors:<br>&nbsp;<br>
1203 <IMG SRC=\"../../Images/MultiBody/BodyShape.png\" ALT=\"model Parts.BodyShape\">
1204 </td>
1205 </tr>
1206 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.Fixed\">Fixed</a>
1207BodyBox</b></td>
1208 <td valign=\"top\">Rigid body with box shape (mass and animation properties are computed
1209 from box data and from density):<br>&nbsp;<br>
1210 <IMG SRC=\"../../Images/MultiBody/BodyBox.png\" ALT=\"model Parts.BodyBox\">
1211 </td>
1212 </tr>
1213 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.BodyCylinder\">BodyCylinder</a></td>
1214 <td valign=\"top\">Rigid body with cylinder shape (mass and animation properties
1215 are computed from cylinder data and from density):<br>&nbsp;<br>
1216 <IMG SRC=\"../../Images/MultiBody/BodyCylinder.png\" ALT=\"model Parts.BodyCylinder\">
1217 </td>
1218 </tr>
1219 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.PointMass\">PointMass</a></td>
1220 <td valign=\"top\">Rigid body where inertia tensor and rotation is neglected:<br>&nbsp;<br>
1221 <IMG SRC=\"../../Images/MultiBody/Parts/PointMass.png\" ALT=\"model Parts.PointMass\">
1222 </td>
1223 </tr>
1224 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.Mounting1D\">Mounting1D</a></td>
1225 <td valign=\"top\"> Propagate 1-dim. support torque to 3-dim. system
1226 </td>
1227 </tr>
1228 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.Rotor1D\">Rotor1D</a></td>
1229 <td valign=\"top\">1D inertia attachable on 3-dim. bodies (without neglecting dynamic effects)<br>
1230 <IMG SRC=\"../../Images/MultiBody/Parts/Rotor1D.png\" ALT=\"model Parts.Rotor1D\">
1231 </td>
1232 </tr>
1233 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Parts.BevelGear1D\">BevelGear1D</a></td>
1234 <td valign=\"top\">1D gearbox with arbitrary shaft directions (3D bearing frame)
1235 </td>
1236 </tr>
1237</table>
1238<p>
1239Components <b>Fixed</b>, <b>FixedTranslation</b>, <b>FixedRotation</b>
1240and <b>BodyShape</b> are visualized according to parameter
1241<b>shapeType</b>, that may have the following values (e.g., shapeType = \"box\"): <br>&nbsp;<br>
1242</p>
1243<IMG SRC=\"../../Images/MultiBody/FixedShape.png\" ALT=\"model Visualizers.FixedShape\">
1244<p>
1245All the details of the visualization shape parameters are
1246given in
1247<a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.FixedShape\">Visualizers.FixedShape</a>
1248</p>
1249<p>
1250Colors in all animation parts are defined via parameter <b>color</b>.
1251This is an Integer vector with 3 elements, {r, g, b}, and specifies the
1252color of the shape. {r,g,b} are the \"red\", \"green\" and \"blue\" color parts,
1253given in the ranges 0 .. 255, respectively. The predefined type
1254<b>MultiBody.Types.Color</b> contains a menu
1255definition of the colors used in the MultiBody library
1256(this will be replaced by a color editor).
1257</p>
1258</HTML>
1259"));
1260 end Parts;
1261
1262 package Interfaces "Connectors and partial models for 3-dim. mechanical components"
1263 extends Modelica.Icons.Library;
1264 connector Frame "Coordinate system fixed to the component with one cut-force and cut-torque (no icon)"
1265 import SI = Modelica.SIunits;
1266 SI.Position r_0[3] "Position vector from world frame to the connector frame origin, resolved in world frame";
1267 Frames.Orientation R "Orientation object to rotate the world frame into the connector frame";
1268 flow SI.Force f[3] "Cut-force resolved in connector frame" annotation(unassignedMessage="All Forces cannot be uniquely calculated.
1269The reason could be that the mechanism contains
1270a planar loop or that joints constrain the
1271same motion. For planar loops, use for one
1272revolute joint per loop the joint
1273Joints.RevolutePlanarLoopConstraint instead of
1274Joints.Revolute.");
1275 flow SI.Torque t[3] "Cut-torque resolved in connector frame";
1276 annotation(Documentation(info="<html>
1277<p>
1278Basic definition of a coordinate system that is fixed to a mechanical
1279component. In the origin of the coordinate system the cut-force
1280and the cut-torque is acting. This component has no icon definition
1281and is only used by inheritance from frame connectors to define
1282different icons.
1283</p>
1284</html>"));
1285 end Frame;
1286
1287 connector Frame_a "Coordinate system fixed to the component with one cut-force and cut-torque (filled rectangular icon)"
1288 extends Frame;
1289 annotation(defaultComponentName="frame_a", Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}, initialScale=0.16), graphics={Rectangle(extent={{-10,10},{10,-10}}, lineColor={95,95,95}, lineThickness=0.5),Rectangle(extent={{-30,100},{30,-100}}, lineColor={0,0,0}, fillColor={192,192,192}, fillPattern=FillPattern.Solid)}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}, initialScale=0.16), graphics={Text(extent={{-140,-50},{140,-88}}, lineColor={0,0,0}, textString="%name"),Rectangle(extent={{-12,40},{12,-40}}, lineColor={0,0,0}, fillColor={192,192,192}, fillPattern=FillPattern.Solid)}), Documentation(info="<html>
1290<p>
1291Basic definition of a coordinate system that is fixed to a mechanical
1292component. In the origin of the coordinate system the cut-force
1293and the cut-torque is acting.
1294This component has a filled rectangular icon.
1295</p>
1296</html>"));
1297 end Frame_a;
1298
1299 connector Frame_b "Coordinate system fixed to the component with one cut-force and cut-torque (non-filled rectangular icon)"
1300 extends Frame;
1301 annotation(defaultComponentName="frame_b", Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}, initialScale=0.16), graphics={Rectangle(extent={{-10,10},{10,-10}}, lineColor={95,95,95}, lineThickness=0.5),Rectangle(extent={{-30,100},{30,-100}}, lineColor={0,0,0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid)}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}, initialScale=0.16), graphics={Text(extent={{-140,-50},{140,-88}}, lineColor={0,0,0}, textString="%name"),Rectangle(extent={{-12,40},{12,-40}}, lineColor={0,0,0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid)}), Documentation(info="<html>
1302<p>
1303Basic definition of a coordinate system that is fixed to a mechanical
1304component. In the origin of the coordinate system the cut-force
1305and the cut-torque is acting. This component has a non-filled rectangular icon.
1306</p>
1307</html>"));
1308 end Frame_b;
1309
1310 connector Frame_resolve "Coordinate system fixed to the component used to express in which
1311coordinate system a vector is resolved (non-filled rectangular icon)"
1312 extends Frame;
1313 annotation(defaultComponentName="frame_resolve", Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}, initialScale=0.16), graphics={Rectangle(extent={{-10,10},{10,-10}}, lineColor={95,95,95}, pattern=LinePattern.Dot),Rectangle(extent={{-30,100},{30,-100}}, lineColor={95,95,95}, pattern=LinePattern.Dot, fillColor={255,255,255}, fillPattern=FillPattern.Solid)}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}, initialScale=0.16), graphics={Text(extent={{-140,-50},{140,-88}}, lineColor={0,0,0}, textString="%name"),Rectangle(extent={{-12,40},{12,-40}}, lineColor={95,95,95}, pattern=LinePattern.Dot, fillColor={255,255,255}, fillPattern=FillPattern.Solid)}), Documentation(info="<html>
1314<p>
1315Basic definition of a coordinate system that is fixed to a mechanical
1316component. In the origin of the coordinate system the cut-force
1317and the cut-torque is acting. This coordinate system is used to
1318express in which coordinate system a vector is resolved.
1319A component that uses a Frame_resolve connector has to set the
1320cut-force and cut-torque of this frame to zero. When connecting
1321from a Frame_resolve connector to another frame connector,
1322by default the connecting line has line style \"dotted\".
1323This component has a non-filled rectangular icon.
1324</p>
1325</html>"));
1326 end Frame_resolve;
1327
1328 annotation(Documentation(info="<html>
1329<p>
1330This package contains connectors and partial models (i.e. models
1331that are only used to build other models) of the MultiBody library.
1332</p>
1333</html>"));
1334 end Interfaces;
1335
1336 package Frames "Functions to transform rotational frame quantities"
1337 extends Modelica.Icons.Library;
1338 record Orientation "Orientation object defining rotation from a frame 1 into a frame 2"
1339 import SI = Modelica.SIunits;
1340 extends Modelica.Icons.Record;
1341 Real T[3,3] "Transformation matrix from world frame to local frame";
1342 SI.AngularVelocity w[3] "Absolute angular velocity of local frame, resolved in local frame";
1343 encapsulated function equalityConstraint "Return the constraint residues to express that two frames have the same orientation"
1344 import Modelica;
1345 import Modelica.Mechanics.MultiBody.Frames;
1346 extends Modelica.Icons.Function;
1347 input Frames.Orientation R1 "Orientation object to rotate frame 0 into frame 1";
1348 input Frames.Orientation R2 "Orientation object to rotate frame 0 into frame 2";
1349 output Real residue[3] "The rotation angles around x-, y-, and z-axis of frame 1 to rotate frame 1 into frame 2 for a small rotation (should be zero)";
1350 annotation(Inline=true);
1351 algorithm
1352 residue:={Modelica.Math.atan2(cross(R1.T[1,:], R1.T[2,:])*R2.T[2,:], R1.T[1,:]*R2.T[1,:]),Modelica.Math.atan2(-cross(R1.T[1,:], R1.T[2,:])*R2.T[1,:], R1.T[2,:]*R2.T[2,:]),Modelica.Math.atan2(R1.T[2,:]*R2.T[1,:], R1.T[3,:]*R2.T[3,:])};
1353 end equalityConstraint;
1354
1355 annotation(Documentation(info="<html>
1356<p>
1357This object describes the <b>rotation</b> from a <b>frame 1</b> into a <b>frame 2</b>.
1358An instance of this type should never be directly accessed but
1359only with the access functions provided
1360in package Modelica.Mechanics.MultiBody.Frames. As a consequence, it is not necessary to know
1361the internal representation of this object as described in the next paragraphs.
1362</p>
1363<p>
1364\"Orientation\" is defined to be a record consisting of two
1365elements: \"Real T[3,3]\", the transformation matrix to rotate frame 1
1366into frame 2 and \"Real w[3]\", the angular velocity of frame 2 with
1367respect to frame 1, resolved in frame 2. Element \"T\"
1368has the following interpretation:
1369</p>
1370<pre>
1371 Orientation R;
1372 <b>R.T</b> = [<b>e</b><sub>x</sub>, <b>e</b><sub>y</sub>, <b>e</b><sub>z</sub>];
1373 e.g., <b>R.T</b> = [1,0,0; 0,1,0; 0,0,1]
1374</pre>
1375<p>
1376where <b>e</b><sub>x</sub>,<b>e</b><sub>y</sub>,<b>e</b><sub>z</sub>
1377are unit vectors in the direction of the x-axis, y-axis, and z-axis
1378of frame 1, resolved in frame 2, respectively. Therefore, if <b>v</b><sub>1</sub>
1379is vector <b>v</b> resolved in frame 1 and <b>v</b><sub>2</sub> is
1380vector <b>v</b> resolved in frame 2, the following relationship holds:
1381</p>
1382<pre>
1383 <b>v</b><sub>2</sub> = <b>R.T</b> * <b>v</b><sub>1</sub>
1384</pre>
1385</p>
1386The <b>inverse</b> orientation
1387<b>R_inv.T</b> = <b>R.T</b><sup>T</sup> describes the rotation
1388from frame 2 into frame 1.
1389</p>
1390<p>
1391Since the orientation is described by 9 variables, there are
13926 constraints between these variables. These constraints
1393are defined in function <b>Frames.orientationConstraint</b>.
1394</p>
1395<p>
1396R.w is the angular velocity of frame 2 with respect to frame 1, resolved
1397in frame 2. Formally, R.w is defined as:<br>
1398<b>skew</b>(R.w) = R.T*<b>der</b>(transpose(R.T))
1399with
1400</p>
1401<pre>
1402 | 0 -w[3] w[2] |
1403 <b>skew</b>(w) = | w[3] 0 -w[1] |
1404 | -w[2] w[1] 0 |
1405</pre>
1406
1407</html>
1408"));
1409 end Orientation;
1410
1411 function angularVelocity2 "Return angular velocity resolved in frame 2 from orientation object"
1412 extends Modelica.Icons.Function;
1413 input Orientation R "Orientation object to rotate frame 1 into frame 2";
1414 output Modelica.SIunits.AngularVelocity w[3] "Angular velocity of frame 2 with respect to frame 1 resolved in frame 2";
1415 annotation(Inline=true);
1416 algorithm
1417 w:=R.w;
1418 end angularVelocity2;
1419
1420 function resolve1 "Transform vector from frame 2 to frame 1"
1421 extends Modelica.Icons.Function;
1422 input Orientation R "Orientation object to rotate frame 1 into frame 2";
1423 input Real v2[3] "Vector in frame 2";
1424 output Real v1[3] "Vector in frame 1";
1425 annotation(derivative(noDerivative=R)=Internal.resolve1_der, __Dymola_InlineAfterIndexReduction=true);
1426 algorithm
1427 v1:=transpose(R.T)*v2;
1428 end resolve1;
1429
1430 function resolve2 "Transform vector from frame 1 to frame 2"
1431 extends Modelica.Icons.Function;
1432 input Orientation R "Orientation object to rotate frame 1 into frame 2";
1433 input Real v1[3] "Vector in frame 1";
1434 output Real v2[3] "Vector in frame 2";
1435 annotation(derivative(noDerivative=R)=Internal.resolve2_der, __Dymola_InlineAfterIndexReduction=true);
1436 algorithm
1437 v2:=R.T*v1;
1438 end resolve2;
1439
1440 function nullRotation "Return orientation object that does not rotate a frame"
1441 extends Modelica.Icons.Function;
1442 output Orientation R "Orientation object such that frame 1 and frame 2 are identical";
1443 annotation(Inline=true);
1444 algorithm
1445 R:=Orientation(T=identity(3), w=zeros(3));
1446 end nullRotation;
1447
1448 function absoluteRotation "Return absolute orientation object from another absolute and a relative orientation object"
1449 extends Modelica.Icons.Function;
1450 input Orientation R1 "Orientation object to rotate frame 0 into frame 1";
1451 input Orientation R_rel "Orientation object to rotate frame 1 into frame 2";
1452 output Orientation R2 "Orientation object to rotate frame 0 into frame 2";
1453 annotation(Inline=true);
1454 algorithm
1455 R2:=Orientation(T=R_rel.T*R1.T, w=resolve2(R_rel, R1.w) + R_rel.w);
1456 end absoluteRotation;
1457
1458 function planarRotation "Return orientation object of a planar rotation"
1459 import Modelica.Math;
1460 extends Modelica.Icons.Function;
1461 input Real e[3](each final unit="1") "Normalized axis of rotation (must have length=1)";
1462 input Modelica.SIunits.Angle angle "Rotation angle to rotate frame 1 into frame 2 along axis e";
1463 input Modelica.SIunits.AngularVelocity der_angle "= der(angle)";
1464 output Orientation R "Orientation object to rotate frame 1 into frame 2";
1465 annotation(Inline=true);
1466 algorithm
1467 R:=Orientation(T=[e]*transpose([e]) + (identity(3) - [e]*transpose([e]))*Math.cos(angle) - skew(e)*Math.sin(angle), w=e*der_angle);
1468 end planarRotation;
1469
1470 function planarRotationAngle "Return angle of a planar rotation, given the rotation axis and the representations of a vector in frame 1 and frame 2"
1471 extends Modelica.Icons.Function;
1472 input Real e[3](each final unit="1") "Normalized axis of rotation to rotate frame 1 around e into frame 2 (must have length=1)";
1473 input Real v1[3] "A vector v resolved in frame 1 (shall not be parallel to e)";
1474 input Real v2[3] "Vector v resolved in frame 2, i.e., v2 = resolve2(planarRotation(e,angle),v1)";
1475 output Modelica.SIunits.Angle angle "Rotation angle to rotate frame 1 into frame 2 along axis e in the range: -pi <= angle <= pi";
1476 annotation(Inline=true, Documentation(info="<HTML>
1477<p>
1478A call to this function of the form
1479</p>
1480<pre>
1481 Real[3] e, v1, v2;
1482 Modelica.SIunits.Angle angle;
1483 <b>equation</b>
1484 angle = <b>planarRotationAngle</b>(e, v1, v2);
1485</pre>
1486<p>
1487computes the rotation angle \"<b>angle</b>\" of a planar
1488rotation along unit vector <b>e</b>, rotating frame 1 into frame 2, given
1489the coordinate representations of a vector \"v\" in frame 1 (<b>v1</b>)
1490and in frame 2 (<b>v2</b>). Therefore, the result of this function
1491fulfills the following equation:
1492</p>
1493<pre>
1494 v2 = <b>resolve2</b>(<b>planarRotation</b>(e,angle), v1)
1495</pre>
1496<p>
1497The rotation angle is returned in the range
1498</p>
1499<pre>
1500 -<font face=\"Symbol\">p</font> &lt;= angle &lt;= <font face=\"Symbol\">p</font>
1501</pre>
1502<p>
1503This function makes the following assumptions on the input arguments
1504</p>
1505<ul>
1506<li> Vector <b>e</b> has length 1, i.e., length(e) = 1</li>
1507<li> Vector \"v\" is not parallel to <b>e</b>, i.e.,
1508 length(cross(e,v1)) &ne; 0</li>
1509</ul>
1510<p>
1511The function does not check the above assumptions. If these
1512assumptions are violated, a wrong result will be returned
1513and/or a division by zero will occur.
1514</p>
1515</HTML>"));
1516 algorithm
1517 angle:=Modelica.Math.atan2(-cross(e, v1)*v2, v1*v2 - e*v1*(e*v2));
1518 end planarRotationAngle;
1519
1520 function axesRotations "Return fixed rotation object to rotate in sequence around fixed angles along 3 axes"
1521 import TM = Modelica.Mechanics.MultiBody.Frames.TransformationMatrices;
1522 extends Modelica.Icons.Function;
1523 input Integer sequence[3](min={1,1,1}, max={3,3,3})={1,2,3} "Sequence of rotations from frame 1 to frame 2 along axis sequence[i]";
1524 input Modelica.SIunits.Angle angles[3] "Rotation angles around the axes defined in 'sequence'";
1525 input Modelica.SIunits.AngularVelocity der_angles[3] "= der(angles)";
1526 output Orientation R "Orientation object to rotate frame 1 into frame 2";
1527 annotation(Inline=true);
1528 algorithm
1529 R:=Orientation(T=TM.axisRotation(sequence[3], angles[3])*TM.axisRotation(sequence[2], angles[2])*TM.axisRotation(sequence[1], angles[1]), w=Frames.axis(sequence[3])*der_angles[3] + TM.resolve2(TM.axisRotation(sequence[3], angles[3]), Frames.axis(sequence[2])*der_angles[2]) + TM.resolve2(TM.axisRotation(sequence[3], angles[3])*TM.axisRotation(sequence[2], angles[2]), Frames.axis(sequence[1])*der_angles[1]));
1530 end axesRotations;
1531
1532 function axesRotationsAngles "Return the 3 angles to rotate in sequence around 3 axes to construct the given orientation object"
1533 import SI = Modelica.SIunits;
1534 extends Modelica.Icons.Function;
1535 input Orientation R "Orientation object to rotate frame 1 into frame 2";
1536 input Integer sequence[3](min={1,1,1}, max={3,3,3})={1,2,3} "Sequence of rotations from frame 1 to frame 2 along axis sequence[i]";
1537 input SI.Angle guessAngle1=0 "Select angles[1] such that |angles[1] - guessAngle1| is a minimum";
1538 output SI.Angle angles[3] "Rotation angles around the axes defined in 'sequence' such that R=Frames.axesRotation(sequence,angles); -pi < angles[i] <= pi";
1539 protected
1540 Real e1_1[3](each final unit="1") "First rotation axis, resolved in frame 1";
1541 Real e2_1a[3](each final unit="1") "Second rotation axis, resolved in frame 1a";
1542 Real e3_1[3](each final unit="1") "Third rotation axis, resolved in frame 1";
1543 Real e3_2[3](each final unit="1") "Third rotation axis, resolved in frame 2";
1544 Real A "Coefficient A in the equation A*cos(angles[1])+B*sin(angles[1]) = 0";
1545 Real B "Coefficient B in the equation A*cos(angles[1])+B*sin(angles[1]) = 0";
1546 SI.Angle angle_1a "Solution 1 for angles[1]";
1547 SI.Angle angle_1b "Solution 2 for angles[1]";
1548 TransformationMatrices.Orientation T_1a "Orientation object to rotate frame 1 into frame 1a";
1549 algorithm
1550 assert(sequence[1] <> sequence[2] and sequence[2] <> sequence[3], "input argument 'sequence[1:3]' is not valid");
1551 e1_1:=if sequence[1] == 1 then {1,0,0} else if sequence[1] == 2 then {0,1,0} else {0,0,1};
1552 e2_1a:=if sequence[2] == 1 then {1,0,0} else if sequence[2] == 2 then {0,1,0} else {0,0,1};
1553 e3_1:=R.T[sequence[3],:];
1554 e3_2:=if sequence[3] == 1 then {1,0,0} else if sequence[3] == 2 then {0,1,0} else {0,0,1};
1555 A:=e2_1a*e3_1;
1556 B:=cross(e1_1, e2_1a)*e3_1;
1557 if abs(A) <= 1e-12 and abs(B) <= 1e-12 then
1558 angles[1]:=guessAngle1;
1559 else
1560 angle_1a:=Modelica.Math.atan2(A, -B);
1561 angle_1b:=Modelica.Math.atan2(-A, B);
1562 angles[1]:=if abs(angle_1a - guessAngle1) <= abs(angle_1b - guessAngle1) then angle_1a else angle_1b;
1563 end if;
1564 T_1a:=TransformationMatrices.planarRotation(e1_1, angles[1]);
1565 angles[2]:=planarRotationAngle(e2_1a, TransformationMatrices.resolve2(T_1a, e3_1), e3_2);
1566 angles[3]:=planarRotationAngle(e3_2, e2_1a, TransformationMatrices.resolve2(R.T, TransformationMatrices.resolve1(T_1a, e2_1a)));
1567 annotation(Documentation(info="<HTML>
1568<p>
1569A call to this function of the form
1570</p>
1571<pre>
1572 Frames.Orientation R;
1573 <b>parameter</b> Integer sequence[3] = {1,2,3};
1574 Modelica.SIunits.Angle angles[3];
1575 <b>equation</b>
1576 angle = <b>axesRotationAngles</b>(R, sequence);
1577</pre>
1578<p>
1579computes the rotation angles \"<b>angles</b>[1:3]\" to rotate frame 1
1580into frame 2 along axes <b>sequence</b>[1:3], given the orientation
1581object <b>R</b> from frame 1 to frame 2. Therefore, the result of
1582this function fulfills the following equation:
1583</p>
1584<pre>
1585 R = <b>axesRotation</b>(sequence, angles)
1586</pre>
1587<p>
1588The rotation angles are returned in the range
1589</p>
1590<pre>
1591 -<font face=\"Symbol\">p</font> &lt;= angles[i] &lt;= <font face=\"Symbol\">p</font>
1592</pre>
1593<p>
1594There are <b>two solutions</b> for \"angles[1]\" in this range.
1595Via the third argument <b>guessAngle1</b> (default = 0) the
1596returned solution is selected such that |angles[1] - guessAngle1| is
1597minimal. The orientation object R may be in a singular configuration, i.e.,
1598there is an infinite number of angle values leading to the same R. The returned solution is
1599selected by setting angles[1] = guessAngle1. Then angles[2]
1600and angles[3] can be uniquely determined in the above range.
1601</p>
1602<p>
1603Note, that input argument <b>sequence</b> has the restriction that
1604only values 1,2,3 can be used and that sequence[1] &ne; sequence[2]
1605and sequence[2] &ne; sequence[3]. Often used values are:
1606</p>
1607<pre>
1608 sequence = <b>{1,2,3}</b> // Cardan angle sequence
1609 = <b>{3,1,3}</b> // Euler angle sequence
1610 = <b>{3,2,1}</b> // Tait-Bryan angle sequence
1611</pre>
1612</HTML>"));
1613 end axesRotationsAngles;
1614
1615 function from_nxy "Return fixed orientation object from n_x and n_y vectors"
1616 extends Modelica.Icons.Function;
1617 input Real n_x[3](each final unit="1") "Vector in direction of x-axis of frame 2, resolved in frame 1";
1618 input Real n_y[3](each final unit="1") "Vector in direction of y-axis of frame 2, resolved in frame 1";
1619 output Orientation R "Orientation object to rotate frame 1 into frame 2";
1620 protected
1621 Real abs_n_x=sqrt(n_x*n_x);
1622 Real e_x[3](each final unit="1")=if abs_n_x < 1e-10 then {1,0,0} else n_x/abs_n_x;
1623 Real n_z_aux[3](each final unit="1")=cross(e_x, n_y);
1624 Real n_y_aux[3](each final unit="1")=if n_z_aux*n_z_aux > 1e-06 then n_y else if abs(e_x[1]) > 1e-06 then {0,1,0} else {1,0,0};
1625 Real e_z_aux[3](each final unit="1")=cross(e_x, n_y_aux);
1626 Real e_z[3](each final unit="1")=e_z_aux/sqrt(e_z_aux*e_z_aux);
1627 algorithm
1628 R:=Orientation(T={e_x,cross(e_z, e_x),e_z}, w=zeros(3));
1629 annotation(Documentation(info="<html>
1630<p>
1631It is assumed that the two input vectors n_x and n_y are
1632resolved in frame 1 and are directed along the x and y axis
1633of frame 2 (i.e., n_x and n_y are orthogonal to each other)
1634The function returns the orientation object R to rotate from
1635frame 1 to frame 2.
1636</p>
1637<p>
1638The function is robust in the sense that it returns always
1639an orientation object R, even if n_y is not orthogonal to n_x.
1640This is performed in the following way:
1641</p>
1642<p>
1643If n_x and n_y are not orthogonal to each other, first a unit
1644vector e_y is determined that is orthogonal to n_x and is lying
1645in the plane spanned by n_x and n_y. If n_x and n_y are parallel
1646or nearly parallel to each other, a vector e_y is selected
1647arbitrarily such that e_x and e_y are orthogonal to each other.
1648</p>
1649</html>"));
1650 end from_nxy;
1651
1652 function from_T "Return orientation object R from transformation matrix T"
1653 extends Modelica.Icons.Function;
1654 input Real T[3,3] "Transformation matrix to transform vector from frame 1 to frame 2 (v2=T*v1)";
1655 input Modelica.SIunits.AngularVelocity w[3] "Angular velocity from frame 2 with respect to frame 1, resolved in frame 2 (skew(w)=T*der(transpose(T)))";
1656 output Orientation R "Orientation object to rotate frame 1 into frame 2";
1657 annotation(Inline=true);
1658 algorithm
1659 R:=Orientation(T=T, w=w);
1660 end from_T;
1661
1662 function from_Q "Return orientation object R from quaternion orientation object Q"
1663 extends Modelica.Icons.Function;
1664 input Quaternions.Orientation Q "Quaternions orientation object to rotate frame 1 into frame 2";
1665 input Modelica.SIunits.AngularVelocity w[3] "Angular velocity from frame 2 with respect to frame 1, resolved in frame 2";
1666 output Orientation R "Orientation object to rotate frame 1 into frame 2";
1667 annotation(Inline=true);
1668 algorithm
1669 R:=Orientation([2*(Q[1]*Q[1] + Q[4]*Q[4]) - 1,2*(Q[1]*Q[2] + Q[3]*Q[4]),2*(Q[1]*Q[3] - Q[2]*Q[4]);2*(Q[2]*Q[1] - Q[3]*Q[4]),2*(Q[2]*Q[2] + Q[4]*Q[4]) - 1,2*(Q[2]*Q[3] + Q[1]*Q[4]);2*(Q[3]*Q[1] + Q[2]*Q[4]),2*(Q[3]*Q[2] - Q[1]*Q[4]),2*(Q[3]*Q[3] + Q[4]*Q[4]) - 1], w=w);
1670 end from_Q;
1671
1672 function to_Q "Return quaternion orientation object Q from orientation object R"
1673 extends Modelica.Icons.Function;
1674 input Orientation R "Orientation object to rotate frame 1 into frame 2";
1675 input Quaternions.Orientation Q_guess=Quaternions.nullRotation() "Guess value for output Q (there are 2 solutions; the one closer to Q_guess is used";
1676 output Quaternions.Orientation Q "Quaternions orientation object to rotate frame 1 into frame 2";
1677 annotation(Inline=true);
1678 algorithm
1679 Q:=Quaternions.from_T(R.T, Q_guess);
1680 end to_Q;
1681
1682 function axis "Return unit vector for x-, y-, or z-axis"
1683 extends Modelica.Icons.Function;
1684 input Integer axis(min=1, max=3) "Axis vector to be returned";
1685 output Real e[3](each final unit="1") "Unit axis vector";
1686 annotation(Inline=true);
1687 algorithm
1688 e:=if axis == 1 then {1,0,0} else if axis == 2 then {0,1,0} else {0,0,1};
1689 end axis;
1690
1691 package Quaternions "Functions to transform rotational frame quantities based on quaternions (also called Euler parameters)"
1692 extends Modelica.Icons.Library;
1693 type Orientation "Orientation type defining rotation from a frame 1 into a frame 2 with quaternions {p1,p2,p3,p0}"
1694 extends Internal.QuaternionBase;
1695 encapsulated function equalityConstraint "Return the constraint residues to express that two frames have the same quaternion orientation"
1696 import Modelica;
1697 import Modelica.Mechanics.MultiBody.Frames.Quaternions;
1698 extends Modelica.Icons.Function;
1699 input Quaternions.Orientation Q1 "Quaternions orientation object to rotate frame 0 into frame 1";
1700 input Quaternions.Orientation Q2 "Quaternions orientation object to rotate frame 0 into frame 2";
1701 output Real residue[3] "The half of the rotation angles around x-, y-, and z-axis of frame 1 to rotate frame 1 into frame 2 for a small rotation (shall be zero)";
1702 annotation(Inline=true);
1703 algorithm
1704 residue:=[Q1[4],Q1[3],-Q1[2],-Q1[1];-Q1[3],Q1[4],Q1[1],-Q1[2];Q1[2],-Q1[1],Q1[4],-Q1[3]]*Q2;
1705 end equalityConstraint;
1706
1707 annotation(Documentation(info="<html>
1708<p>
1709This type describes the <b>rotation</b> to rotate a frame 1 into
1710a frame 2 using quaternions (also called <b>Euler parameters</b>)
1711according to the following definition:
1712</p>
1713<pre>
1714 Quaternions.Orientation Q;
1715 Real n[3];
1716 Real phi(unit=\"rad\");
1717 Q = [ n*sin(phi/2)
1718 cos(phi/2) ]
1719</pre>
1720<p>
1721where \"n\" is the <b>axis of rotation</b> to rotate frame 1 into
1722frame 2 and \"phi\" is the <b>rotation angle</b> for this rotation.
1723Vector \"n\" is either resolved in frame 1 or in frame 2
1724(the result is the same since the coordinates of \"n\" with respect to
1725frame 1 are identical to its coordinates with respect to frame 2).
1726<p>
1727<p>
1728The term \"quaternions\" is prefered over the historically
1729more reasonable \"Euler parameters\" in order to not get
1730confused with Modelica \"parameters\".
1731</p>
1732</html>
1733"));
1734 end Orientation;
1735
1736 type der_Orientation= Real[4](each unit="1/s") "First time derivative of Quaternions.Orientation";
1737 function orientationConstraint "Return residues of orientation constraints (shall be zero)"
1738 extends Modelica.Icons.Function;
1739 input Quaternions.Orientation Q "Quaternions orientation object to rotate frame 1 into frame 2";
1740 output Real residue[1] "Residue constraint (shall be zero)";
1741 annotation(Inline=true);
1742 algorithm
1743 residue:={Q*Q - 1};
1744 end orientationConstraint;
1745
1746 function angularVelocity2 "Compute angular velocity resolved in frame 2 from quaternions orientation object and its derivative"
1747 extends Modelica.Icons.Function;
1748 input Quaternions.Orientation Q "Quaternions orientation object to rotate frame 1 into frame 2";
1749 input der_Orientation der_Q "Derivative of Q";
1750 output Modelica.SIunits.AngularVelocity w[3] "Angular velocity of frame 2 with respect to frame 1 resolved in frame 2";
1751 annotation(Inline=true);
1752 algorithm
1753 w:=2*([Q[4],Q[3],-Q[2],-Q[1];-Q[3],Q[4],Q[1],-Q[2];Q[2],-Q[1],Q[4],-Q[3]]*der_Q);
1754 end angularVelocity2;
1755
1756 function nullRotation "Return quaternions orientation object that does not rotate a frame"
1757 extends Modelica.Icons.Function;
1758 output Quaternions.Orientation Q "Quaternions orientation object to rotate frame 1 into frame 2";
1759 annotation(Inline=true);
1760 algorithm
1761 Q:={0,0,0,1};
1762 end nullRotation;
1763
1764 function from_T "Return quaternions orientation object Q from transformation matrix T"
1765 extends Modelica.Icons.Function;
1766 input Real T[3,3] "Transformation matrix to transform vector from frame 1 to frame 2 (v2=T*v1)";
1767 input Quaternions.Orientation Q_guess=nullRotation() "Guess value for Q (there are 2 solutions; the one close to Q_guess is used";
1768 output Quaternions.Orientation Q "Quaternions orientation object to rotate frame 1 into frame 2 (Q and -Q have same transformation matrix)";
1769 protected
1770 Real paux;
1771 Real paux4;
1772 Real c1;
1773 Real c2;
1774 Real c3;
1775 Real c4;
1776 constant Real p4limit=0.1;
1777 constant Real c4limit=4*p4limit*p4limit;
1778 algorithm
1779 c1:=1 + T[1,1] - T[2,2] - T[3,3];
1780 c2:=1 + T[2,2] - T[1,1] - T[3,3];
1781 c3:=1 + T[3,3] - T[1,1] - T[2,2];
1782 c4:=1 + T[1,1] + T[2,2] + T[3,3];
1783 if c4 > c4limit or c4 > c1 and c4 > c2 and c4 > c3 then
1784 paux:=sqrt(c4)/2;
1785 paux4:=4*paux;
1786 Q:={(T[2,3] - T[3,2])/paux4,(T[3,1] - T[1,3])/paux4,(T[1,2] - T[2,1])/paux4,paux};
1787 elseif c1 > c2 and c1 > c3 and c1 > c4 then
1788 paux:=sqrt(c1)/2;
1789 paux4:=4*paux;
1790 Q:={paux,(T[1,2] + T[2,1])/paux4,(T[1,3] + T[3,1])/paux4,(T[2,3] - T[3,2])/paux4};
1791
1792 elseif c2 > c1 and c2 > c3 and c2 > c4 then
1793 paux:=sqrt(c2)/2;
1794 paux4:=4*paux;
1795 Q:={(T[1,2] + T[2,1])/paux4,paux,(T[2,3] + T[3,2])/paux4,(T[3,1] - T[1,3])/paux4};
1796 else
1797 paux:=sqrt(c3)/2;
1798 paux4:=4*paux;
1799 Q:={(T[1,3] + T[3,1])/paux4,(T[2,3] + T[3,2])/paux4,paux,(T[1,2] - T[2,1])/paux4};
1800 end if;
1801 if Q*Q_guess < 0 then
1802 Q:=-Q;
1803 end if;
1804 end from_T;
1805
1806 annotation(Documentation(info="<HTML>
1807<p>
1808Package <b>Frames.Quaternions</b> contains type definitions and
1809functions to transform rotational frame quantities with quaternions.
1810Functions of this package are currently only utilized in
1811MultiBody.Parts.Body components, when quaternions shall be used
1812as parts of the body states.
1813Some functions are also used in a new Modelica package for
1814B-Spline interpolation that is able to interpolate paths consisting of
1815position vectors and orientation objects.
1816</p>
1817<h4>Content</h4>
1818<p>In the table below an example is given for every function definition.
1819The used variables have the following declaration:
1820</p>
1821<pre>
1822 Quaternions.Orientation Q, Q1, Q2, Q_rel, Q_inv;
1823 Real[3,3] T, T_inv;
1824 Real[3] v1, v2, w1, w2, n_x, n_y, n_z, res_ori, phi;
1825 Real[6] res_equal;
1826 Real L, angle;
1827</pre>
1828<table border=1 cellspacing=0 cellpadding=2>
1829 <tr><th><b><i>Function/type</i></b></th><th><b><i>Description</i></b></th></tr>
1830 <tr><td valign=\"top\"><b>Orientation Q;</b></td>
1831 <td valign=\"top\">New type defining a quaternion object that describes<br>
1832 the rotation of frame 1 into frame 2.
1833 </td>
1834 </tr>
1835 <tr><td valign=\"top\"><b>der_Orientation</b> der_Q;</td>
1836 <td valign=\"top\">New type defining the first time derivative
1837 of Frames.Quaternions.Orientation.
1838 </td>
1839 </tr>
1840 <tr><td valign=\"top\">res_ori = <b>orientationConstraint</b>(Q);</td>
1841 <td valign=\"top\">Return the constraints between the variables of a quaternion object<br>
1842 (shall be zero).</td>
1843 </tr>
1844 <tr><td valign=\"top\">w1 = <b>angularVelocity1</b>(Q, der_Q);</td>
1845 <td valign=\"top\">Return angular velocity resolved in frame 1 from
1846 quaternion object Q<br> and its derivative der_Q.
1847 </td>
1848 </tr>
1849 <tr><td valign=\"top\">w2 = <b>angularVelocity2</b>(Q, der_Q);</td>
1850 <td valign=\"top\">Return angular velocity resolved in frame 2 from
1851 quaternion object Q<br> and its derivative der_Q.
1852 </td>
1853 </tr>
1854 <tr><td valign=\"top\">v1 = <b>resolve1</b>(Q,v2);</td>
1855 <td valign=\"top\">Transform vector v2 from frame 2 to frame 1.
1856 </td>
1857 </tr>
1858 <tr><td valign=\"top\">v2 = <b>resolve2</b>(Q,v1);</td>
1859 <td valign=\"top\">Transform vector v1 from frame 1 to frame 2.
1860 </td>
1861 </tr>
1862 <tr><td valign=\"top\">[v1,w1] = <b>multipleResolve1</b>(Q, [v2,w2]);</td>
1863 <td valign=\"top\">Transform several vectors from frame 2 to frame 1.
1864 </td>
1865 </tr>
1866 <tr><td valign=\"top\">[v2,w2] = <b>multipleResolve2</b>(Q, [v1,w1]);</td>
1867 <td valign=\"top\">Transform several vectors from frame 1 to frame 2.
1868 </td>
1869 </tr>
1870 <tr><td valign=\"top\">Q = <b>nullRotation</b>()</td>
1871 <td valign=\"top\">Return quaternion object R that does not rotate a frame.
1872 </tr>
1873 <tr><td valign=\"top\">Q_inv = <b>inverseRotation</b>(Q);</td>
1874 <td valign=\"top\">Return inverse quaternion object.
1875 </td>
1876 </tr>
1877 <tr><td valign=\"top\">Q_rel = <b>relativeRotation</b>(Q1,Q2);</td>
1878 <td valign=\"top\">Return relative quaternion object from two absolute
1879 quaternion objects.
1880 </td>
1881 </tr>
1882 <tr><td valign=\"top\">Q2 = <b>absoluteRotation</b>(Q1,Q_rel);</td>
1883 <td valign=\"top\">Return absolute quaternion object from another
1884 absolute<br> and a relative quaternion object.
1885 </td>
1886 </tr>
1887 <tr><td valign=\"top\">Q = <b>planarRotation</b>(e, angle);</td>
1888 <td valign=\"top\">Return quaternion object of a planar rotation.
1889 </td>
1890 </tr>
1891 <tr><td valign=\"top\">phi = <b>smallRotation</b>(Q);</td>
1892 <td valign=\"top\">Return rotation angles phi valid for a small rotation.
1893 </td>
1894 </tr>
1895 <tr><td valign=\"top\">Q = <b>from_T</b>(T);</td>
1896 <td valign=\"top\">Return quaternion object Q from transformation matrix T.
1897 </td>
1898 </tr>
1899 <tr><td valign=\"top\">Q = <b>from_T_inv</b>(T_inv);</td>
1900 <td valign=\"top\">Return quaternion object Q from inverse transformation matrix T_inv.
1901 </td>
1902 </tr>
1903 <tr><td valign=\"top\">T = <b>to_T</b>(Q);</td>
1904 <td valign=\"top\">Return transformation matrix T from quaternion object Q.
1905 </tr>
1906 <tr><td valign=\"top\">T_inv = <b>to_T_inv</b>(Q);</td>
1907 <td valign=\"top\">Return inverse transformation matrix T_inv from quaternion object Q.
1908 </td>
1909 </tr>
1910</table>
1911</HTML>"));
1912 end Quaternions;
1913
1914 package TransformationMatrices "Functions for transformation matrices"
1915 extends Modelica.Icons.Library;
1916 type Orientation "Orientation type defining rotation from a frame 1 into a frame 2 with a transformation matrix"
1917 extends Internal.TransformationMatrix;
1918 encapsulated function equalityConstraint "Return the constraint residues to express that two frames have the same orientation"
1919 import Modelica;
1920 import Modelica.Mechanics.MultiBody.Frames.TransformationMatrices;
1921 extends Modelica.Icons.Function;
1922 input TransformationMatrices.Orientation T1 "Orientation object to rotate frame 0 into frame 1";
1923 input TransformationMatrices.Orientation T2 "Orientation object to rotate frame 0 into frame 2";
1924 annotation(Inline=true);
1925 output Real residue[3] "The rotation angles around x-, y-, and z-axis of frame 1 to rotate frame 1 into frame 2 for a small rotation (should be zero)";
1926 algorithm
1927 residue:={cross(T1[1,:], T1[2,:])*T2[2,:],-cross(T1[1,:], T1[2,:])*T2[1,:],T1[2,:]*T2[1,:]};
1928 end equalityConstraint;
1929
1930 annotation(Documentation(info="<html>
1931<p>
1932This type describes the <b>rotation</b> from a <b>frame 1</b> into a <b>frame 2</b>.
1933An instance <b>R</b> of type <b>Orientation</b> has the following interpretation:
1934</p>
1935<pre>
1936 <b>T</b> = [<b>e</b><sub>x</sub>, <b>e</b><sub>y</sub>, <b>e</b><sub>z</sub>];
1937 e.g., <b>T</b> = [1,0,0; 0,1,0; 0,0,1]
1938</pre>
1939<p>
1940where <b>e</b><sub>x</sub>,<b>e</b><sub>y</sub>,<b>e</b><sub>z</sub>
1941are unit vectors in the direction of the x-axis, y-axis, and z-axis
1942of frame 1, resolved in frame 2, respectively. Therefore, if <b>v</b><sub>1</sub>
1943is vector <b>v</b> resolved in frame 1 and <b>v</b><sub>2</sub> is
1944vector <b>v</b> resolved in frame 2, the following relationship holds:
1945</p>
1946<pre>
1947 <b>v</b><sub>2</sub> = <b>T</b> * <b>v</b><sub>1</sub>
1948</pre>
1949</p>
1950The <b>inverse</b> orientation
1951<b>T_inv</b> = <b>T</b><sup>T</sup> describes the rotation
1952from frame 2 into frame 1.
1953</p>
1954<p>
1955Since the orientation is described by 9 variables, there are
19566 constraints between these variables. These constraints
1957are defined in function <b>TransformationMatrices.orientationConstraint</b>.
1958</p>
1959<p>
1960Note, that in the MultiBody library the rotation object is
1961never directly accessed but only with the access functions provided
1962in package TransformationMatrices. As a consequence, other implementations of
1963Rotation can be defined by adapting this package correspondingly.
1964</p>
1965</html>
1966"));
1967 end Orientation;
1968
1969 function resolve1 "Transform vector from frame 2 to frame 1"
1970 extends Modelica.Icons.Function;
1971 input TransformationMatrices.Orientation T "Orientation object to rotate frame 1 into frame 2";
1972 input Real v2[3] "Vector in frame 2";
1973 output Real v1[3] "Vector in frame 1";
1974 annotation(Inline=true);
1975 algorithm
1976 v1:=transpose(T)*v2;
1977 end resolve1;
1978
1979 function resolve2 "Transform vector from frame 1 to frame 2"
1980 extends Modelica.Icons.Function;
1981 input TransformationMatrices.Orientation T "Orientation object to rotate frame 1 into frame 2";
1982 input Real v1[3] "Vector in frame 1";
1983 output Real v2[3] "Vector in frame 2";
1984 annotation(Inline=true);
1985 algorithm
1986 v2:=T*v1;
1987 end resolve2;
1988
1989 function absoluteRotation "Return absolute orientation object from another absolute and a relative orientation object"
1990 extends Modelica.Icons.Function;
1991 input TransformationMatrices.Orientation T1 "Orientation object to rotate frame 0 into frame 1";
1992 input TransformationMatrices.Orientation T_rel "Orientation object to rotate frame 1 into frame 2";
1993 output TransformationMatrices.Orientation T2 "Orientation object to rotate frame 0 into frame 2";
1994 annotation(Inline=true);
1995 algorithm
1996 T2:=T_rel*T1;
1997 end absoluteRotation;
1998
1999 function planarRotation "Return orientation object of a planar rotation"
2000 import Modelica.Math;
2001 extends Modelica.Icons.Function;
2002 input Real e[3](each final unit="1") "Normalized axis of rotation (must have length=1)";
2003 input Modelica.SIunits.Angle angle "Rotation angle to rotate frame 1 into frame 2 along axis e";
2004 output TransformationMatrices.Orientation T "Orientation object to rotate frame 1 into frame 2";
2005 annotation(Inline=true);
2006 algorithm
2007 T:=[e]*transpose([e]) + (identity(3) - [e]*transpose([e]))*Math.cos(angle) - skew(e)*Math.sin(angle);
2008 end planarRotation;
2009
2010 function axisRotation "Return rotation object to rotate around one frame axis"
2011 import Modelica.Math.*;
2012 extends Modelica.Icons.Function;
2013 input Integer axis(min=1, max=3) "Rotate around 'axis' of frame 1";
2014 input Modelica.SIunits.Angle angle "Rotation angle to rotate frame 1 into frame 2 along 'axis' of frame 1";
2015 output TransformationMatrices.Orientation T "Orientation object to rotate frame 1 into frame 2";
2016 annotation(Inline=true);
2017 algorithm
2018 T:=if axis == 1 then [1,0,0;0,cos(angle),sin(angle);0,-sin(angle),cos(angle)] else if axis == 2 then [cos(angle),0,-sin(angle);0,1,0;sin(angle),0,cos(angle)] else [cos(angle),sin(angle),0;-sin(angle),cos(angle),0;0,0,1];
2019 end axisRotation;
2020
2021 function from_nxy "Return orientation object from n_x and n_y vectors"
2022 extends Modelica.Icons.Function;
2023 input Real n_x[3](each final unit="1") "Vector in direction of x-axis of frame 2, resolved in frame 1";
2024 input Real n_y[3](each final unit="1") "Vector in direction of y-axis of frame 2, resolved in frame 1";
2025 output TransformationMatrices.Orientation T "Orientation object to rotate frame 1 into frame 2";
2026 protected
2027 Real abs_n_x=sqrt(n_x*n_x);
2028 Real e_x[3](each final unit="1")=if abs_n_x < 1e-10 then {1,0,0} else n_x/abs_n_x;
2029 Real n_z_aux[3](each final unit="1")=cross(e_x, n_y);
2030 Real n_y_aux[3](each final unit="1")=if n_z_aux*n_z_aux > 1e-06 then n_y else if abs(e_x[1]) > 1e-06 then {0,1,0} else {1,0,0};
2031 Real e_z_aux[3](each final unit="1")=cross(e_x, n_y_aux);
2032 Real e_z[3](each final unit="1")=e_z_aux/sqrt(e_z_aux*e_z_aux);
2033 algorithm
2034 T:={e_x,cross(e_z, e_x),e_z};
2035 annotation(Documentation(info="<html>
2036<p>
2037It is assumed that the two input vectors n_x and n_y are
2038resolved in frame 1 and are directed along the x and y axis
2039of frame 2 (i.e., n_x and n_y are orthogonal to each other)
2040The function returns the orientation object T to rotate from
2041frame 1 to frame 2.
2042</p>
2043<p>
2044The function is robust in the sense that it returns always
2045an orientation object T, even if n_y is not orthogonal to n_x.
2046This is performed in the following way:
2047</p>
2048<p>
2049If n_x and n_y are not orthogonal to each other, first a unit
2050vector e_y is determined that is orthogonal to n_x and is lying
2051in the plane spanned by n_x and n_y. If n_x and n_y are parallel
2052or nearly parallel to each other, a vector e_y is selected
2053arbitrarily such that e_x and e_y are orthogonal to each other.
2054</p>
2055</html>"));
2056 end from_nxy;
2057
2058 annotation(Documentation(info="<HTML>
2059<p>
2060Package <b>Frames.TransformationMatrices</b> contains type definitions and
2061functions to transform rotational frame quantities using
2062transformation matrices.
2063</p>
2064<h4>Content</h4>
2065<p>In the table below an example is given for every function definition.
2066The used variables have the following declaration:
2067</p>
2068<pre>
2069 Orientation T, T1, T2, T_rel, T_inv;
2070 Real[3] v1, v2, w1, w2, n_x, n_y, n_z, e, e_x, res_ori, phi;
2071 Real[6] res_equal;
2072 Real L, angle;
2073</pre>
2074<table border=1 cellspacing=0 cellpadding=2>
2075 <tr><th><b><i>Function/type</i></b></th><th><b><i>Description</i></b></th></tr>
2076 <tr><td valign=\"top\"><b>Orientation T;</b></td>
2077 <td valign=\"top\">New type defining an orientation object that describes<br>
2078 the rotation of frame 1 into frame 2.
2079 </td>
2080 </tr>
2081 <tr><td valign=\"top\"><b>der_Orientation</b> der_T;</td>
2082 <td valign=\"top\">New type defining the first time derivative
2083 of Frames.Orientation.
2084 </td>
2085 </tr>
2086 <tr><td valign=\"top\">res_ori = <b>orientationConstraint</b>(T);</td>
2087 <td valign=\"top\">Return the constraints between the variables of an orientation object<br>
2088 (shall be zero).</td>
2089 </tr>
2090 <tr><td valign=\"top\">w1 = <b>angularVelocity1</b>(T, der_T);</td>
2091 <td valign=\"top\">Return angular velocity resolved in frame 1 from
2092 orientation object T<br> and its derivative der_T.
2093 </td>
2094 </tr>
2095 <tr><td valign=\"top\">w2 = <b>angularVelocity2</b>(T, der_T);</td>
2096 <td valign=\"top\">Return angular velocity resolved in frame 2 from
2097 orientation object T<br> and its derivative der_T.
2098 </td>
2099 </tr>
2100 <tr><td valign=\"top\">v1 = <b>resolve1</b>(T,v2);</td>
2101 <td valign=\"top\">Transform vector v2 from frame 2 to frame 1.
2102 </td>
2103 </tr>
2104 <tr><td valign=\"top\">v2 = <b>resolve2</b>(T,v1);</td>
2105 <td valign=\"top\">Transform vector v1 from frame 1 to frame 2.
2106 </td>
2107 </tr>
2108 <tr><td valign=\"top\">[v1,w1] = <b>multipleResolve1</b>(T, [v2,w2]);</td>
2109 <td valign=\"top\">Transform several vectors from frame 2 to frame 1.
2110 </td>
2111 </tr>
2112 <tr><td valign=\"top\">[v2,w2] = <b>multipleResolve2</b>(T, [v1,w1]);</td>
2113 <td valign=\"top\">Transform several vectors from frame 1 to frame 2.
2114 </td>
2115 </tr>
2116 <tr><td valign=\"top\">D1 = <b>resolveDyade1</b>(T,D2);</td>
2117 <td valign=\"top\">Transform second order tensor D2 from frame 2 to frame 1.
2118 </td>
2119 </tr>
2120 <tr><td valign=\"top\">D2 = <b>resolveDyade2</b>(T,D1);</td>
2121 <td valign=\"top\">Transform second order tensor D1 from frame 1 to frame 2.
2122 </td>
2123 </tr>
2124 <tr><td valign=\"top\">T= <b>nullRotation</b>()</td>
2125 <td valign=\"top\">Return orientation object T that does not rotate a frame.
2126 </tr>
2127 <tr><td valign=\"top\">T_inv = <b>inverseRotation</b>(T);</td>
2128 <td valign=\"top\">Return inverse orientation object.
2129 </td>
2130 </tr>
2131 <tr><td valign=\"top\">T_rel = <b>relativeRotation</b>(T1,T2);</td>
2132 <td valign=\"top\">Return relative orientation object from two absolute
2133 orientation objects.
2134 </td>
2135 </tr>
2136 <tr><td valign=\"top\">T2 = <b>absoluteRotation</b>(T1,T_rel);</td>
2137 <td valign=\"top\">Return absolute orientation object from another
2138 absolute<br> and a relative orientation object.
2139 </td>
2140 </tr>
2141 <tr><td valign=\"top\">T = <b>planarRotation</b>(e, angle);</td>
2142 <td valign=\"top\">Return orientation object of a planar rotation.
2143 </td>
2144 </tr>
2145 <tr><td valign=\"top\">angle = <b>planarRotationAngle</b>(e, v1, v2);</td>
2146 <td valign=\"top\">Return angle of a planar rotation, given the rotation axis<br>
2147 and the representations of a vector in frame 1 and frame 2.
2148 </td>
2149 </tr>
2150 <tr><td valign=\"top\">T = <b>axisRotation</b>(i, angle);</td>
2151 <td valign=\"top\">Return orientation object T for rotation around axis i of frame 1.
2152 </td>
2153 </tr>
2154 <tr><td valign=\"top\">T = <b>axesRotations</b>(sequence, angles);</td>
2155 <td valign=\"top\">Return rotation object to rotate in sequence around 3 axes. Example:<br>
2156 T = axesRotations({1,2,3},{90,45,-90});
2157 </td>
2158 </tr>
2159 <tr><td valign=\"top\">angles = <b>axesRotationsAngles</b>(T, sequence);</td>
2160 <td valign=\"top\">Return the 3 angles to rotate in sequence around 3 axes to<br>
2161 construct the given orientation object.
2162 </td>
2163 </tr>
2164 <tr><td valign=\"top\">phi = <b>smallRotation</b>(T);</td>
2165 <td valign=\"top\">Return rotation angles phi valid for a small rotation.
2166 </td>
2167 </tr>
2168 <tr><td valign=\"top\">T = <b>from_nxy</b>(n_x, n_y);</td>
2169 <td valign=\"top\">Return orientation object from n_x and n_y vectors.
2170 </td>
2171 </tr>
2172 <tr><td valign=\"top\">T = <b>from_nxz</b>(n_x, n_z);</td>
2173 <td valign=\"top\">Return orientation object from n_x and n_z vectors.
2174 </td>
2175 </tr>
2176 <tr><td valign=\"top\">R = <b>from_T</b>(T);</td>
2177 <td valign=\"top\">Return orientation object R from transformation matrix T.
2178 </td>
2179 </tr>
2180 <tr><td valign=\"top\">R = <b>from_T_inv</b>(T_inv);</td>
2181 <td valign=\"top\">Return orientation object R from inverse transformation matrix T_inv.
2182 </td>
2183 </tr>
2184 <tr><td valign=\"top\">T = <b>from_Q</b>(Q);</td>
2185 <td valign=\"top\">Return orientation object T from quaternion orientation object Q.
2186 </td>
2187 </tr>
2188 <tr><td valign=\"top\">T = <b>to_T</b>(R);</td>
2189 <td valign=\"top\">Return transformation matrix T from orientation object R.
2190 </tr>
2191 <tr><td valign=\"top\">T_inv = <b>to_T_inv</b>(R);</td>
2192 <td valign=\"top\">Return inverse transformation matrix T_inv from orientation object R.
2193 </td>
2194 </tr>
2195 <tr><td valign=\"top\">Q = <b>to_Q</b>(T);</td>
2196 <td valign=\"top\">Return quaternione orientation object Q from orientation object T.
2197 </td>
2198 </tr>
2199 <tr><td valign=\"top\">exy = <b>to_exy</b>(T);</td>
2200 <td valign=\"top\">Return [e_x, e_y] matrix of an orientation object T, <br>
2201 with e_x and e_y vectors of frame 2, resolved in frame 1.
2202 </tr>
2203</table>
2204</HTML>"));
2205 end TransformationMatrices;
2206
2207 package Internal "Internal definitions that may be removed or changed (do not use)"
2208 extends Modelica.Icons.Library;
2209 type TransformationMatrix= Real[3,3];
2210 type QuaternionBase= Real[4];
2211 function resolve1_der "Derivative of function Frames.resolve1(..)"
2212 import Modelica.Mechanics.MultiBody.Frames;
2213 extends Modelica.Icons.Function;
2214 input Orientation R "Orientation object to rotate frame 1 into frame 2";
2215 input Real v2[3] "Vector resolved in frame 2";
2216 input Real v2_der[3] "= der(v2)";
2217 output Real v1_der[3] "Derivative of vector v resolved in frame 1";
2218 annotation(Inline=true);
2219 algorithm
2220 v1_der:=Frames.resolve1(R, v2_der + cross(R.w, v2));
2221 end resolve1_der;
2222
2223 function resolve2_der "Derivative of function Frames.resolve2(..)"
2224 import Modelica.Mechanics.MultiBody.Frames;
2225 extends Modelica.Icons.Function;
2226 input Orientation R "Orientation object to rotate frame 1 into frame 2";
2227 input Real v1[3] "Vector resolved in frame 1";
2228 input Real v1_der[3] "= der(v1)";
2229 output Real v2_der[3] "Derivative of vector v resolved in frame 2";
2230 annotation(Inline=true);
2231 algorithm
2232 v2_der:=Frames.resolve2(R, v1_der) - cross(R.w, Frames.resolve2(R, v1));
2233 end resolve2_der;
2234
2235 end Internal;
2236
2237 annotation(Documentation(info="<HTML>
2238<p>
2239Package <b>Frames</b> contains type definitions and
2240functions to transform rotational frame quantities. The basic idea is to
2241hide the actual definition of an <b>orientation</b> in this package
2242by providing essentially type <b>Orientation</b> together with
2243<b>functions</b> operating on instances of this type.
2244</p>
2245<h4>Content</h4>
2246<p>In the table below an example is given for every function definition.
2247The used variables have the following declaration:
2248</p>
2249<pre>
2250 Frames.Orientation R, R1, R2, R_rel, R_inv;
2251 Real[3,3] T, T_inv;
2252 Real[3] v1, v2, w1, w2, n_x, n_y, n_z, e, e_x, res_ori, phi;
2253 Real[6] res_equal;
2254 Real L, angle;
2255</pre>
2256<table border=1 cellspacing=0 cellpadding=2>
2257 <tr><th><b><i>Function/type</i></b></th><th><b><i>Description</i></b></th></tr>
2258 <tr><td valign=\"top\"><b>Orientation R;</b></td>
2259 <td valign=\"top\">New type defining an orientation object that describes<br>
2260 the rotation of frame 1 into frame 2.
2261 </td>
2262 </tr>
2263 <tr><td valign=\"top\">res_ori = <b>orientationConstraint</b>(R);</td>
2264 <td valign=\"top\">Return the constraints between the variables of an orientation object<br>
2265 (shall be zero).</td>
2266 </tr>
2267 <tr><td valign=\"top\">w1 = <b>angularVelocity1</b>(R);</td>
2268 <td valign=\"top\">Return angular velocity resolved in frame 1 from
2269 orientation object R.
2270 </td>
2271 </tr>
2272 <tr><td valign=\"top\">w2 = <b>angularVelocity2</b>(R);</td>
2273 <td valign=\"top\">Return angular velocity resolved in frame 2 from
2274 orientation object R.
2275 </td>
2276 </tr>
2277 <tr><td valign=\"top\">v1 = <b>resolve1</b>(R,v2);</td>
2278 <td valign=\"top\">Transform vector v2 from frame 2 to frame 1.
2279 </td>
2280 </tr>
2281 <tr><td valign=\"top\">v2 = <b>resolve2</b>(R,v1);</td>
2282 <td valign=\"top\">Transform vector v1 from frame 1 to frame 2.
2283 </td>
2284 </tr>
2285 <tr><td valign=\"top\">v2 = <b>resolveRelative</b>(v1,R1,R2);</td>
2286 <td valign=\"top\">Transform vector v1 from frame 1 to frame 2
2287 using absolute orientation objects R1 of frame 1 and R2 of frame 2.
2288 </td>
2289 </tr>
2290 <tr><td valign=\"top\">D1 = <b>resolveDyade1</b>(R,D2);</td>
2291 <td valign=\"top\">Transform second order tensor D2 from frame 2 to frame 1.
2292 </td>
2293 </tr>
2294 <tr><td valign=\"top\">D2 = <b>resolveDyade2</b>(R,D1);</td>
2295 <td valign=\"top\">Transform second order tensor D1 from frame 1 to frame 2.
2296 </td>
2297 </tr>
2298 <tr><td valign=\"top\">R = <b>nullRotation</b>()</td>
2299 <td valign=\"top\">Return orientation object R that does not rotate a frame.
2300 </tr>
2301 <tr><td valign=\"top\">R_inv = <b>inverseRotation</b>(R);</td>
2302 <td valign=\"top\">Return inverse orientation object.
2303 </td>
2304 </tr>
2305 <tr><td valign=\"top\">R_rel = <b>relativeRotation</b>(R1,R2);</td>
2306 <td valign=\"top\">Return relative orientation object from two absolute
2307 orientation objects.
2308 </td>
2309 </tr>
2310 <tr><td valign=\"top\">R2 = <b>absoluteRotation</b>(R1,R_rel);</td>
2311 <td valign=\"top\">Return absolute orientation object from another
2312 absolute<br> and a relative orientation object.
2313 </td>
2314 </tr>
2315 <tr><td valign=\"top\">R = <b>planarRotation</b>(e, angle, der_angle);</td>
2316 <td valign=\"top\">Return orientation object of a planar rotation.
2317 </td>
2318 </tr>
2319 <tr><td valign=\"top\">angle = <b>planarRotationAngle</b>(e, v1, v2);</td>
2320 <td valign=\"top\">Return angle of a planar rotation, given the rotation axis<br>
2321 and the representations of a vector in frame 1 and frame 2.
2322 </td>
2323 </tr>
2324 <tr><td valign=\"top\">R = <b>axisRotation</b>(axis, angle, der_angle);</td>
2325 <td valign=\"top\">Return orientation object R to rotate around angle along axis of frame 1.
2326 </td>
2327 </tr>
2328 <tr><td valign=\"top\">R = <b>axesRotations</b>(sequence, angles, der_angles);</td>
2329 <td valign=\"top\">Return rotation object to rotate in sequence around 3 axes. Example:<br>
2330 R = axesRotations({1,2,3},{pi/2,pi/4,-pi}, zeros(3));
2331 </td>
2332 </tr>
2333 <tr><td valign=\"top\">angles = <b>axesRotationsAngles</b>(R, sequence);</td>
2334 <td valign=\"top\">Return the 3 angles to rotate in sequence around 3 axes to<br>
2335 construct the given orientation object.
2336 </td>
2337 </tr>
2338 <tr><td valign=\"top\">phi = <b>smallRotation</b>(R);</td>
2339 <td valign=\"top\">Return rotation angles phi valid for a small rotation R.
2340 </td>
2341 </tr>
2342 <tr><td valign=\"top\">R = <b>from_nxy</b>(n_x, n_y);</td>
2343 <td valign=\"top\">Return orientation object from n_x and n_y vectors.
2344 </td>
2345 </tr>
2346 <tr><td valign=\"top\">R = <b>from_nxz</b>(n_x, n_z);</td>
2347 <td valign=\"top\">Return orientation object from n_x and n_z vectors.
2348 </td>
2349 </tr>
2350 <tr><td valign=\"top\">R = <b>from_T</b>(T,w);</td>
2351 <td valign=\"top\">Return orientation object R from transformation matrix T and
2352 its angular velocity w.
2353 </td>
2354 </tr>
2355 <tr><td valign=\"top\">R = <b>from_T2</b>(T,der(T));</td>
2356 <td valign=\"top\">Return orientation object R from transformation matrix T and
2357 its derivative der(T).
2358 </td>
2359 </tr>
2360 <tr><td valign=\"top\">R = <b>from_T_inv</b>(T_inv,w);</td>
2361 <td valign=\"top\">Return orientation object R from inverse transformation matrix T_inv and
2362 its angular velocity w.
2363 </td>
2364 </tr>
2365 <tr><td valign=\"top\">R = <b>from_Q</b>(Q,w);</td>
2366 <td valign=\"top\">Return orientation object R from quaternion orientation object Q
2367 and its angular velocity w.
2368 </td>
2369 </tr>
2370 <tr><td valign=\"top\">T = <b>to_T</b>(R);</td>
2371 <td valign=\"top\">Return transformation matrix T from orientation object R.
2372 </tr>
2373 <tr><td valign=\"top\">T_inv = <b>to_T_inv</b>(R);</td>
2374 <td valign=\"top\">Return inverse transformation matrix T_inv from orientation object R.
2375 </td>
2376 </tr>
2377 <tr><td valign=\"top\">Q = <b>to_Q</b>(R);</td>
2378 <td valign=\"top\">Return quaternione orientation object Q from orientation object R.
2379 </td>
2380 </tr>
2381 <tr><td valign=\"top\">exy = <b>to_exy</b>(R);</td>
2382 <td valign=\"top\">Return [e_x, e_y] matrix of an orientation object R, <br>
2383 with e_x and e_y vectors of frame 2, resolved in frame 1.
2384 </tr>
2385 <tr><td valign=\"top\">L = <b>length</b>(n_x);</td>
2386 <td valign=\"top\">Return length L of a vector n_x.
2387 </td>
2388 </tr>
2389 <tr><td valign=\"top\">e_x = <b>normalize</b>(n_x);</td>
2390 <td valign=\"top\">Return normalized vector e_x of n_x such that length of e_x is one.
2391 </td>
2392 </tr>
2393 <tr><td valign=\"top\">e = <b>axis</b>(i);</td>
2394 <td valign=\"top\">Return unit vector e directed along axis i
2395 </td>
2396 </tr>
2397 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Frames.Quaternions\">Quaternions</a></td>
2398 <td valign=\"top\"><b>Package</b> with functions to transform rotational frame quantities based
2399 on quaternions (also called Euler parameters).
2400 </td>
2401 </tr>
2402 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Mechanics.MultiBody.Frames.TransformationMatrices\">TransformationMatrices</a></td>
2403 <td valign=\"top\"><b>Package</b> with functions to transform rotational frame quantities based
2404 on transformation matrices.
2405 </td>
2406 </tr>
2407</table>
2408</HTML>"));
2409 end Frames;
2410
2411 end MultiBody;
2412
2413 end Mechanics;
2414
2415 package Math "Library of mathematical functions (e.g., sin, cos) and of functions operating on vectors and matrices"
2416 import SI = Modelica.SIunits;
2417 extends Modelica.Icons.Library2;
2418 package Vectors "Library of functions operating on vectors"
2419 extends Modelica.Icons.Library;
2420 function length "Return length of a vectorReturn length of a vector (better as norm(), if further symbolic processing is performed)"
2421 extends Modelica.Icons.Function;
2422 input Real v[:] "Vector";
2423 output Real result "Length of vector v";
2424 annotation(Inline=true, Documentation(info="<html>
2425<h4>Syntax</h4>
2426<blockquote><pre>
2427Vectors.<b>length</b>(v);
2428</pre></blockquote>
2429<h4>Description</h4>
2430<p>
2431The function call \"<code>Vectors.<b>length</b>(v)</code>\" returns the
2432<b>Euclidean length</b> \"<code>sqrt(v*v)</code>\" of vector v.
2433The function call is equivalent to Vectors.norm(v). The advantage of
2434length(v) over norm(v)\"is that function length(..) is implemented
2435in one statement and therefore the function is usually automatically
2436inlined. Further symbolic processing is therefore possible, which is
2437not the case with function norm(..).
2438</p>
2439<h4>Example</h4>
2440<blockquote><pre>
2441 v = {2, -4, -2, -1};
2442 <b>length</b>(v); // = 5
2443</pre></blockquote>
2444<h4>See also</h4>
2445<a href=\"Modelica://Modelica.Math.Vectors.norm\">Vectors.norm</a>
2446</html>"));
2447 algorithm
2448 result:=sqrt(v*v);
2449 end length;
2450
2451 function normalize "Return normalized vector such that length = 1Return normalized vector such that length = 1 and prevent zero-division for zero vector"
2452 extends Modelica.Icons.Function;
2453 input Real v[:] "Vector";
2454 input Real eps=100*Modelica.Constants.eps "if |v| < eps then result = v/eps";
2455 output Real result[size(v, 1)] "Input vector v normalized to length=1";
2456 annotation(Inline=true, Documentation(info="<html>
2457<h4>Syntax</h4>
2458<blockquote><pre>
2459Vectors.<b>normalize</b>(v);
2460Vectors.<b>normalize</b>(v,eps=100*Modelica.Constants.eps);
2461</pre></blockquote>
2462<h4>Description</h4>
2463<p>
2464The function call \"<code>Vectors.<b>normalize</b>(v)</code>\" returns the
2465<b>unit vector</b> \"<code>v/length(v)</code>\" of vector v.
2466If length(v) is close to zero (more precisely, if length(v) &lt; eps),
2467v/eps is returned in order to avoid
2468a division by zero. For many applications this is useful, because
2469often the unit vector <b>e</b> = <b>v</b>/length(<b>v</b>) is used to compute
2470a vector x*<b>e</b>, where the scalar x is in the order of length(<b>v</b>),
2471i.e., x*<b>e</b> is small, when length(<b>v</b>) is small and then
2472it is fine to replace <b>e</b> by <b>v</b> to avoid a division by zero.
2473</p>
2474<p>
2475Since the function is implemented in one statement,
2476it is usually inlined and therefore symbolic processing is
2477possible.
2478</p>
2479<h4>Example</h4>
2480<blockquote><pre>
2481 <b>normalize</b>({1,2,3}); // = {0.267, 0.534, 0.802}
2482 <b>normalize</b>({0,0,0}); // = {0,0,0}
2483</pre></blockquote>
2484<h4>See also</h4>
2485<a href=\"Modelica://Modelica.Math.Vectors.length\">Vectors.length</a>
2486</html>"));
2487 algorithm
2488 result:=smooth(0, if length(v) >= eps then v/length(v) else v/eps);
2489 end normalize;
2490
2491 annotation(preferedView="info", Documentation(info="<HTML>
2492<h4>Library content</h4>
2493<p>
2494This library provides functions operating on vectors:
2495</p>
2496<table border=1 cellspacing=0 cellpadding=2>
2497 <tr><th><i>Function</i></th>
2498 <th><i>Description</i></th>
2499 </tr>
2500 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Math.Vectors.isEqual\">isEqual</a>(v1, v2)</td>
2501 <td valign=\"top\">Determines whether two vectors have the same size and elements</td>
2502 </tr>
2503 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Math.Vectors.norm\">norm</a>(v,p)</td>
2504 <td valign=\"top\">p-norm of vector v</td>
2505 </tr>
2506 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Math.Vectors.length\">length</a>(v)</td>
2507 <td valign=\"top\">Length of vector v (= norm(v,2), but inlined and therefore usable in
2508 symbolic manipulations) </td>
2509 </tr>
2510 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Math.Vectors.normalize\">normalize</a>(v)</td>
2511 <td valign=\"top\">Return normalized vector such that length = 1 and prevent
2512 zero-division for zero vector</td>
2513 </tr>
2514 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Math.Vectors.reverse\">reverse</a>(v)</td>
2515 <td valign=\"top\">Reverse vector elements</td>
2516 </tr>
2517 <tr><td valign=\"top\"><a href=\"Modelica://Modelica.Math.Vectors.sort\">sort</a>(v)</td>
2518 <td valign=\"top\">Sort elements of vector in ascending or descending order</td>
2519 </tr>
2520</table>
2521<h4>See also</h4>
2522<a href=\"Modelica://Modelica.Math.Matrices\">Matrices</a>
2523</HTML>"));
2524 end Vectors;
2525
2526 function sin "Sine"
2527 extends baseIcon1;
2528 input SI.Angle u;
2529 output Real y;
2530
2531 external "C" y=sin(u) ;
2532 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Line(points={{-90,0},{68,0}}, color={192,192,192}),Polygon(points={{90,0},{68,8},{68,-8},{90,0}}, lineColor={192,192,192}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Line(points={{-80,0},{-68.7,34.2},{-61.5,53.1},{-55.1,66.4},{-49.4,74.6},{-43.8,79.1},{-38.2,79.8},{-32.6,76.6},{-26.9,69.7},{-21.3,59.4},{-14.9,44.1},{-6.83,21.2},{10.1,-30.8},{17.3,-50.2},{23.7,-64.2},{29.3,-73.1},{35,-78.4},{40.6,-80},{46.2,-77.6},{51.9,-71.5},{57.5,-61.9},{63.9,-47.2},{72,-24.8},{80,0}}, color={0,0,0}),Text(extent={{12,84},{84,36}}, lineColor={192,192,192}, textString="sin")}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Line(points={{-100,0},{84,0}}, color={95,95,95}),Polygon(points={{100,0},{84,6},{84,-6},{100,0}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid),Line(points={{-80,0},{-68.7,34.2},{-61.5,53.1},{-55.1,66.4},{-49.4,74.6},{-43.8,79.1},{-38.2,79.8},{-32.6,76.6},{-26.9,69.7},{-21.3,59.4},{-14.9,44.1},{-6.83,21.2},{10.1,-30.8},{17.3,-50.2},{23.7,-64.2},{29.3,-73.1},{35,-78.4},{40.6,-80},{46.2,-77.6},{51.9,-71.5},{57.5,-61.9},{63.9,-47.2},{72,-24.8},{80,0}}, color={0,0,255}, thickness=0.5),Text(extent={{-105,72},{-85,88}}, textString="1", lineColor={0,0,255}),Text(extent={{70,25},{90,5}}, textString="2*pi", lineColor={0,0,255}),Text(extent={{-103,-72},{-83,-88}}, textString="-1", lineColor={0,0,255}),Text(extent={{82,-6},{102,-26}}, lineColor={95,95,95}, textString="u"),Line(points={{-80,80},{-28,80}}, color={175,175,175}, smooth=Smooth.None),Line(points={{-80,-80},{50,-80}}, color={175,175,175}, smooth=Smooth.None)}), Documentation(info="<html>
2533<p>
2534This function returns y = sin(u), with -&infin; &lt; u &lt; &infin;:
2535</p>
2536
2537<p>
2538<img src=\"../Images/Math/sin.png\">
2539</p>
2540</html>"), Library="ModelicaExternalC");
2541 end sin;
2542
2543 function cos "Cosine"
2544 extends baseIcon1;
2545 input SI.Angle u;
2546 output Real y;
2547
2548 external "C" y=cos(u) ;
2549 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Line(points={{-90,0},{68,0}}, color={192,192,192}),Polygon(points={{90,0},{68,8},{68,-8},{90,0}}, lineColor={192,192,192}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Line(points={{-80,80},{-74.4,78.1},{-68.7,72.3},{-63.1,63},{-56.7,48.7},{-48.6,26.6},{-29.3,-32.5},{-22.1,-51.7},{-15.7,-65.3},{-10.1,-73.8},{-4.42,-78.8},{1.21,-79.9},{6.83,-77.1},{12.5,-70.6},{18.1,-60.6},{24.5,-45.7},{32.6,-23},{50.3,31.3},{57.5,50.7},{63.9,64.6},{69.5,73.4},{75.2,78.6},{80,80}}, color={0,0,0}),Text(extent={{-36,82},{36,34}}, lineColor={192,192,192}, textString="cos")}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Text(extent={{-103,72},{-83,88}}, textString="1", lineColor={0,0,255}),Text(extent={{-103,-72},{-83,-88}}, textString="-1", lineColor={0,0,255}),Text(extent={{70,25},{90,5}}, textString="2*pi", lineColor={0,0,255}),Line(points={{-100,0},{84,0}}, color={95,95,95}),Polygon(points={{98,0},{82,6},{82,-6},{98,0}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid),Line(points={{-80,80},{-74.4,78.1},{-68.7,72.3},{-63.1,63},{-56.7,48.7},{-48.6,26.6},{-29.3,-32.5},{-22.1,-51.7},{-15.7,-65.3},{-10.1,-73.8},{-4.42,-78.8},{1.21,-79.9},{6.83,-77.1},{12.5,-70.6},{18.1,-60.6},{24.5,-45.7},{32.6,-23},{50.3,31.3},{57.5,50.7},{63.9,64.6},{69.5,73.4},{75.2,78.6},{80,80}}, color={0,0,255}, thickness=0.5),Text(extent={{78,-6},{98,-26}}, lineColor={95,95,95}, textString="u"),Line(points={{-80,-80},{18,-80}}, color={175,175,175}, smooth=Smooth.None)}), Documentation(info="<html>
2550<p>
2551This function returns y = cos(u), with -&infin; &lt; u &lt; &infin;:
2552</p>
2553
2554<p>
2555<img src=\"../Images/Math/cos.png\">
2556</p>
2557</html>"), Library="ModelicaExternalC");
2558 end cos;
2559
2560 function asin "Inverse sine (-1 <= u <= 1)"
2561 extends baseIcon2;
2562 input Real u;
2563 output SI.Angle y;
2564
2565 external "C" y=asin(u) ;
2566 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Line(points={{-90,0},{68,0}}, color={192,192,192}),Polygon(points={{90,0},{68,8},{68,-8},{90,0}}, lineColor={192,192,192}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Line(points={{-80,-80},{-79.2,-72.8},{-77.6,-67.5},{-73.6,-59.4},{-66.3,-49.8},{-53.5,-37.3},{-30.2,-19.7},{37.4,24.8},{57.5,40.8},{68.7,52.7},{75.2,62.2},{77.6,67.5},{80,80}}, color={0,0,0}),Text(extent={{-88,78},{-16,30}}, lineColor={192,192,192}, textString="asin")}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Text(extent={{-40,-72},{-15,-88}}, textString="-pi/2", lineColor={0,0,255}),Text(extent={{-38,88},{-13,72}}, textString=" pi/2", lineColor={0,0,255}),Text(extent={{68,-9},{88,-29}}, textString="+1", lineColor={0,0,255}),Text(extent={{-90,21},{-70,1}}, textString="-1", lineColor={0,0,255}),Line(points={{-100,0},{84,0}}, color={95,95,95}),Polygon(points={{98,0},{82,6},{82,-6},{98,0}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid),Line(points={{-80,-80},{-79.2,-72.8},{-77.6,-67.5},{-73.6,-59.4},{-66.3,-49.8},{-53.5,-37.3},{-30.2,-19.7},{37.4,24.8},{57.5,40.8},{68.7,52.7},{75.2,62.2},{77.6,67.5},{80,80}}, color={0,0,255}, thickness=0.5),Text(extent={{82,24},{102,4}}, lineColor={95,95,95}, textString="u"),Line(points={{0,80},{86,80}}, color={175,175,175}, smooth=Smooth.None),Line(points={{80,86},{80,-10}}, color={175,175,175}, smooth=Smooth.None)}), Documentation(info="<html>
2567<p>
2568This function returns y = asin(u), with -1 &le; u &le; +1:
2569</p>
2570
2571<p>
2572<img src=\"../Images/Math/asin.png\">
2573</p>
2574</html>"), Library="ModelicaExternalC");
2575 end asin;
2576
2577 function atan2 "Four quadrant inverse tangent"
2578 extends baseIcon2;
2579 input Real u1;
2580 input Real u2;
2581 output SI.Angle y;
2582
2583 external "C" y=atan2(u1,u2) ;
2584 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Line(points={{-90,0},{68,0}}, color={192,192,192}),Polygon(points={{90,0},{68,8},{68,-8},{90,0}}, lineColor={192,192,192}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Line(points={{0,-80},{8.93,-67.2},{17.1,-59.3},{27.3,-53.6},{42.1,-49.4},{69.9,-45.8},{80,-45.1}}, color={0,0,0}),Line(points={{-80,-34.9},{-46.1,-31.4},{-29.4,-27.1},{-18.3,-21.5},{-10.3,-14.5},{-2.03,-3.17},{7.97,11.6},{15.5,19.4},{24.3,25},{39,30},{62.1,33.5},{80,34.9}}, color={0,0,0}),Line(points={{-80,45.1},{-45.9,48.7},{-29.1,52.9},{-18.1,58.6},{-10.2,65.8},{-1.82,77.2},{0,80}}, color={0,0,0}),Text(extent={{-90,-46},{-18,-94}}, lineColor={192,192,192}, textString="atan2")}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Line(points={{-100,0},{84,0}}, color={95,95,95}),Polygon(points={{96,0},{80,6},{80,-6},{96,0}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid),Line(points={{0,-80},{8.93,-67.2},{17.1,-59.3},{27.3,-53.6},{42.1,-49.4},{69.9,-45.8},{80,-45.1}}, color={0,0,255}, thickness=0.5),Line(points={{-80,-34.9},{-46.1,-31.4},{-29.4,-27.1},{-18.3,-21.5},{-10.3,-14.5},{-2.03,-3.17},{7.97,11.6},{15.5,19.4},{24.3,25},{39,30},{62.1,33.5},{80,34.9}}, color={0,0,255}, thickness=0.5),Line(points={{-80,45.1},{-45.9,48.7},{-29.1,52.9},{-18.1,58.6},{-10.2,65.8},{-1.82,77.2},{0,80}}, color={0,0,255}, thickness=0.5),Text(extent={{-32,89},{-10,74}}, textString="pi", lineColor={0,0,255}),Text(extent={{-32,-72},{-4,-88}}, textString="-pi", lineColor={0,0,255}),Text(extent={{0,55},{20,42}}, textString="pi/2", lineColor={0,0,255}),Line(points={{0,40},{-8,40}}, color={192,192,192}),Line(points={{0,-40},{-8,-40}}, color={192,192,192}),Text(extent={{0,-23},{20,-42}}, textString="-pi/2", lineColor={0,0,255}),Text(extent={{62,-4},{94,-26}}, lineColor={95,95,95}, textString="u1, u2"),Line(points={{-88,40},{86,40}}, color={175,175,175}, smooth=Smooth.None),Line(points={{-86,-40},{86,-40}}, color={175,175,175}, smooth=Smooth.None)}), Documentation(info="<HTML>
2585This function returns y = atan2(u1,u2) such that tan(y) = u1/u2 and
2586y is in the range -pi &lt; y &le; pi. u2 may be zero, provided
2587u1 is not zero. Usually u1, u2 is provided in such a form that
2588u1 = sin(y) and u2 = cos(y):
2589</p>
2590
2591<p>
2592<img src=\"../Images/Math/atan2.png\">
2593</p>
2594
2595</HTML>
2596"), Library="ModelicaExternalC");
2597 end atan2;
2598
2599 function exp "Exponential, base e"
2600 extends baseIcon2;
2601 input Real u;
2602 output Real y;
2603
2604 external "C" y=exp(u) ;
2605 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Line(points={{-90,-80.3976},{68,-80.3976}}, color={192,192,192}),Polygon(points={{90,-80.3976},{68,-72.3976},{68,-88.3976},{90,-80.3976}}, lineColor={192,192,192}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Line(points={{-80,-80},{-31,-77.9},{-6.03,-74},{10.9,-68.4},{23.7,-61},{34.2,-51.6},{43,-40.3},{50.3,-27.8},{56.7,-13.5},{62.3,2.23},{67.1,18.6},{72,38.2},{76,57.6},{80,80}}, color={0,0,0}),Text(extent={{-86,50},{-14,2}}, lineColor={192,192,192}, textString="exp")}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Line(points={{-100,-80.3976},{84,-80.3976}}, color={95,95,95}),Polygon(points={{98,-80.3976},{82,-74.3976},{82,-86.3976},{98,-80.3976}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid),Line(points={{-80,-80},{-31,-77.9},{-6.03,-74},{10.9,-68.4},{23.7,-61},{34.2,-51.6},{43,-40.3},{50.3,-27.8},{56.7,-13.5},{62.3,2.23},{67.1,18.6},{72,38.2},{76,57.6},{80,80}}, color={0,0,255}, thickness=0.5),Text(extent={{-31,72},{-11,88}}, textString="20", lineColor={0,0,255}),Text(extent={{-92,-81},{-72,-101}}, textString="-3", lineColor={0,0,255}),Text(extent={{66,-81},{86,-101}}, textString="3", lineColor={0,0,255}),Text(extent={{2,-69},{22,-89}}, textString="1", lineColor={0,0,255}),Text(extent={{78,-54},{98,-74}}, lineColor={95,95,95}, textString="u"),Line(points={{0,80},{88,80}}, color={175,175,175}, smooth=Smooth.None),Line(points={{80,84},{80,-84}}, color={175,175,175}, smooth=Smooth.None)}), Documentation(info="<html>
2606<p>
2607This function returns y = exp(u), with -&infin; &lt; u &lt; &infin;:
2608</p>
2609
2610<p>
2611<img src=\"../Images/Math/exp.png\">
2612</p>
2613</html>"), Library="ModelicaExternalC");
2614 end exp;
2615
2616 partial function baseIcon1 "Basic icon for mathematical function with y-axis on left side"
2617 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Line(points={{-80,-80},{-80,68}}, color={192,192,192}),Polygon(points={{-80,90},{-88,68},{-72,68},{-80,90}}, lineColor={192,192,192}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Text(extent={{-150,150},{150,110}}, textString="%name", lineColor={0,0,255})}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Line(points={{-80,80},{-88,80}}, color={95,95,95}),Line(points={{-80,-80},{-88,-80}}, color={95,95,95}),Line(points={{-80,-90},{-80,84}}, color={95,95,95}),Text(extent={{-75,104},{-55,84}}, lineColor={95,95,95}, textString="y"),Polygon(points={{-80,98},{-86,82},{-74,82},{-80,98}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid)}), Documentation(info="<html>
2618<p>
2619Icon for a mathematical function, consisting of an y-axis on the left side.
2620It is expected, that an x-axis is added and a plot of the function.
2621</p>
2622</html>"));
2623 end baseIcon1;
2624
2625 partial function baseIcon2 "Basic icon for mathematical function with y-axis in middle"
2626 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Line(points={{0,-80},{0,68}}, color={192,192,192}),Polygon(points={{0,90},{-8,68},{8,68},{0,90}}, lineColor={192,192,192}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Text(extent={{-150,150},{150,110}}, textString="%name", lineColor={0,0,255})}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={Line(points={{0,80},{-8,80}}, color={95,95,95}),Line(points={{0,-80},{-8,-80}}, color={95,95,95}),Line(points={{0,-90},{0,84}}, color={95,95,95}),Text(extent={{5,104},{25,84}}, lineColor={95,95,95}, textString="y"),Polygon(points={{0,98},{-6,82},{6,82},{0,98}}, lineColor={95,95,95}, fillColor={95,95,95}, fillPattern=FillPattern.Solid)}), Documentation(revisions="<html>
2627<p>
2628Icon for a mathematical function, consisting of an y-axis in the middle.
2629It is expected, that an x-axis is added and a plot of the function.
2630</p>
2631</html>"));
2632 end baseIcon2;
2633
2634 annotation(Invisible=true, Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Text(extent={{-59,-9},{42,-56}}, lineColor={0,0,0}, textString="f(x)")}), Documentation(info="<HTML>
2635<p>
2636This package contains <b>basic mathematical functions</b> (such as sin(..)),
2637as well as functions operating on <b>vectors</b> and <b>matrices</b>.
2638</p>
2639
2640<dl>
2641<dt><b>Main Author:</b>
2642<dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br>
2643 Deutsches Zentrum f&uuml;r Luft und Raumfahrt e.V. (DLR)<br>
2644 Institut f&uuml;r Robotik und Mechatronik<br>
2645 Postfach 1116<br>
2646 D-82230 Wessling<br>
2647 Germany<br>
2648 email: <A HREF=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</A><br>
2649</dl>
2650
2651<p>
2652Copyright &copy; 1998-2009, Modelica Association and DLR.
2653</p>
2654<p>
2655<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
2656under the terms of the <b>Modelica license</b>, see the license conditions
2657and the accompanying <b>disclaimer</b>
2658<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a>.</i>
2659</p><br>
2660</HTML>
2661", revisions="<html>
2662<ul>
2663<li><i>October 21, 2002</i>
2664 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
2665 and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
2666 Function tempInterpol2 added.</li>
2667<li><i>Oct. 24, 1999</i>
2668 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2669 Icons for icon and diagram level introduced.</li>
2670<li><i>June 30, 1999</i>
2671 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2672 Realized.</li>
2673</ul>
2674
2675</html>"));
2676 end Math;
2677
2678 package Blocks "Library of basic input/output control blocks (continuous, discrete, logical, table blocks)"
2679 import SI = Modelica.SIunits;
2680 extends Modelica.Icons.Library2;
2681 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-32,-6},{16,-35}}, lineColor={0,0,0}),Rectangle(extent={{-32,-56},{16,-85}}, lineColor={0,0,0}),Line(points={{16,-20},{49,-20},{49,-71},{16,-71}}, color={0,0,0}),Line(points={{-32,-72},{-64,-72},{-64,-21},{-32,-21}}, color={0,0,0}),Polygon(points={{16,-71},{29,-67},{29,-74},{16,-71}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Polygon(points={{-32,-21},{-46,-17},{-46,-25},{-32,-21}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid)}), Documentation(info="<html>
2682<p>
2683This library contains input/output blocks to build up block diagrams.
2684</p>
2685
2686<dl>
2687<dt><b>Main Author:</b>
2688<dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br>
2689 Deutsches Zentrum f&uuml;r Luft und Raumfahrt e. V. (DLR)<br>
2690 Oberpfaffenhofen<br>
2691 Postfach 1116<br>
2692 D-82230 Wessling<br>
2693 email: <A HREF=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</A><br>
2694</dl>
2695<p>
2696Copyright &copy; 1998-2009, Modelica Association and DLR.
2697</p>
2698<p>
2699<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
2700under the terms of the <b>Modelica license</b>, see the license conditions
2701and the accompanying <b>disclaimer</b>
2702<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a>.</i>
2703</p>
2704</HTML>
2705", revisions="<html>
2706<ul>
2707<li><i>June 23, 2004</i>
2708 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2709 Introduced new block connectors and adapated all blocks to the new connectors.
2710 Included subpackages Continuous, Discrete, Logical, Nonlinear from
2711 package ModelicaAdditions.Blocks.
2712 Included subpackage ModelicaAdditions.Table in Modelica.Blocks.Sources
2713 and in the new package Modelica.Blocks.Tables.
2714 Added new blocks to Blocks.Sources and Blocks.Logical.
2715 </li>
2716<li><i>October 21, 2002</i>
2717 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
2718 and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
2719 New subpackage Examples, additional components.
2720 </li>
2721<li><i>June 20, 2000</i>
2722 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and
2723 Michael Tiller:<br>
2724 Introduced a replaceable signal type into
2725 Blocks.Interfaces.RealInput/RealOutput:
2726<pre>
2727 replaceable type SignalType = Real
2728</pre>
2729 in order that the type of the signal of an input/output block
2730 can be changed to a physical type, for example:
2731<pre>
2732 Sine sin1(outPort(redeclare type SignalType=Modelica.SIunits.Torque))
2733</pre>
2734 </li>
2735<li><i>Sept. 18, 1999</i>
2736 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2737 Renamed to Blocks. New subpackages Math, Nonlinear.
2738 Additional components in subpackages Interfaces, Continuous
2739 and Sources. </li>
2740<li><i>June 30, 1999</i>
2741 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2742 Realized a first version, based on an existing Dymola library
2743 of Dieter Moormann and Hilding Elmqvist.</li>
2744</ul>
2745</html>"));
2746 package Math "Library of mathematical functions as input/output blocks"
2747 import Modelica.SIunits;
2748 import Modelica.Blocks.Interfaces;
2749 extends Modelica.Icons.Library;
2750 block Add "Output the sum of the two inputs"
2751 extends Interfaces.SI2SO;
2752 parameter Real k1=+1 "Gain of upper input";
2753 parameter Real k2=+1 "Gain of lower input";
2754 equation
2755 y=k1*u1 + k2*u2;
2756 annotation(Documentation(info="
2757<HTML>
2758<p>
2759This blocks computes output <b>y</b> as <i>sum</i> of the
2760two input signals <b>u1</b> and <b>u2</b>:
2761</p>
2762<pre>
2763 <b>y</b> = k1*<b>u1</b> + k2*<b>u2</b>;
2764</pre>
2765<p>
2766Example:
2767</p>
2768<pre>
2769 parameter: k1= +2, k2= -3
2770
2771 results in the following equations:
2772
2773 y = 2 * u1 - 3 * u2
2774</pre>
2775
2776</HTML>
2777"), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Text(extent={{-98,-52},{7,-92}}, lineColor={0,0,0}, textString="%k2"),Text(extent={{-100,90},{5,50}}, lineColor={0,0,0}, textString="%k1"),Text(extent={{-150,150},{150,110}}, textString="%name", lineColor={0,0,255}),Line(points={{-100,60},{-40,60},{-30,40}}, color={0,0,255}),Ellipse(extent={{-50,50},{50,-50}}, lineColor={0,0,255}),Line(points={{-100,-60},{-40,-60},{-30,-40}}, color={0,0,255}),Line(points={{-15,-25.99},{15,25.99}}, color={0,0,0}),Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Line(points={{50,0},{100,0}}, color={0,0,255}),Line(points={{-100,60},{-74,24},{-44,24}}, color={0,0,127}),Line(points={{-100,-60},{-74,-28},{-42,-28}}, color={0,0,127}),Ellipse(extent={{-50,50},{50,-50}}, lineColor={0,0,127}),Line(points={{50,0},{100,0}}, color={0,0,127}),Text(extent={{-38,34},{38,-34}}, lineColor={0,0,0}, textString="+"),Text(extent={{-100,52},{5,92}}, lineColor={0,0,0}, textString="%k1"),Text(extent={{-100,-52},{5,-92}}, lineColor={0,0,0}, textString="%k2")}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,255}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Text(extent={{-98,-52},{7,-92}}, lineColor={0,0,0}, textString="%k2"),Text(extent={{-100,90},{5,50}}, lineColor={0,0,0}, textString="%k1"),Line(points={{-100,60},{-40,60},{-30,40}}, color={0,0,255}),Ellipse(extent={{-50,50},{50,-50}}, lineColor={0,0,255}),Line(points={{-100,-60},{-40,-60},{-30,-40}}, color={0,0,255}),Line(points={{-15,-25.99},{15,25.99}}, color={0,0,0}),Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Line(points={{50,0},{100,0}}, color={0,0,255}),Line(points={{-100,60},{-74,24},{-44,24}}, color={0,0,127}),Line(points={{-100,-60},{-74,-28},{-42,-28}}, color={0,0,127}),Ellipse(extent={{-50,50},{50,-50}}, lineColor={0,0,127}),Line(points={{50,0},{100,0}}, color={0,0,127}),Text(extent={{-38,34},{38,-34}}, lineColor={0,0,0}, textString="+"),Text(extent={{-100,52},{5,92}}, lineColor={0,0,0}, textString="k1"),Text(extent={{-100,-52},{5,-92}}, lineColor={0,0,0}, textString="k2")}));
2778 end Add;
2779
2780 annotation(Documentation(info="
2781<HTML>
2782<p>
2783This package contains basic <b>mathematical operations</b>,
2784such as summation and multiplication, and basic <b>mathematical
2785functions</b>, such as <b>sqrt</b> and <b>sin</b>, as
2786input/output blocks. All blocks of this library can be either
2787connected with continuous blocks or with sampled-data blocks.
2788</p>
2789</HTML>
2790", revisions="<html>
2791<ul>
2792<li><i>October 21, 2002</i>
2793 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
2794 and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
2795 New blocks added: RealToInteger, IntegerToReal, Max, Min, Edge, BooleanChange, IntegerChange.</li>
2796<li><i>August 7, 1999</i>
2797 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2798 Realized (partly based on an existing Dymola library
2799 of Dieter Moormann and Hilding Elmqvist).
2800</li>
2801</ul>
2802</html>"));
2803 end Math;
2804
2805 package Interfaces "Library of connectors and partial models for input/output blocks"
2806 import Modelica.SIunits;
2807 extends Modelica.Icons.Library;
2808 connector RealInput= input Real "'input Real' as connector" annotation(defaultComponentName="u", Icon(graphics={Polygon(points={{-100,100},{100,0},{-100,-100},{-100,100}}, lineColor={0,0,127}, fillColor={0,0,127}, fillPattern=FillPattern.Solid)}, coordinateSystem(extent={{-100,-100},{100,100}}, preserveAspectRatio=true, initialScale=0.2)), Diagram(coordinateSystem(preserveAspectRatio=true, initialScale=0.2, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Polygon(points={{0,50},{100,0},{0,-50},{0,50}}, lineColor={0,0,127}, fillColor={0,0,127}, fillPattern=FillPattern.Solid),Text(extent={{-10,85},{-10,60}}, lineColor={0,0,127}, textString="%name")}), Documentation(info="<html>
2809<p>
2810Connector with one input signal of type Real.
2811</p>
2812</html>"));
2813 connector RealOutput= output Real "'output Real' as connector" annotation(defaultComponentName="y", Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Polygon(points={{-100,100},{100,0},{-100,-100},{-100,100}}, lineColor={0,0,127}, fillColor={255,255,255}, fillPattern=FillPattern.Solid)}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Polygon(points={{-100,50},{0,0},{-100,-50},{-100,50}}, lineColor={0,0,127}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Text(extent={{30,110},{30,60}}, lineColor={0,0,127}, textString="%name")}), Documentation(info="<html>
2814<p>
2815Connector with one output signal of type Real.
2816</p>
2817</html>"));
2818 partial block BlockIcon "Basic graphical layout of input/output block"
2819 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Text(extent={{-150,150},{150,110}}, textString="%name", lineColor={0,0,255})}), Documentation(info="<html>
2820<p>
2821Block that has only the basic icon for an input/output
2822block (no declarations, no equations). Most blocks
2823of package Modelica.Blocks inherit directly or indirectly
2824from this block.
2825</p>
2826</html>"));
2827 end BlockIcon;
2828
2829 partial block SI2SO "2 Single Input / 1 Single Output continuous control block"
2830 extends BlockIcon;
2831 RealInput u1 "Connector of Real input signal 1" annotation(Placement(transformation(extent={{-140,40},{-100,80}}, rotation=0)));
2832 RealInput u2 "Connector of Real input signal 2" annotation(Placement(transformation(extent={{-140,-80},{-100,-40}}, rotation=0)));
2833 RealOutput y "Connector of Real output signal" annotation(Placement(transformation(extent={{100,-10},{120,10}}, rotation=0)));
2834 annotation(Documentation(info="<html>
2835<p>
2836Block has two continuous Real input signals u1 and u2 and one
2837continuous Real output signal y.
2838</p>
2839</html>"), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics));
2840 end SI2SO;
2841
2842 annotation(Documentation(info="<HTML>
2843<p>
2844This package contains interface definitions for
2845<b>continuous</b> input/output blocks with Real,
2846Integer and Boolean signals. Furthermore, it contains
2847partial models for continuous and discrete blocks.
2848</p>
2849
2850</HTML>
2851", revisions="<html>
2852<ul>
2853<li><i>Oct. 21, 2002</i>
2854 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
2855 and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
2856 Added several new interfaces. <a href=\"../Documentation/ChangeNotes1.5.html\">Detailed description</a> available.
2857<li><i>Oct. 24, 1999</i>
2858 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2859 RealInputSignal renamed to RealInput. RealOutputSignal renamed to
2860 output RealOutput. GraphBlock renamed to BlockIcon. SISOreal renamed to
2861 SISO. SOreal renamed to SO. I2SOreal renamed to M2SO.
2862 SignalGenerator renamed to SignalSource. Introduced the following
2863 new models: MIMO, MIMOs, SVcontrol, MVcontrol, DiscreteBlockIcon,
2864 DiscreteBlock, DiscreteSISO, DiscreteMIMO, DiscreteMIMOs,
2865 BooleanBlockIcon, BooleanSISO, BooleanSignalSource, MI2BooleanMOs.</li>
2866<li><i>June 30, 1999</i>
2867 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2868 Realized a first version, based on an existing Dymola library
2869 of Dieter Moormann and Hilding Elmqvist.</li>
2870</ul>
2871</html>
2872"));
2873 end Interfaces;
2874
2875 end Blocks;
2876
2877 package SIunits "Library of type and unit definitions based on SI units according to ISO 31-1992"
2878 extends Modelica.Icons.Library2;
2879 package Conversions "Conversion functions to/from non SI units and type definitions of non SI units"
2880 extends Modelica.Icons.Library2;
2881 package NonSIunits "Type definitions of non SI units"
2882 extends Modelica.Icons.Library2;
2883 type Temperature_degC= Real(final quantity="ThermodynamicTemperature", final unit="degC") "Absolute temperature in degree Celsius (for relative temperature use SIunits.TemperatureDifference)" annotation(__Dymola_absoluteValue=true);
2884 type Angle_deg= Real(final quantity="Angle", final unit="deg") "Angle in degree";
2885 annotation(Documentation(info="<HTML>
2886<p>
2887This package provides predefined types, such as <b>Angle_deg</b> (angle in
2888degree), <b>AngularVelocity_rpm</b> (angular velocity in revolutions per
2889minute) or <b>Temperature_degF</b> (temperature in degree Fahrenheit),
2890which are in common use but are not part of the international standard on
2891units according to ISO 31-1992 \"General principles concerning quantities,
2892units and symbols\" and ISO 1000-1992 \"SI units and recommendations for
2893the use of their multiples and of certain other units\".</p>
2894<p>If possible, the types in this package should not be used. Use instead
2895types of package Modelica.SIunits. For more information on units, see also
2896the book of Francois Cardarelli <b>Scientific Unit Conversion - A
2897Practical Guide to Metrication</b> (Springer 1997).</p>
2898<p>Some units, such as <b>Temperature_degC/Temp_C</b> are both defined in
2899Modelica.SIunits and in Modelica.Conversions.NonSIunits. The reason is that these
2900definitions have been placed erroneously in Modelica.SIunits although they
2901are not SIunits. For backward compatibility, these type definitions are
2902still kept in Modelica.SIunits.</p>
2903</HTML>
2904"), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Text(extent={{-66,-13},{52,-67}}, lineColor={0,0,0}, textString="[km/h]")}));
2905 end NonSIunits;
2906
2907 function from_deg "Convert from degree to radian"
2908 extends ConversionIcon;
2909 input NonSIunits.Angle_deg degree "degree value";
2910 output Angle radian "radian value";
2911 algorithm
2912 radian:=Modelica.Constants.pi/180.0*degree;
2913 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Text(extent={{-20,100},{-100,20}}, lineColor={0,0,0}, textString="deg"),Text(extent={{100,-20},{20,-100}}, lineColor={0,0,0}, textString="rad")}));
2914 end from_deg;
2915
2916 partial function ConversionIcon "Base icon for conversion functions"
2917 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,100},{100,-100}}, lineColor={191,0,0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Line(points={{-90,0},{30,0}}, color={191,0,0}),Polygon(points={{90,0},{30,20},{30,-20},{90,0}}, lineColor={191,0,0}, fillColor={191,0,0}, fillPattern=FillPattern.Solid),Text(extent={{-115,155},{115,105}}, textString="%name", lineColor={0,0,255})}));
2918 end ConversionIcon;
2919
2920 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Text(extent={{-33,-7},{-92,-67}}, lineColor={0,0,0}, lineThickness=1, textString="°C"),Text(extent={{82,-7},{22,-67}}, lineColor={0,0,0}, textString="K"),Line(points={{-26,-36},{6,-36}}, color={0,0,0}),Polygon(points={{6,-28},{6,-45},{26,-37},{6,-28}}, pattern=LinePattern.None, fillColor={0,0,0}, fillPattern=FillPattern.Solid, lineColor={0,0,255})}), Documentation(info="<HTML>
2921<p>This package provides conversion functions from the non SI Units
2922defined in package Modelica.SIunits.Conversions.NonSIunits to the
2923corresponding SI Units defined in package Modelica.SIunits and vice
2924versa. It is recommended to use these functions in the following
2925way (note, that all functions have one Real input and one Real output
2926argument):</p>
2927<pre>
2928 <b>import</b> SI = Modelica.SIunits;
2929 <b>import</b> Modelica.SIunits.Conversions.*;
2930 ...
2931 <b>parameter</b> SI.Temperature T = from_degC(25); // convert 25 degree Celsius to Kelvin
2932 <b>parameter</b> SI.Angle phi = from_deg(180); // convert 180 degree to radian
2933 <b>parameter</b> SI.AngularVelocity w = from_rpm(3600); // convert 3600 revolutions per minutes
2934 // to radian per seconds
2935</pre>
2936
2937</HTML>
2938"));
2939 end Conversions;
2940
2941 type Angle= Real(final quantity="Angle", final unit="rad", displayUnit="deg");
2942 type Length= Real(final quantity="Length", final unit="m");
2943 type Position= Length;
2944 type Distance= Length(min=0);
2945 type Diameter= Length(min=0);
2946 type AngularVelocity= Real(final quantity="AngularVelocity", final unit="rad/s");
2947 type AngularAcceleration= Real(final quantity="AngularAcceleration", final unit="rad/s2");
2948 type Velocity= Real(final quantity="Velocity", final unit="m/s");
2949 type Acceleration= Real(final quantity="Acceleration", final unit="m/s2");
2950 type Mass= Real(quantity="Mass", final unit="kg", min=0);
2951 type MomentOfInertia= Real(final quantity="MomentOfInertia", final unit="kg.m2");
2952 type Inertia= MomentOfInertia;
2953 type Force= Real(final quantity="Force", final unit="N");
2954 type Torque= Real(final quantity="Torque", final unit="N.m");
2955 type FaradayConstant= Real(final quantity="FaradayConstant", final unit="C/mol");
2956 annotation(Invisible=true, Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Text(extent={{-63,-13},{45,-67}}, lineColor={0,0,0}, textString="[kg.m2]")}), Documentation(info="<html>
2957<p>This package provides predefined types, such as <i>Mass</i>,
2958<i>Angle</i>, <i>Time</i>, based on the international standard
2959on units, e.g.,
2960</p>
2961
2962<pre> <b>type</b> Angle = Real(<b>final</b> quantity = \"Angle\",
2963 <b>final</b> unit = \"rad\",
2964 displayUnit = \"deg\");
2965</pre>
2966
2967<p>
2968as well as conversion functions from non SI-units to SI-units
2969and vice versa in subpackage
2970<a href=\"Modelica://Modelica.SIunits.Conversions\">Conversions</a>.
2971</p>
2972
2973<p>
2974For an introduction how units are used in the Modelica standard library
2975with package SIunits, have a look at:
2976<a href=\"Modelica://Modelica.SIunits.UsersGuide.HowToUseSIunits\">How to use SIunits</a>.
2977</p>
2978
2979<p>
2980Copyright &copy; 1998-2009, Modelica Association and DLR.
2981</p>
2982<p>
2983<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
2984under the terms of the <b>Modelica license</b>, see the license conditions
2985and the accompanying <b>disclaimer</b>
2986<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a>.</i>
2987</p>
2988
2989</html>", revisions="<html>
2990<ul>
2991<li><i>Dec. 14, 2005</i>
2992 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
2993 Add User's Guide and removed \"min\" values for Resistance and Conductance.</li>
2994<li><i>October 21, 2002</i>
2995 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
2996 and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
2997 Added new package <b>Conversions</b>. Corrected typo <i>Wavelenght</i>.</li>
2998<li><i>June 6, 2000</i>
2999 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3000 Introduced the following new types<br>
3001 type Temperature = ThermodynamicTemperature;<br>
3002 types DerDensityByEnthalpy, DerDensityByPressure,
3003 DerDensityByTemperature, DerEnthalpyByPressure,
3004 DerEnergyByDensity, DerEnergyByPressure<br>
3005 Attribute \"final\" removed from min and max values
3006 in order that these values can still be changed to narrow
3007 the allowed range of values.<br>
3008 Quantity=\"Stress\" removed from type \"Stress\", in order
3009 that a type \"Stress\" can be connected to a type \"Pressure\".</li>
3010<li><i>Oct. 27, 1999</i>
3011 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3012 New types due to electrical library: Transconductance, InversePotential,
3013 Damping.</li>
3014<li><i>Sept. 18, 1999</i>
3015 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3016 Renamed from SIunit to SIunits. Subpackages expanded, i.e., the
3017 SIunits package, does no longer contain subpackages.</li>
3018<li><i>Aug 12, 1999</i>
3019 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3020 Type \"Pressure\" renamed to \"AbsolutePressure\" and introduced a new
3021 type \"Pressure\" which does not contain a minimum of zero in order
3022 to allow convenient handling of relative pressure. Redefined
3023 BulkModulus as an alias to AbsolutePressure instead of Stress, since
3024 needed in hydraulics.</li>
3025<li><i>June 29, 1999</i>
3026 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3027 Bug-fix: Double definition of \"Compressibility\" removed
3028 and appropriate \"extends Heat\" clause introduced in
3029 package SolidStatePhysics to incorporate ThermodynamicTemperature.</li>
3030<li><i>April 8, 1998</i>
3031 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
3032 and Astrid Jaschinski:<br>
3033 Complete ISO 31 chapters realized.</li>
3034<li><i>Nov. 15, 1997</i>
3035 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
3036 and <a href=\"http://www.control.lth.se/~hubertus/\">Hubertus Tummescheit</a>:<br>
3037 Some chapters realized.</li>
3038</ul>
3039</html>"), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{169,86},{349,236}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{169,236},{189,256},{369,256},{349,236},{169,236}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{369,256},{369,106},{349,86},{349,236},{369,256}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Text(extent={{179,226},{339,196}}, lineColor={160,160,164}, textString="Library"),Text(extent={{206,173},{314,119}}, lineColor={0,0,0}, textString="[kg.m2]"),Text(extent={{163,320},{406,264}}, lineColor={255,0,0}, textString="Modelica.SIunits")}));
3040 end SIunits;
3041
3042 package Icons "Library of icons"
3043 partial package Library "Icon for library"
3044 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Rectangle(extent={{-100,-100},{80,50}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{-100,50},{-80,70},{100,70},{80,50},{-100,50}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{100,70},{100,-80},{80,-100},{80,50},{100,70}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Text(extent={{-85,35},{65,-85}}, lineColor={0,0,255}, textString="Library"),Text(extent={{-120,122},{120,73}}, lineColor={255,0,0}, textString="%name")}), Documentation(info="<html>
3045<p>
3046This icon is designed for a <b>library</b>.
3047</p>
3048</html>"));
3049 end Library;
3050
3051 partial package Library2 "Icon for library where additional icon elements shall be added"
3052 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Rectangle(extent={{-100,-100},{80,50}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{-100,50},{-80,70},{100,70},{80,50},{-100,50}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{100,70},{100,-80},{80,-100},{80,50},{100,70}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Text(extent={{-120,125},{120,70}}, lineColor={255,0,0}, textString="%name"),Text(extent={{-90,40},{70,10}}, lineColor={160,160,164}, textString="Library")}), Documentation(info="<html>
3053<p>
3054This icon is designed for a <b>package</b> where a package
3055specific graphic is additionally included in the icon.
3056</p>
3057</html>"));
3058 end Library2;
3059
3060 partial model Example "Icon for an example model"
3061 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Rectangle(extent={{-100,-100},{80,50}}, fillColor={255,255,255}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{-100,50},{-80,70},{100,70},{80,50},{-100,50}}, fillColor={255,255,255}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{100,70},{100,-80},{80,-100},{80,50},{100,70}}, fillColor={255,255,255}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Text(extent={{-96,3},{77,-49}}, lineColor={0,0,255}, textString="Example"),Text(extent={{-120,132},{120,73}}, lineColor={255,0,0}, textString="%name")}), Documentation(info="<html>
3062<p>
3063This icon is designed for an <b>Example package</b>,
3064i.e. a package containing executable demo models.
3065</p>
3066</html>"));
3067 end Example;
3068
3069 partial function Function "Icon for a function"
3070 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Text(extent={{-140,162},{136,102}}, textString="%name", lineColor={0,0,255}),Ellipse(extent={{-100,100},{100,-100}}, lineColor={255,127,0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Text(extent={{-100,100},{100,-100}}, lineColor={255,127,0}, textString="f")}), Documentation(info="<html>
3071<p>
3072This icon is designed for a <b>function</b>
3073</p>
3074</html>"));
3075 end Function;
3076
3077 partial record Record "Icon for a record"
3078 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,50},{100,-100}}, fillColor={255,255,127}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Text(extent={{-127,115},{127,55}}, textString="%name", lineColor={0,0,255}),Line(points={{-100,-50},{100,-50}}, color={0,0,0}),Line(points={{-100,0},{100,0}}, color={0,0,0}),Line(points={{0,50},{0,-100}}, color={0,0,0})}), Documentation(info="<html>
3079<p>
3080This icon is designed for a <b>record</b>
3081</p>
3082</html>"));
3083 end Record;
3084
3085 type TypeReal "Icon for a Real type"
3086 extends Real;
3087 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}, fillColor={181,181,181}, fillPattern=FillPattern.Solid),Text(extent={{-94,94},{94,-94}}, lineColor={0,0,0}, textString="R")}), Documentation(info="<html>
3088<p>
3089This icon is designed for a <b>Real</b> type.
3090</p>
3091</html>"));
3092 end TypeReal;
3093
3094 type TypeInteger "Icon for an Integer type"
3095 extends Integer;
3096 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}, fillColor={181,181,181}, fillPattern=FillPattern.Solid),Text(extent={{-94,94},{94,-94}}, lineColor={0,0,0}, textString="I")}), Documentation(info="<html>
3097<p>
3098This icon is designed for an <b>Integer</b> type.
3099</p>
3100</html>"));
3101 end TypeInteger;
3102
3103 type TypeString "Icon for a String type"
3104 extends String;
3105 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}, fillColor={181,181,181}, fillPattern=FillPattern.Solid),Text(extent={{-94,94},{94,-94}}, lineColor={0,0,0}, textString="S")}), Documentation(info="<html>
3106<p>
3107This icon is designed for a <b>String</b> type.
3108</p>
3109</html>"));
3110 end TypeString;
3111
3112 partial model RotationalSensor "Icon representing rotational measurement device"
3113 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Ellipse(extent={{-70,70},{70,-70}}, lineColor={0,0,0}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Line(points={{0,70},{0,40}}, color={0,0,0}),Line(points={{22.9,32.8},{40.2,57.3}}, color={0,0,0}),Line(points={{-22.9,32.8},{-40.2,57.3}}, color={0,0,0}),Line(points={{37.6,13.7},{65.8,23.9}}, color={0,0,0}),Line(points={{-37.6,13.7},{-65.8,23.9}}, color={0,0,0}),Line(points={{0,0},{9.02,28.6}}, color={0,0,0}),Polygon(points={{-0.48,31.6},{18,26},{18,57.2},{-0.48,31.6}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid),Ellipse(extent={{-5,5},{5,-5}}, lineColor={0,0,0}, fillColor={0,0,0}, fillPattern=FillPattern.Solid)}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics), Documentation(info="<html>
3114<p>
3115This icon is designed for a <b>rotational sensor</b> model.
3116</p>
3117</html>"));
3118 end RotationalSensor;
3119
3120 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-100,-100},{80,50}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{-100,50},{-80,70},{100,70},{80,50},{-100,50}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{100,70},{100,-80},{80,-100},{80,50},{100,70}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Text(extent={{-120,135},{120,70}}, lineColor={255,0,0}, textString="%name"),Text(extent={{-90,40},{70,10}}, lineColor={160,160,164}, textString="Library"),Rectangle(extent={{-100,-100},{80,50}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{-100,50},{-80,70},{100,70},{80,50},{-100,50}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{100,70},{100,-80},{80,-100},{80,50},{100,70}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Text(extent={{-90,40},{70,10}}, lineColor={160,160,164}, textString="Library"),Polygon(points={{-64,-20},{-50,-4},{50,-4},{36,-20},{-64,-20},{-64,-20}}, lineColor={0,0,0}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Rectangle(extent={{-64,-20},{36,-84}}, lineColor={0,0,0}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Text(extent={{-60,-24},{32,-38}}, lineColor={128,128,128}, textString="Library"),Polygon(points={{50,-4},{50,-70},{36,-84},{36,-20},{50,-4}}, lineColor={0,0,0}, fillColor={192,192,192}, fillPattern=FillPattern.Solid)}), Documentation(info="<html>
3121<p>
3122This package contains definitions for the graphical layout of
3123components which may be used in different libraries.
3124The icons can be utilized by inheriting them in the desired class
3125using \"extends\" or by directly copying the \"icon\" layer.
3126</p>
3127
3128<dl>
3129<dt><b>Main Author:</b>
3130<dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br>
3131 Deutsches Zentrum fuer Luft und Raumfahrt e.V. (DLR)<br>
3132 Oberpfaffenhofen<br>
3133 Postfach 1116<br>
3134 D-82230 Wessling<br>
3135 email: <A HREF=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</A><br>
3136</dl>
3137
3138<p>
3139Copyright &copy; 1998-2009, Modelica Association and DLR.
3140</p>
3141<p>
3142<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
3143under the terms of the <b>Modelica license</b>, see the license conditions
3144and the accompanying <b>disclaimer</b>
3145<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a>.</i>
3146</p><br>
3147</HTML>
3148", revisions="<html>
3149<ul>
3150<li><i>October 21, 2002</i>
3151 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
3152 and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
3153 Added new icons <b>Function</b>, <b>Enumerations</b> and <b>Record</b>.</li>
3154<li><i>June 6, 2000</i>
3155 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3156 Replaced <b>model</b> keyword by <b>package</b> if the main
3157 usage is for inheriting from a package.<br>
3158 New icons <b>GearIcon</b> and <b>MotorIcon</b>.</li>
3159<li><i>Sept. 18, 1999</i>
3160 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3161 Renaming package Icon to Icons.
3162 Model Advanced removed (icon not accepted on the Modelica meeting).
3163 New model Library2, which is the Library icon with enough place
3164 to add library specific elements in the icon. Icon also used in diagram
3165 level for models Info, TranslationalSensor, RotationalSensor.</li>
3166<li><i>July 15, 1999</i>
3167 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3168 Model Caution renamed to Advanced, model Sensor renamed to
3169 TranslationalSensor, new model RotationalSensor.</li>
3170<li><i>June 30, 1999</i>
3171 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3172 Realized a first version.</li>
3173</ul>
3174<br>
3175</html>"));
3176 end Icons;
3177
3178 package Constants "Library of mathematical constants and constants of nature (e.g., pi, eps, R, sigma)"
3179 import SI = Modelica.SIunits;
3180 import NonSI = Modelica.SIunits.Conversions.NonSIunits;
3181 extends Modelica.Icons.Library2;
3182 final constant Real e=Modelica.Math.exp(1.0);
3183 final constant Real pi=2*Modelica.Math.asin(1.0);
3184 final constant Real D2R=pi/180 "Degree to Radian";
3185 final constant Real R2D=180/pi "Radian to Degree";
3186 final constant Real eps=1e-15 "Biggest number such that 1.0 + eps = 1.0";
3187 final constant Real small=1e-60 "Smallest number such that small and -small are representable on the machine";
3188 final constant Real inf=1e+60 "Biggest Real number such that inf and -inf are representable on the machine";
3189 final constant Integer Integer_inf=1073741823 "Biggest Integer number such that Integer_inf and -Integer_inf are representable on the machine";
3190 final constant SI.Velocity c=299792458 "Speed of light in vacuum";
3191 final constant SI.Acceleration g_n=9.80665 "Standard acceleration of gravity on earth";
3192 final constant Real G(final unit="m3/(kg.s2)")=6.6742e-11 "Newtonian constant of gravitation";
3193 final constant SI.FaradayConstant F=96485.3399 "Faraday constant, C/mol";
3194 final constant Real h(final unit="J.s")=6.6260693e-34 "Planck constant";
3195 final constant Real k(final unit="J/K")=1.3806505e-23 "Boltzmann constant";
3196 final constant Real R(final unit="J/(mol.K)")=8.314472 "Molar gas constant";
3197 final constant Real sigma(final unit="W/(m2.K4)")=5.6704e-08 "Stefan-Boltzmann constant";
3198 final constant Real N_A(final unit="1/mol")=6.0221415e+23 "Avogadro constant";
3199 final constant Real mue_0(final unit="N/A2")=4*pi*1e-07 "Magnetic constant";
3200 final constant Real epsilon_0(final unit="F/m")=1/(mue_0*c*c) "Electric constant";
3201 final constant NonSI.Temperature_degC T_zero=-273.15 "Absolute zero temperature";
3202 annotation(Documentation(info="<html>
3203<p>
3204This package provides often needed constants from mathematics, machine
3205dependent constants and constants from nature. The latter constants
3206(name, value, description) are from the following source:
3207</p>
3208
3209<dl>
3210<dt>Peter J. Mohr and Barry N. Taylor (1999):</dt>
3211<dd><b>CODATA Recommended Values of the Fundamental Physical Constants: 1998</b>.
3212 Journal of Physical and Chemical Reference Data, Vol. 28, No. 6, 1999 and
3213 Reviews of Modern Physics, Vol. 72, No. 2, 2000. See also <a href=
3214\"http://physics.nist.gov/cuu/Constants/\">http://physics.nist.gov/cuu/Constants/</a></dd>
3215</dl>
3216
3217<p>CODATA is the Committee on Data for Science and Technology.</p>
3218
3219<dl>
3220<dt><b>Main Author:</b></dt>
3221<dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br>
3222 Deutsches Zentrum f&uuml;r Luft und Raumfahrt e. V. (DLR)<br>
3223 Oberpfaffenhofen<br>
3224 Postfach 11 16<br>
3225 D-82230 We&szlig;ling<br>
3226 email: <a href=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</a></dd>
3227</dl>
3228
3229
3230<p>
3231Copyright &copy; 1998-2009, Modelica Association and DLR.
3232</p>
3233<p>
3234<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
3235under the terms of the <b>Modelica license</b>, see the license conditions
3236and the accompanying <b>disclaimer</b>
3237<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a>.</i>
3238</p><br>
3239</html>
3240", revisions="<html>
3241<ul>
3242<li><i>Nov 8, 2004</i>
3243 by <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
3244 Constants updated according to 2002 CODATA values.</li>
3245<li><i>Dec 9, 1999</i>
3246 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3247 Constants updated according to 1998 CODATA values. Using names, values
3248 and description text from this source. Included magnetic and
3249 electric constant.</li>
3250<li><i>Sep 18, 1999</i>
3251 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3252 Constants eps, inf, small introduced.</li>
3253<li><i>Nov 15, 1997</i>
3254 by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
3255 Realized.</li>
3256</ul>
3257</html>"), Invisible=true, Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={Line(points={{-34,-38},{12,-38}}, color={0,0,0}, thickness=0.5),Line(points={{-20,-38},{-24,-48},{-28,-56},{-34,-64}}, color={0,0,0}, thickness=0.5),Line(points={{-2,-38},{2,-46},{8,-56},{14,-64}}, color={0,0,0}, thickness=0.5)}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{200,162},{380,312}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{200,312},{220,332},{400,332},{380,312},{200,312}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Polygon(points={{400,332},{400,182},{380,162},{380,312},{400,332}}, fillColor={235,235,235}, fillPattern=FillPattern.Solid, lineColor={0,0,255}),Text(extent={{210,302},{370,272}}, lineColor={160,160,164}, textString="Library"),Line(points={{266,224},{312,224}}, color={0,0,0}, thickness=1),Line(points={{280,224},{276,214},{272,206},{266,198}}, color={0,0,0}, thickness=1),Line(points={{298,224},{302,216},{308,206},{314,198}}, color={0,0,0}, thickness=1),Text(extent={{152,412},{458,334}}, lineColor={255,0,0}, textString="Modelica.Constants")}));
3258 end Constants;
3259
3260end Modelica;
3261package ObsoleteModelica3 "Library that contains components from Modelica Standard Library 2.2.2 that have been removed from version 3.0"
3262 annotation(uses(Modelica(version="3.1")), Documentation(info="<html>
3263<p>
3264This package contains models and blocks from the Modelica Standard Library
3265version 2.2.2 that are no longer available in version 3.0.
3266The conversion script for version 3.0 changes references in existing
3267user models automatically to the models and blocks of package
3268ObsoleteModelica3. The user should <b>manually</b> replace all
3269references to ObsoleteModelica3 in his/her models to the models
3270that are recommended in the documentation of the respective model.
3271</p>
3272
3273<p>
3274In most cases, this means that a model with the name
3275\"ObsoleteModelica3.XXX\" should be renamed to \"Modelica.XXX\" (version 3.0)
3276and then a manual adaptation is needed. For example, a reference to
3277ObsoleteModelica3.Mechanics.MultiBody.Sensors.AbsoluteSensor
3278should be replaced by
3279Modelica.Mechanics.MultiBody.Sensors.AbsoluteSensor (version 3.0).
3280Since the design of the component has changed (e.g., several
3281optional connectors, and no longer one connector where all signals
3282are packed together), this requires some changes at the place where
3283the model is used (besides the renaming of the underlying class).
3284</p>
3285
3286<p>
3287The models in ObsoleteModelica3 are either not according to the Modelica Language
3288version 3.0 and higher, or the model was changed to get a better design.
3289In all cases, an automatic conversion to the new implementation
3290was not feasible, since too complicated.
3291</p>
3292
3293<p>
3294In order to easily detect obsolete models and blocks, all of them are specially
3295marked in the icon layer with a red box.
3296</p>
3297
3298<p>
3299Copyright &copy; 2007-2009, Modelica Association.
3300</p>
3301<p>
3302<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
3303under the terms of the <b>Modelica license</b>, see the license conditions
3304and the accompanying <b>disclaimer</b>
3305<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense2\">here</a>.</i>
3306</p>
3307
3308</html>"));
3309 package Icons "Library of icons"
3310 partial model ObsoleteModel "Icon for an obsolete model (use only for this case)"
3311 annotation(__Dymola_obsolete="Only used to mark an obsolete model. Do not use otherwise.", Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={Rectangle(extent={{-102,102},{102,-102}}, lineColor={255,0,0}, pattern=LinePattern.Dash, lineThickness=0.5)}), Documentation(info="<html>
3312<p>
3313This partial model is intended to provide a <u>default icon
3314for an obsolete model</u> that will be removed from the
3315corresponding library in a future release.
3316<p>
3317</html>"));
3318 end ObsoleteModel;
3319
3320 end Icons;
3321
3322 package Mechanics "Library of 1-dim. and 3-dim. mechanical components (multi-body, rotational, translational)"
3323 package MultiBody "Library to model 3-dimensional mechanical systems"
3324 package Interfaces "Connectors and partial models for 3-dim. mechanical components"
3325 partial model PartialCutForceSensor "Obsolete model. Use instead instead a model from Modelica.Mechanics.MultiBody.Sensors"
3326 extends Modelica.Icons.RotationalSensor;
3327 extends ObsoleteModelica3.Icons.ObsoleteModel;
3328 Modelica.Mechanics.MultiBody.Interfaces.Frame_a frame_a "Coordinate system with one cut-force and cut-torque" annotation(Placement(transformation(extent={{-116,-16},{-84,16}}, rotation=0)));
3329 Modelica.Mechanics.MultiBody.Interfaces.Frame_b frame_b "Coordinate system with one cut-force and cut-torque" annotation(Placement(transformation(extent={{84,-16},{116,16}}, rotation=0)));
3330 Modelica.Mechanics.MultiBody.Interfaces.Frame_resolve frame_resolve "If connected, the output signals are resolved in this frame (cut-force/-torque are set to zero)" annotation(Placement(transformation(origin={80,-100}, extent={{-16,-16},{16,16}}, rotation=270)));
3331 annotation(Window(x=0.37, y=0.02, width=0.6, height=0.65), __Dymola_obsolete="Model equations depend on cardinality(..) which will become obsolete in the Modelica language. Use instead a model from Modelica.Mechanics.MultiBody.Sensors", Documentation(info="
3332<HTML>
3333<p>
3334This is a base class for 3-dim. mechanical components with two frames
3335and one output port in order to measure the cut-force and/or
3336cut-torque acting between the two frames and
3337to provide the measured signals as output for further processing
3338with the blocks of package Modelica.Blocks.
3339</p>
3340</HTML>
3341"), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Line(points={{-70,0},{-101,0}}, color={0,0,0}),Line(points={{70,0},{100,0}}, color={0,0,0}),Line(points={{-80,-100},{-80,0}}, color={0,0,127}),Text(extent={{-132,76},{129,124}}, textString="%name", lineColor={0,0,255}),Text(extent={{-118,55},{-82,30}}, lineColor={128,128,128}, textString="a"),Text(extent={{83,55},{119,30}}, lineColor={128,128,128}, textString="b"),Text(extent={{-31,-72},{100,-97}}, lineColor={192,192,192}, textString="resolve"),Line(points={{80,0},{80,-100}}, color={95,95,95}, pattern=LinePattern.Dot)}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={1,1}), graphics={Line(points={{-70,0},{-100,0}}, color={0,0,0}),Line(points={{70,0},{100,0}}, color={0,0,0}),Line(points={{-80,-100},{-80,0}}, color={0,0,127}),Line(points={{80,0},{80,-100}}, color={95,95,95}, pattern=LinePattern.Dot)}));
3342 protected
3343 outer Modelica.Mechanics.MultiBody.World world;
3344 equation
3345 defineBranch(frame_a.R, frame_b.R);
3346 assert(cardinality(frame_a) > 0, "Connector frame_a of cut-force/-torque sensor object is not connected");
3347 assert(cardinality(frame_b) > 0, "Connector frame_b of cut-force/-torque sensor object is not connected");
3348 frame_a.r_0=frame_b.r_0;
3349 frame_a.R=frame_b.R;
3350 zeros(3)=frame_a.f + frame_b.f;
3351 zeros(3)=frame_a.t + frame_b.t;
3352 if cardinality(frame_resolve) == 1 then
3353 frame_resolve.f=zeros(3);
3354 frame_resolve.t=zeros(3);
3355 else
3356 frame_resolve.r_0=zeros(3);
3357 frame_resolve.R=Modelica.Mechanics.MultiBody.Frames.nullRotation();
3358 end if;
3359 end PartialCutForceSensor;
3360
3361 end Interfaces;
3362
3363 package Sensors "Sensors to measure variables"
3364 model CutForceAndTorque "Obsolete model. Use instead Modelica.Mechanics.MultiBody.Sensors.CutForceAndTorque"
3365 import SI = Modelica.SIunits;
3366 import Modelica.Mechanics.MultiBody.Types;
3367 extends ObsoleteModelica3.Mechanics.MultiBody.Interfaces.PartialCutForceSensor;
3368 Modelica.Blocks.Interfaces.RealOutput load[6] "Cut force and cut torque resolved in frame_a/frame_b or in frame_resolved, if connected" annotation(Placement(transformation(origin={-80,-110}, extent={{10,-10},{-10,10}}, rotation=90)));
3369 parameter Boolean animation=true "= true, if animation shall be enabled (show force and torque arrow)";
3370 parameter Boolean positiveSign=true "= true, if force and torque with positive sign is returned (= frame_a.f/.t), otherwise with negative sign (= frame_b.f/.t)";
3371 parameter Boolean resolveInFrame_a=true "= true, if force and torque are resolved in frame_a/frame_b, otherwise in the world frame (if connector frame_resolve is connected, the force/torque is resolved in frame_resolve)";
3372 input Real N_to_m(unit="N/m")=1000 " Force arrow scaling (length = force/N_to_m)" annotation(Dialog(group="if animation = true", enable=animation));
3373 input Real Nm_to_m(unit="N.m/m")=1000 " Torque arrow scaling (length = torque/Nm_to_m)" annotation(Dialog(group="if animation = true", enable=animation));
3374 input SI.Diameter forceDiameter=world.defaultArrowDiameter " Diameter of force arrow" annotation(Dialog(group="if animation = true", enable=animation));
3375 input SI.Diameter torqueDiameter=forceDiameter " Diameter of torque arrow" annotation(Dialog(group="if animation = true", enable=animation));
3376 input Types.Color forceColor=Modelica.Mechanics.MultiBody.Types.Defaults.ForceColor " Color of force arrow" annotation(Dialog(group="if animation = true", enable=animation));
3377 input Types.Color torqueColor=Modelica.Mechanics.MultiBody.Types.Defaults.TorqueColor " Color of torque arrow" annotation(Dialog(group="if animation = true", enable=animation));
3378 input Types.SpecularCoefficient specularCoefficient=world.defaultSpecularCoefficient "Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog(group="if animation = true", enable=animation));
3379 SI.Force force[3] "Cut force resolved in frame_a/frame_b or in frame_resolved, if connected";
3380 SI.Torque torque[3] "Cut torque resolved in frame_a/frame_b or in frame_resolved, if connected";
3381 annotation(__Dymola_obsolete="Based on a packed result signal which is not a good design. Use instead Modelica.Mechanics.MultiBody.Sensors.CutForceAndTorque", preferedView="info", Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics), Documentation(info="<HTML>
3382<p>
3383The cut-force and cut-torque acting at the component to which frame_b is
3384connected are determined and provided at the output signal connector
3385<b>load</b>:
3386</p>
3387<pre>
3388 load[1:3] = frame_a.f;
3389 load[4:6] = frame_a.t;
3390</pre>
3391<p>
3392If parameter <b>positiveSign</b> =
3393<b>false</b>, the negative cut-force and negative
3394cut-torque is provided (= frame_b.f and frame_b.t).
3395If <b>frame_resolve</b> is connected to another frame, then the
3396cut-force and cut-torque are resolved in frame_resolve.
3397If <b>frame_resolve</b> is <b>not</b> connected then the
3398coordinate system in which the cut-force and cut-torque is resolved
3399is defined by parameter <b>resolveInFrame_a</b>.
3400If this parameter is <b>true</b>, then the
3401cut-force and cut-torque is resolved in frame_a, otherwise it is
3402resolved in the world frame.
3403</p>
3404<p>
3405In the following figure the animation of a CutForceAndTorque
3406sensor is shown. The dark blue coordinate system is frame_b,
3407and the green arrows are the cut force and the cut torque,
3408respectively, acting at frame_b and
3409with negative sign at frame_a.
3410</p>
3411<p align=\"center\">
3412<IMG SRC=\"../Images/MultiBody/Sensors/CutForceAndTorque.png\">
3413</p>
3414</HTML>"));
3415 protected
3416 outer Modelica.Mechanics.MultiBody.World world;
3417 parameter Integer csign=if positiveSign then +1 else -1;
3418 SI.Position f_in_m[3]=frame_a.f*csign/N_to_m "Force mapped from N to m for animation";
3419 SI.Position t_in_m[3]=frame_a.t*csign/Nm_to_m "Torque mapped from Nm to m for animation";
3420 Modelica.Mechanics.MultiBody.Visualizers.Advanced.Arrow forceArrow(diameter=forceDiameter, color=forceColor, specularCoefficient=specularCoefficient, R=frame_b.R, r=frame_b.r_0, r_tail=f_in_m, r_head=-f_in_m) if world.enableAnimation and animation;
3421 Modelica.Mechanics.MultiBody.Visualizers.Advanced.DoubleArrow torqueArrow(diameter=torqueDiameter, color=torqueColor, specularCoefficient=specularCoefficient, R=frame_b.R, r=frame_b.r_0, r_tail=t_in_m, r_head=-t_in_m) if world.enableAnimation and animation;
3422 equation
3423 if cardinality(frame_resolve) == 1 then
3424 force=Modelica.Mechanics.MultiBody.Frames.resolve2(frame_resolve.R, Modelica.Mechanics.MultiBody.Frames.resolve1(frame_a.R, frame_a.f))*csign;
3425 torque=Modelica.Mechanics.MultiBody.Frames.resolve2(frame_resolve.R, Modelica.Mechanics.MultiBody.Frames.resolve1(frame_a.R, frame_a.t))*csign;
3426 elseif resolveInFrame_a then
3427 force=frame_a.f*csign;
3428 torque=frame_a.t*csign;
3429 else
3430 force=Modelica.Mechanics.MultiBody.Frames.resolve1(frame_a.R, frame_a.f)*csign;
3431 torque=Modelica.Mechanics.MultiBody.Frames.resolve1(frame_a.R, frame_a.t)*csign;
3432 end if;
3433 load[1:3]=force;
3434 load[4:6]=torque;
3435 end CutForceAndTorque;
3436
3437 end Sensors;
3438
3439 end MultiBody;
3440
3441 end Mechanics;
3442
3443end ObsoleteModelica3;
3444package ModelicaServices "Models and functions used in the Modelica Standard Library requiring a tool specific implementation"
3445 package Animation "Models and functions for 3-dim. animation"
3446 model Shape "Different visual shapes with variable size; all data have to be set as modifiers (see info layer)"
3447 extends Modelica.Utilities.Internal.PartialModelicaServices.Animation.PartialShape;
3448 import T = Modelica.Mechanics.MultiBody.Frames.TransformationMatrices;
3449 import SI = Modelica.SIunits;
3450 import Modelica.Mechanics.MultiBody.Frames;
3451 import Modelica.Mechanics.MultiBody.Types;
3452 protected
3453 Real abs_n_x(final unit="1")=Modelica.Math.Vectors.length(lengthDirection) annotation(HideResult=true);
3454 Real e_x[3](each final unit="1")=noEvent(if abs_n_x < 1e-10 then {1,0,0} else lengthDirection/abs_n_x) annotation(HideResult=true);
3455 Real n_z_aux[3](each final unit="1")=cross(e_x, widthDirection) annotation(HideResult=true);
3456 Real e_y[3](each final unit="1")=noEvent(cross(Modelica.Math.Vectors.normalize(cross(e_x, if n_z_aux*n_z_aux > 1e-06 then widthDirection else if abs(e_x[1]) > 1e-06 then {0,1,0} else {1,0,0})), e_x)) annotation(HideResult=true);
3457 output Real Form annotation(HideResult=false);
3458 public
3459 output Real rxvisobj[3](each final unit="1") "x-axis unit vector of shape, resolved in world frame" annotation(HideResult=false);
3460 output Real ryvisobj[3](each final unit="1") "y-axis unit vector of shape, resolved in world frame" annotation(HideResult=false);
3461 output SI.Position rvisobj[3] "position vector from world frame to shape frame, resolved in world frame" annotation(HideResult=false);
3462 protected
3463 output SI.Length size[3] "{length,width,height} of shape" annotation(HideResult=false);
3464 output Real Material annotation(HideResult=false);
3465 output Real Extra annotation(HideResult=false);
3466 equation
3467 Form=(987000 + PackShape(shapeType))*1e+20;
3468 rxvisobj=transpose(R.T)*e_x;
3469 ryvisobj=transpose(R.T)*e_y;
3470 rvisobj=r + T.resolve1(R.T, r_shape);
3471 size={length,width,height};
3472 Material=PackMaterial(color[1]/255.0, color[2]/255.0, color[3]/255.0, specularCoefficient);
3473 Extra=extra;
3474 annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}, grid={2,2}), graphics={Rectangle(extent={{-100,-100},{80,60}}, lineColor={0,0,255}, fillColor={255,255,255}, fillPattern=FillPattern.Solid),Polygon(points={{-100,60},{-80,100},{100,100},{80,60},{-100,60}}, lineColor={0,0,255}, fillColor={192,192,192}, fillPattern=FillPattern.Solid),Polygon(points={{100,100},{100,-60},{80,-100},{80,60},{100,100}}, lineColor={0,0,255}, fillColor={160,160,164}, fillPattern=FillPattern.Solid),Text(extent={{-100,-100},{80,60}}, lineColor={0,0,0}, textString="%shapeType"),Text(extent={{-132,160},{128,100}}, textString="%name", lineColor={0,0,255})}), Documentation(info="<html>
3475
3476<p>
3477This model is documented at
3478<a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape\">Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape</a>.
3479</p>
3480
3481
3482</html>
3483"));
3484 end Shape;
3485
3486 end Animation;
3487
3488 annotation(preferredView="info", version="1.0", versionDate="2009-06-21", versionBuild=2, revisionId="$Id:: package.mo 3120 2009-11-08 18:22:04Z #$", Documentation(info="<html>
3489<p>
3490This package contains a set of functions and models to be used in the
3491Modelica Standard Library that requires a tool specific implementation.
3492These are:
3493</p>
3494
3495<ul>
3496<li> <a href=\"Modelica://ModelicaServices.Animation.Shape\">ModelicaServices.Animation.Shape</a>.
3497 provides a 3-dim. visualization of
3498 mechanical objects. It is used in
3499<a href=\"Modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape\">Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape</a>
3500 via inheritance.</li>
3501</ul>
3502
3503<p>
3504<b>Licensed by DLR and Dynasim under the Modelica License 2</b><br>
3505Copyright &copy; 2009, DLR and Dynasim.
3506</p>
3507
3508<p>
3509<i>This Modelica package is <u>free</u> software and
3510the use is completely at <u>your own risk</u>;
3511it can be redistributed and/or modified under the terms of the
3512Modelica license 2, see the license conditions (including the
3513disclaimer of warranty)
3514<a href=\"Modelica://ModelicaServices.UsersGuide.ModelicaLicense2\">here</a></u>
3515or at
3516<a href=\"http://www.Modelica.org/licenses/ModelicaLicense2\">
3517http://www.Modelica.org/licenses/ModelicaLicense2</a>.
3518</p>
3519
3520</html>"), uses(Modelica(version="3.1")));
3521end ModelicaServices;
3522function PackMaterial
3523 input Real r;
3524 input Real g;
3525 input Real b;
3526 input Real spec;
3527 output Real packedMaterial;
3528 Integer i1;
3529 Integer i2;
3530 Integer i3;
3531 Integer i4;
3532algorithm
3533 i1:=integer(floor(r*99));
3534 if i1 < 0 then
3535 i1:=0;
3536 end if;
3537 if i1 > 99 then
3538 i1:=99;
3539 end if;
3540 i2:=integer(floor(g*99));
3541 if i2 < 0 then
3542 i2:=0;
3543 end if;
3544 if i2 > 99 then
3545 i2:=99;
3546 end if;
3547 i3:=integer(floor(b*99));
3548 if i3 < 0 then
3549 i3:=0;
3550 end if;
3551 if i3 > 99 then
3552 i3:=99;
3553 end if;
3554 i4:=integer(floor(spec*9));
3555 if i4 < 0 then
3556 i4:=0;
3557 end if;
3558 if i4 > 99 then
3559 i4:=9;
3560 end if;
3561 packedMaterial:=((i1*100 + i2)*100 + i3)*10 + i4;
3562end PackMaterial;
3563function PackShape
3564 input String shape;
3565 output Real packedShape;
3566 function atoi
3567 input String str;
3568 output Integer i;
3569
3570 external "C" ;
3571
3572 end atoi;
3573
3574algorithm
3575 if shape == "box" then
3576 packedShape:=101.0;
3577 elseif shape == "sphere" then
3578 packedShape:=102.0;
3579
3580 elseif shape == "cylinder" then
3581 packedShape:=103.0;
3582
3583 elseif shape == "cone" then
3584 packedShape:=104.0;
3585
3586 elseif shape == "pipe" then
3587 packedShape:=105.0;
3588
3589 elseif shape == "beam" then
3590 packedShape:=106.0;
3591
3592 elseif shape == "wirebox" then
3593 packedShape:=107.0;
3594
3595 elseif shape == "gearwheel" then
3596 packedShape:=108.0;
3597
3598 elseif shape == "pipecylinder" then
3599 packedShape:=110.0;
3600
3601 elseif shape == "spring" then
3602 packedShape:=111.0;
3603 else
3604 packedShape:=200 + atoi(shape);
3605 end if;
3606end PackShape;
3607package ModelicaTest "Library to test components of library Modelica "
3608 annotation(version="1.1", versionDate="2007-10-19", uses(Modelica(version="3.1")), Documentation(info="<html>
3609<p>
3610This library provides models and functions to test components of
3611<b>package Modelica</b> (the Modelica Standard Library).
3612</p>
3613
3614<p>
3615Further development of this library should be performed in the following
3616way:
3617</p>
3618
3619<ul>
3620<li> Functions that are added to this library to test functions of the
3621 Modelica Standard Library, should be called in \"ModelicaTest.testAllFunctions()\".
3622 The idea is that all test functions are called, when calling
3623 \"testAllFunctions()\".</li>
3624
3625<li> Models that are added to this library should have the annotation
3626 (with an appropriate StopTime):
3627 <pre>
3628 <b>annotation</b>(experiment(StopTime=1.1)); </pre>
3629 This gives the tool vendors the possibility to automatically identify
3630 the models that shall be simulated and, e.g., that shall be used in an automatic
3631 regression test.</li>
3632</ul>
3633
3634<p>
3635Copyright &copy; 1998-2007, Modelica Association.
3636</p>
3637<p>
3638<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
3639under the terms of the <b>Modelica license</b>, see the license conditions
3640and the accompanying <b>disclaimer</b>
3641<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense\">here</a>.</i>
3642</p>
3643</html>"), conversion(from(version="1.0", script="ConvertFromModelicaTest_1.0.mos")));
3644 package MultiBody "Test models for Modelica.Mechanics.MultiBody"
3645 package Sensors "Test MultiBody.Sensors"
3646 model CutForceAndTorque1
3647 extends Modelica.Icons.Example;
3648 annotation(experiment(StopTime=1.1));
3649 inner Modelica.Mechanics.MultiBody.World world annotation(Placement(transformation(extent={{-100,0},{-80,20}}, rotation=0)));
3650 ObsoleteModelica3.Mechanics.MultiBody.Sensors.CutForceAndTorque cutForce1a(N_to_m=10, Nm_to_m=10) annotation(Placement(transformation(extent={{-20,20},{0,0}}, rotation=0)));
3651 Modelica.Mechanics.MultiBody.Parts.FixedTranslation translate1a(r={0,-1,0}) annotation(Placement(transformation(origin={30,10}, extent={{10,-10},{-10,10}}, rotation=180)));
3652 Modelica.Mechanics.MultiBody.Parts.Body body1a annotation(Placement(transformation(extent={{60,0},{80,20}}, rotation=0)));
3653 ObsoleteModelica3.Mechanics.MultiBody.Sensors.CutForceAndTorque cutForce2a(positiveSign=false, resolveInFrame_a=false, N_to_m=10, Nm_to_m=10) annotation(Placement(transformation(extent={{-20,-40},{0,-20}}, rotation=0)));
3654 Modelica.Mechanics.MultiBody.Parts.FixedTranslation translate2a(r={0,-1,0}) annotation(Placement(transformation(origin={30,-30}, extent={{10,-10},{-10,10}}, rotation=180)));
3655 Modelica.Mechanics.MultiBody.Parts.Body body2a annotation(Placement(transformation(extent={{60,-40},{80,-20}}, rotation=0)));
3656 Modelica.Mechanics.MultiBody.Parts.FixedRotation rotate1a(n={0,0,1}, angle=90, r={0,0,-0.2}) annotation(Placement(transformation(extent={{-60,0},{-40,20}}, rotation=0)));
3657 Modelica.Mechanics.MultiBody.Parts.FixedRotation rotate2a(n={0,0,1}, angle=90, r={0,0,0.2}) annotation(Placement(transformation(extent={{-60,-40},{-40,-20}}, rotation=0)));
3658 ObsoleteModelica3.Mechanics.MultiBody.Sensors.CutForceAndTorque cutForce1b(N_to_m=10, Nm_to_m=10) annotation(Placement(transformation(extent={{-20,60},{0,80}}, rotation=0)));
3659 Modelica.Mechanics.MultiBody.Parts.FixedTranslation translate1b(r={0,-1,0}) annotation(Placement(transformation(origin={30,70}, extent={{10,-10},{-10,10}}, rotation=180)));
3660 Modelica.Mechanics.MultiBody.Parts.Body body1b annotation(Placement(transformation(extent={{60,60},{80,80}}, rotation=0)));
3661 Modelica.Mechanics.MultiBody.Parts.FixedRotation rotate1b(n={0,0,1}, angle=90, r={0,0,-0.6}) annotation(Placement(transformation(extent={{-60,60},{-40,80}}, rotation=0)));
3662 Modelica.Blocks.Math.Add err1[6](each k2=-1) annotation(Placement(transformation(extent={{10,30},{30,50}}, rotation=0)));
3663 ObsoleteModelica3.Mechanics.MultiBody.Sensors.CutForceAndTorque cutForce2b(positiveSign=false, resolveInFrame_a=false, N_to_m=10, Nm_to_m=10) annotation(Placement(transformation(extent={{-20,-80},{0,-100}}, rotation=0)));
3664 Modelica.Mechanics.MultiBody.Parts.FixedTranslation translate2b(r={0,-1,0}) annotation(Placement(transformation(origin={30,-90}, extent={{10,-10},{-10,10}}, rotation=180)));
3665 Modelica.Mechanics.MultiBody.Parts.Body body2b annotation(Placement(transformation(extent={{60,-100},{80,-80}}, rotation=0)));
3666 Modelica.Mechanics.MultiBody.Parts.FixedRotation rotate2b(n={0,0,1}, angle=90, r={0,0,0.6}) annotation(Placement(transformation(extent={{-60,-100},{-40,-80}}, rotation=0)));
3667 Modelica.Blocks.Math.Add err2[6](each k2=-1) annotation(Placement(transformation(extent={{8,-72},{28,-52}}, rotation=0)));
3668 equation
3669 annotation(Diagram(graphics));
3670 connect(world.frame_b,rotate1a.frame_a) annotation(Line(points={{-80,10},{-60,10}}, color={0,0,0}, thickness=0.5));
3671 connect(rotate1a.frame_b,cutForce1a.frame_a) annotation(Line(points={{-40,10},{-20,10}}, color={0,0,0}, thickness=0.5));
3672 connect(rotate2a.frame_b,cutForce2a.frame_a) annotation(Line(points={{-40,-30},{-20,-30}}, color={0,0,0}, thickness=0.5));
3673 connect(rotate2a.frame_a,world.frame_b) annotation(Line(points={{-60,-30},{-70,-30},{-70,10},{-80,10}}, color={0,0,0}, thickness=0.5));
3674 connect(rotate1b.frame_b,cutForce1b.frame_a) annotation(Line(points={{-40,70},{-20,70}}, color={0,0,0}, thickness=0.5));
3675 connect(cutForce1b.frame_resolve,rotate1b.frame_b) annotation(Line(points={{-2,60},{-20,60},{-20,46},{-40,46},{-40,70}}, color={0,0,0}, pattern=LinePattern.Dot));
3676 connect(cutForce1b.load,err1.u1) annotation(Line(points={{-18,59},{-18,46},{8,46}}, color={0,0,255}));
3677 connect(cutForce1a.load,err1.u2) annotation(Line(points={{-18,21},{-18,34},{8,34}}, color={0,0,255}));
3678 connect(world.frame_b,rotate1b.frame_a) annotation(Line(points={{-80,10},{-70,10},{-70,70},{-60,70}}, color={0,0,0}, thickness=0.5));
3679 connect(rotate2b.frame_b,cutForce2b.frame_a) annotation(Line(points={{-40,-90},{-20,-90}}, color={0,0,0}, thickness=0.5));
3680 connect(rotate2b.frame_a,world.frame_b) annotation(Line(points={{-60,-90},{-70,-90},{-70,10},{-80,10}}, color={0,0,0}, thickness=0.5));
3681 connect(cutForce2a.load,err2.u1) annotation(Line(points={{-18,-41},{-18,-56},{6,-56}}, color={0,0,255}));
3682 connect(cutForce2b.load,err2.u2) annotation(Line(points={{-18,-79},{-18,-68},{6,-68}}, color={0,0,255}));
3683 connect(cutForce2b.frame_resolve,world.frame_b) annotation(Line(points={{-2,-80},{-2,-58},{-74,-58},{-74,10},{-80,10}}, color={0,0,0}, pattern=LinePattern.Dot));
3684 connect(cutForce1b.frame_b,translate1b.frame_a) annotation(Line(points={{0,70},{20,70}}, color={0,0,0}, thickness=0.5));
3685 connect(translate1b.frame_b,body1b.frame_a) annotation(Line(points={{40,70},{60,70}}, color={0,0,0}, thickness=0.5));
3686 connect(cutForce1a.frame_b,translate1a.frame_a) annotation(Line(points={{0,10},{10,10},{10,10},{20,10}}, color={0,0,0}, thickness=0.5));
3687 connect(translate1a.frame_b,body1a.frame_a) annotation(Line(points={{40,10},{50,10},{50,10},{60,10}}, color={0,0,0}, thickness=0.5));
3688 connect(cutForce2a.frame_b,translate2a.frame_a) annotation(Line(points={{0,-30},{20,-30}}, color={0,0,0}, thickness=0.5));
3689 connect(translate2a.frame_b,body2a.frame_a) annotation(Line(points={{40,-30},{60,-30}}, color={0,0,0}, thickness=0.5));
3690 connect(cutForce2b.frame_b,translate2b.frame_a) annotation(Line(points={{0,-90},{20,-90}}, color={0,0,0}, thickness=0.5));
3691 connect(translate2b.frame_b,body2b.frame_a) annotation(Line(points={{40,-90},{60,-90}}, color={0,0,0}, thickness=0.5));
3692 end CutForceAndTorque1;
3693
3694 end Sensors;
3695
3696 end MultiBody;
3697
3698end ModelicaTest;
3699model ModelicaTest_MultiBody_Sensors_CutForceAndTorque1
3700 extends ModelicaTest.MultiBody.Sensors.CutForceAndTorque1;
3701end ModelicaTest_MultiBody_Sensors_CutForceAndTorque1;