-
Notifications
You must be signed in to change notification settings - Fork 164
/
DoubleArrow.mo
97 lines (90 loc) · 4.35 KB
/
DoubleArrow.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
within Modelica.Mechanics.MultiBody.Visualizers.Advanced;
model DoubleArrow
"Visualizing a double arrow with variable size; all data have to be set as modifiers (see info layer)"
import Modelica.Mechanics.MultiBody.Types;
import Modelica.Mechanics.MultiBody.Frames;
import T = Modelica.Mechanics.MultiBody.Frames.TransformationMatrices;
import Modelica.Units.Conversions.to_unit1;
input Frames.Orientation R=Frames.nullRotation()
"Orientation object to rotate the world frame into the arrow frame" annotation(Dialog);
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);
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);
input Real r_head[3]={0,0,0}
"Vector from double arrow tail to the head of the double arrow, resolved in arrow frame" annotation(Dialog);
input Modelica.Mechanics.MultiBody.Types.Color color=Modelica.Mechanics.MultiBody.Types.Defaults.ArrowColor
"Color of double arrow" annotation(Dialog(colorSelector=true));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
"Material property describing the reflecting of ambient light (= 0 means, that light is completely absorbed)" annotation(Dialog);
input Types.VectorQuantity quantity=Types.VectorQuantity.Torque
"The kind of physical quantity represented by the vector" annotation(Dialog);
input Boolean headAtOrigin=true "= true, if the vector is pointing towards the origin of vector frame" annotation(Dialog);
protected
outer Modelica.Mechanics.MultiBody.World world;
SI.Position rvisobj[3] = r + T.resolve1(R.T, r_tail);
Visualizers.Advanced.Vector arrowLine(
coordinates=r_head,
color=color,
specularCoefficient=specularCoefficient,
r=rvisobj,
quantity=quantity,
headAtOrigin=headAtOrigin,
twoHeadedArrow=true,
R=R) if world.enableAnimation;
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={{-150,105},{150,65}},
textString="%name",
textColor={0,0,255}),
Polygon(
points={{0,60},{60,0},{0,-60},{0,60}},
lineColor={128,128,128},
fillColor={128,128,128},
fillPattern=FillPattern.Solid)}),
Documentation(info="<html>
<p>
Model <strong>DoubleArrow</strong> defines a double arrow that is dynamically
visualized at the defined location (see variables below).
Nonetheless, visualizing physical vectors by means of
<a href=\"Modelica.Mechanics.MultiBody.Visualizers.Advanced.Vector\">Vector</a>
can be better option in many cases.
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Advanced/DoubleArrow.png\" alt=\"model Visualizers.Advanced.DoubleArrow\">
</p>
<p>
The dialog variables <code>R</code>, <code>r</code>, <code>r_tail</code>, <code>r_head</code>, <code>color</code>,
<code>specularCoefficient</code>, <code>quantity</code>, and <code>headAtOrigin</code>
are declared as (time varying) <strong>input</strong> variables.
If the default equation is not appropriate, a corresponding
modifier equation has to be provided in the
model where an <strong>Arrow</strong> instance is used, e.g., in the form
</p>
<blockquote><pre>
Visualizers.Advanced.DoubleArrow doubleArrow(r_head = {sin(time),cos(time},0})
</pre></blockquote>
<p>
Variable <strong>color</strong> is an Integer vector with 3 elements,
{r, g, b}, and specifies the color of the shape.
{r, g, b} are the "red", "green" and "blue" color parts.
Note, r, g and b are given in the range 0 … 255.
The predefined type
<a href=\"modelica://Modelica.Mechanics.MultiBody.Types.Color\">MultiBody.Types.Color</a>
contains a menu definition of the colors used in the MultiBody
library together with a color editor.
</p>
</html>"));
end DoubleArrow;