-
Notifications
You must be signed in to change notification settings - Fork 164
/
Visualizers.mo
3022 lines (2803 loc) · 169 KB
/
Visualizers.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
within Modelica.Mechanics.MultiBody;
package Visualizers "3-dimensional visual objects used for animation"
extends Modelica.Icons.Package;
model FixedShape
"Visualizing an elementary shape with dynamically varying shape attributes (has one frame connector)"
import Modelica.Mechanics.MultiBody.Types;
extends Modelica.Mechanics.MultiBody.Interfaces.PartialVisualizer;
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter Types.ShapeType shapeType="box" "Type of shape"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Position r_shape[3]={0,0,0}
"Vector from frame_a to shape origin, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Axis lengthDirection={1,0,0}
"Vector in length direction of shape, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Axis widthDirection={0,1,0}
"Vector in width direction of shape, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Distance length(start=1) "Length of shape"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Distance width(start=0.1) "Width of shape"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Distance height(start=0.1) "Height of shape"
annotation (Dialog(group="if animation = true", enable=animation));
input Modelica.Mechanics.MultiBody.Types.Color color={0,128,255}
"Color of shape"
annotation (Dialog(colorSelector=true, group="if animation = true", enable=animation));
input Types.ShapeExtra extra=0.0
"Additional data for cylinder, cone, pipe, gearwheel and spring"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(group="if animation = true", enable=animation));
protected
Advanced.Shape vis(
shapeType=shapeType,
r_shape=r_shape,
lengthDirection=lengthDirection,
widthDirection=widthDirection,
length=length,
width=width,
height=height,
color=color,
extra=extra,
specularCoefficient=specularCoefficient,
r=frame_a.r_0,
R=frame_a.R) if world.enableAnimation and animation;
equation
// No forces and torques
frame_a.f = zeros(3);
frame_a.t = zeros(3);
annotation (
Documentation(info="<html>
<p>
Model <strong>FixedShape</strong> defines a visual shape that is
shown at the location of its frame_a.
All describing data such as size and color can vary dynamically by
providing appropriate expressions in the input fields of the
parameter menu. The only exception is parameter shapeType
that cannot be changed during simulation.
The following shapes are currently supported via
parameter <strong>shapeType</strong> (e.g., shapeType=\"box\"):<br>
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Shape.png\" alt=\"model Visualizers.FixedShape\">
</p>
<p>
The dark blue arrows in the figure above are directed along
variable <strong>lengthDirection</strong>. The light blue arrows are directed
along variable <strong>widthDirection</strong>. The <strong>coordinate systems</strong>
in the figure represent frame_a of the FixedShape component.
</p>
<p>
Additionally, <strong>external shapes</strong> can be specified as (not all options might be supported by all tools):
</p>
<ul>
<li> <strong>\"1\", \"2\", …</strong><br>
define external shapes specified in DXF format in files \"1.dxf\", \"2.dxf\", …
The DXF-files must be found either in the current directory or in the directory where
the Shape instance is stored that references the DXF file.
This (very limited) option should not be used for new models. Example:<br>
shapeType=\"1\".<br></li>
<li> \"<strong>modelica:</strong>//<Modelica-name>/<relative-path-file-name>\"<br>
characterizes the file that is stored under the location of the
<Modelica-name> library path with the given relative file name.
Example:<br> shapeType = \"modelica://Modelica/Resources/Data/Shapes/Engine/piston.dxf\".<br></li>
<li> \"<strong>file:</strong>//<absolute-file-name>\"<br>
characterizes an absolute file name in the file system. Example:<br>
shapeType=\"file://C:/users/myname/shapes/piston.dxf\".</li>
</ul>
<p>
The supported file formats are tool dependent. Most tools support at least DXF-files
but may support other format as well (such as stl, obj, 3ds).
Since visualization files contain color and other data, the corresponding
information in the model is usually ignored.
For information about DXF files, see <a href=\"https://en.wikipedia.org/wiki/AutoCAD_DXF\">Wikipedia</a>.
As a default it is assumed that the DXF coordinates are in the \"frame_a\"-system and in meters, and that the 3dfaces are two-sided.
Some tools support only 3dface (for geometry) and layer (for advanced coloring).</p>
<p>
The sizes of any of the above components are specified by the
<strong>length</strong>, <strong>width</strong> and <strong>height</strong> variables.
Via variable <strong>extra</strong> additional data can be defined:
</p>
<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">
<tr><th><strong>shapeType</strong></th><th>Meaning of parameter <strong>extra</strong></th></tr>
<tr>
<td>\"cylinder\"</td>
<td>if extra > 0, a black line is included in the
cylinder to show the rotation of it.</td>
</tr>
<tr>
<td>\"cone\"</td>
<td>extra = diameter-left-side / diameter-right-side, i.e.,<br>
extra = 1: cylinder<br>
extra = 0: \"real\" cone.</td>
</tr>
<tr>
<td>\"pipe\"</td>
<td>extra = outer-diameter / inner-diameter, i.e,<br>
extra = 1: cylinder that is completely hollow<br>
extra = 0: cylinder without a hole.</td>
</tr>
<tr>
<td>\"gearwheel\"</td>
<td>extra is the number of teeth of the (external) gear.
If extra < 0, an internal gear is visualized with |extra| teeth.
The axis of the gearwheel is along \"lengthDirection\", and usually:
width = height = 2*radiusOfGearWheel.</td>
</tr>
<tr>
<td>\"spring\"</td>
<td>extra is the number of windings of the spring.
Additionally, \"height\" is <strong>not</strong> the \"height\" but
2*coil-width.</td>
</tr>
<tr>
<td>external shape</td>
<td>extra = 0: Visualization from file is not scaled.<br>
extra = 1: Visualization from file is scaled with \"length\", \"width\" and \"height\"
of the shape</td>
</tr>
</table>
<p>
Parameter <strong>color</strong> is a 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 as Integer[3] in the ranges 0 … 255,
respectively. 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>"), Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Polygon(
points={{-100,32},{-64,46},{2,30},{72,54},{50,32},{-10,12},{-100,32}},
lineColor={215,215,215},
fillColor={160,160,160},
fillPattern=FillPattern.Solid),
Polygon(
points={{72,54},{50,32},{50,-60},{72,-32},{72,54}},
lineColor={215,215,215},
fillColor={160,160,164},
fillPattern=FillPattern.Solid),
Text(
extent={{-150,-65},{150,-95}},
textString="%shapeType"),
Text(
extent={{-150,100},{150,60}},
textString="%name",
textColor={0,0,255}),
Polygon(
points={{-100,32},{-100,-60},{-10,-42},{50,-60},{50,32},{-10,12},{-100,32}},
lineColor={215,215,215},
fillColor={0,127,255},
fillPattern=FillPattern.Solid)}));
end FixedShape;
model FixedShape2
"Visualizing an elementary shape with dynamically varying shape attributes (has two frame connectors)"
import Modelica.Mechanics.MultiBody.Frames;
import Modelica.Mechanics.MultiBody.Types;
import Modelica.SIunits.Conversions.to_unit1;
Interfaces.Frame_a frame_a
"Coordinate system a (all shape definition vectors are resolved in this frame)"
annotation (Placement(transformation(extent={{-116,-16},{-84,16}})));
Interfaces.Frame_b frame_b "Coordinate system b"
annotation (Placement(transformation(extent={{84,-16},{116,16}})));
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter Types.ShapeType shapeType="box" "Type of shape"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Position r[3]={1,0,0}
"Vector from frame_a to frame_b resolved in frame_a";
input SI.Position r_shape[3]={0,0,0}
"Vector from frame_a to shape origin, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Axis lengthDirection = to_unit1(r - r_shape)
"Vector in length direction of shape, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Axis widthDirection={0,1,0}
"Vector in width direction of shape, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Length length=Modelica.Math.Vectors.length(
r - r_shape) "Length of shape"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Distance width=0.1 "Width of shape"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Distance height=width "Height of shape"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.ShapeExtra extra=0.0
"Additional data for cylinder, cone, pipe, gearwheel and spring"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Color color={0,128,255} "Color of shape"
annotation (Dialog(colorSelector=true, group="if animation = true", enable=animation));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(group="if animation = true", enable=animation));
protected
outer MultiBody.World world;
Advanced.Shape shape(
shapeType=shapeType,
r_shape=r_shape,
lengthDirection=lengthDirection,
widthDirection=widthDirection,
length=length,
width=width,
height=height,
extra=extra,
color=color,
specularCoefficient = specularCoefficient,
r=frame_a.r_0,
R=frame_a.R) if world.enableAnimation and animation;
equation
Connections.branch(frame_a.R, frame_b.R);
assert(cardinality(frame_a) > 0 or cardinality(frame_b) > 0, "Neither connector frame_a nor frame_b of
MultiBody.Visualizers.FixedShape2 object is connected");
frame_b.r_0 = frame_a.r_0 + Frames.resolve1(frame_a.R, r);
frame_b.R = frame_a.R;
/* Force and torque balance */
zeros(3) = frame_a.f + frame_b.f;
zeros(3) = frame_a.t + frame_b.t + cross(r, frame_b.f);
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Text(
extent={{-150,115},{150,75}},
textString="%name",
textColor={0,0,255}),
Text(
extent={{150,-90},{-150,-60}},
textString="r=%r"),
Polygon(
points={{-100,50},{-66,62},{0,46},{100,70},{80,50},{-10,28},{-100,50}},
lineColor={255,255,255},
fillColor={160,160,164},
fillPattern=FillPattern.Solid),
Polygon(
points={{100,70},{80,50},{80,-44},{100,-16},{100,70}},
lineColor={255,255,255},
fillColor={160,160,164},
fillPattern=FillPattern.Solid),
Polygon(
points={{-100,50},{-100,-44},{-10,-24},{80,-44},{80,50},{-10,28},{-100,50}},
lineColor={215,215,215},
fillColor={0,127,255},
fillPattern=FillPattern.Solid),
Text(
extent={{-86,15},{-50,-10}},
textString="a"),
Text(
extent={{37,15},{73,-10}},
textString="b")}),
Documentation(info="<html>
<p>
Model <strong>FixedShape2</strong> defines a visual shape that is
shown at the location of its frame_a. This model is identical
to <strong>FixedShape</strong> with the only difference that an
additional frame_b is present which is parallel to frame_a.
This makes it more convenient to connect several visual
shapes together when building up more complex visual
objects. All describing data such as size and color can vary dynamically by
providing appropriate expressions in the input fields of the
parameter menu. The only exception is parameter shapeType
that cannot be changed during simulation.
The following shapes are currently supported via
parameter <strong>shapeType</strong> (e.g., shapeType=\"box\"):<br>
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Shape.png\" alt=\"model Visualizers.FixedShape2\">
</p>
<p> <br>
The dark blue arrows in the figure above are directed along
variable <strong>lengthDirection</strong>. The light blue arrows are directed
along variable <strong>widthDirection</strong>. The <strong>coordinate systems</strong>
in the figure represent frame_a of the FixedShape component.
</p>
<p>
Additionally, <strong>external shapes</strong> can be specified as (not all options might be supported by all tools):
</p>
<ul>
<li> <strong>\"1\", \"2\", …</strong><br>
define external shapes specified in DXF format in files \"1.dxf\", \"2.dxf\", …
The DXF-files must be found either in the current directory or in the directory where
the Shape instance is stored that references the DXF file.
This (very limited) option should not be used for new models. Example:<br>
shapeType=\"1\".<br></li>
<li> \"<strong>modelica:</strong>//<Modelica-name>/<relative-path-file-name>\"<br>
characterizes the file that is stored under the location of the
<Modelica-name> library path with the given relative file name.
Example:<br> shapeType = \"modelica://Modelica/Resources/Data/Shapes/Engine/piston.dxf\".<br></li>
<li> \"<strong>file:</strong>//<absolute-file-name>\"<br>
characterizes an absolute file name in the file system. Example:<br>
shapeType=\"file://C:/users/myname/shapes/piston.dxf\".</li>
</ul>
<p>
The supported file formats are tool dependent. Most tools support at least DXF-files
but may support other format as well (such as stl, obj, 3ds).
Since visualization files contain color and other data, the corresponding
information in the model is usually ignored.
For information about DXF files, see <a href=\"https://en.wikipedia.org/wiki/AutoCAD_DXF\">Wikipedia</a>.
As a default it is assumed that the DXF coordinates are in the \"frame_a\"-system and in meters, and that the 3dfaces are two-sided.
Some tools support only 3dface (for geometry) and layer (for advanced coloring).
</p>
<p>
The sizes of any of the above components are specified by the
<strong>length</strong>, <strong>width</strong> and <strong>height</strong> variables.
Via variable <strong>extra</strong> additional data can be defined:
</p>
<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">
<tr><th><strong>shapeType</strong></th><th>Meaning of parameter <strong>extra</strong></th></tr>
<tr>
<td>\"cylinder\"</td>
<td>if extra > 0, a black line is included in the
cylinder to show the rotation of it.</td>
</tr>
<tr>
<td>\"cone\"</td>
<td>extra = diameter-left-side / diameter-right-side, i.e.,<br>
extra = 1: cylinder<br>
extra = 0: \"real\" cone.</td>
</tr>
<tr>
<td>\"pipe\"</td>
<td>extra = outer-diameter / inner-diameter, i.e,<br>
extra = 1: cylinder that is completely hollow<br>
extra = 0: cylinder without a hole.</td>
</tr>
<tr>
<td>\"gearwheel\"</td>
<td>extra is the number of teeth of the (external) gear.
If extra < 0, an internal gear is visualized with |extra| teeth.
The axis of the gearwheel is along \"lengthDirection\", and usually:
width = height = 2*radiusOfGearWheel.</td>
</tr>
<tr>
<td>\"spring\"</td>
<td>extra is the number of windings of the spring.
Additionally, \"height\" is <strong>not</strong> the \"height\" but
2*coil-width.</td>
</tr>
<tr>
<td>external shape</td>
<td>extra = 0: Visualization from file is not scaled.<br>
extra = 1: Visualization from file is scaled with \"length\", \"width\" and \"height\"
of the shape</td>
</tr>
</table>
<p>
Parameter <strong>color</strong> is a 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, b are given as Integer[3] in the ranges 0 … 255,
respectively. 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>
<p>
In the following figure the relationships between
frame_a and frame_b are shown. The origin of frame_b
with respect to frame_a is specified via parameter
vector <strong>r</strong>.
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Parts/FixedTranslation.png\" alt=\"Parts.FixedTranslation\">
</p>
</html>"));
end FixedShape2;
model FixedFrame
"Visualizing a coordinate system including axes labels (visualization data may vary dynamically)"
import Modelica.Mechanics.MultiBody.Types;
extends Modelica.Mechanics.MultiBody.Interfaces.PartialVisualizer;
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter Boolean showLabels=true "= true, if labels shall be shown"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Distance length=0.5 "Length of axes arrows"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Distance diameter=length/world.defaultFrameDiameterFraction
"Diameter of axes arrows" annotation (Dialog(group="if animation = true", enable=animation));
input Types.Color color_x=Modelica.Mechanics.MultiBody.Types.Defaults.
FrameColor "Color of x-arrow"
annotation (Dialog(colorSelector=true,group="if animation = true", enable=animation));
input Types.Color color_y=color_x "Color of y-arrow"
annotation (Dialog(colorSelector=true,group="if animation = true", enable=animation));
input Types.Color color_z=color_x "Color of z-arrow"
annotation (Dialog(colorSelector=true,group="if animation = true", enable=animation));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(group="if animation = true", enable=animation));
protected
parameter Boolean animation2 = world.enableAnimation and animation;
parameter Boolean showLabels2= world.enableAnimation and animation and showLabels;
// Parameters to define axes
SI.Length headLength=min(length, diameter*Types.Defaults.FrameHeadLengthFraction);
SI.Length headWidth=diameter*Types.Defaults.FrameHeadWidthFraction;
SI.Length lineLength=max(0, length - headLength);
SI.Length lineWidth=diameter;
// Parameters to define axes labels
SI.Length scaledLabel=Modelica.Mechanics.MultiBody.Types.Defaults.FrameLabelHeightFraction*diameter;
SI.Length labelStart=1.05*length;
// x-axis
Visualizers.Advanced.Shape x_arrowLine(
shapeType="cylinder",
length=lineLength,
width=lineWidth,
height=lineWidth,
lengthDirection={1,0,0},
widthDirection={0,1,0},
color=color_x,
specularCoefficient=specularCoefficient,
r=frame_a.r_0,
R=frame_a.R) if animation2;
Visualizers.Advanced.Shape x_arrowHead(
shapeType="cone",
length=headLength,
width=headWidth,
height=headWidth,
lengthDirection={1,0,0},
widthDirection={0,1,0},
color=color_x,
specularCoefficient=specularCoefficient,
r=frame_a.r_0 + Frames.resolve1(frame_a.R, {lineLength,0,0}),
R=frame_a.R) if animation2;
Visualizers.Internal.Lines x_label(
lines=scaledLabel*{[0, 0; 1, 1],[0, 1; 1, 0]},
diameter=diameter,
color=color_x,
specularCoefficient=specularCoefficient,
r_lines={labelStart,0,0},
n_x={1,0,0},
n_y={0,1,0},
r=frame_a.r_0,
R=frame_a.R) if showLabels2;
// y-axis
Visualizers.Advanced.Shape y_arrowLine(
shapeType="cylinder",
length=lineLength,
width=lineWidth,
height=lineWidth,
lengthDirection={0,1,0},
widthDirection={1,0,0},
color=color_y,
specularCoefficient=specularCoefficient,
r=frame_a.r_0,
R=frame_a.R) if animation2;
Visualizers.Advanced.Shape y_arrowHead(
shapeType="cone",
length=headLength,
width=headWidth,
height=headWidth,
lengthDirection={0,1,0},
widthDirection={1,0,0},
color=color_y,
specularCoefficient=specularCoefficient,
r=frame_a.r_0 + Frames.resolve1(frame_a.R, {0,lineLength,0}),
R=frame_a.R) if animation2;
Visualizers.Internal.Lines y_label(
lines=scaledLabel*{[0, 0; 1, 1.5],[0, 1.5; 0.5, 0.75]},
diameter=diameter,
color=color_y,
specularCoefficient=specularCoefficient,
r_lines={0,labelStart,0},
n_x={0,1,0},
n_y={-1,0,0},
r=frame_a.r_0,
R=frame_a.R) if showLabels2;
// z-axis
Visualizers.Advanced.Shape z_arrowLine(
shapeType="cylinder",
length=lineLength,
width=lineWidth,
height=lineWidth,
lengthDirection={0,0,1},
widthDirection={0,1,0},
color=color_z,
specularCoefficient=specularCoefficient,
r=frame_a.r_0,
R=frame_a.R) if animation2;
Visualizers.Advanced.Shape z_arrowHead(
shapeType="cone",
length=headLength,
width=headWidth,
height=headWidth,
lengthDirection={0,0,1},
widthDirection={0,1,0},
color=color_z,
specularCoefficient=specularCoefficient,
r=frame_a.r_0 + Frames.resolve1(frame_a.R, {0,0,lineLength}),
R=frame_a.R) if animation2;
Visualizers.Internal.Lines z_label(
lines=scaledLabel*{[0, 0; 1, 0],[0, 1; 1, 1],[0, 1; 1, 0]},
diameter=diameter,
color=color_z,
specularCoefficient=specularCoefficient,
r_lines={0,0,labelStart},
n_x={0,0,1},
n_y={0,1,0},
r=frame_a.r_0,
R=frame_a.R) if showLabels2;
equation
frame_a.f = zeros(3);
frame_a.t = zeros(3);
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-100,100},{100,-100}},
lineColor={0,127,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{-2,92},{-14,52},{10,52},{-2,92},{-2,92}},
lineColor={0,191,0},
fillColor={0,191,0},
fillPattern=FillPattern.Solid),
Line(
points={{-2,-18},{-2,52}},
color={0,191,0},
thickness=0.5),
Text(
extent={{16,93},{67,43}},
textColor={0,191,0},
textString="y"),
Text(
extent={{43,11},{92,-38}},
textString="x"),
Polygon(
points={{98,-70},{74,-44},{64,-60},{98,-70}},
fillPattern=FillPattern.Solid),
Line(
points={{-2,-18},{72,-54}},
thickness=0.5),
Line(
points={{-72,-54},{-2,-18}},
thickness=0.5,
color={0,0,255}),
Text(
extent={{-87,13},{-38,-36}},
textString="z",
textColor={0,0,255}),
Text(
extent={{-150,145},{150,105}},
textString="%name",
textColor={0,0,255}),
Polygon(points={{-98,-68},{-66,-60},{-78,-46},{-98,-68}}, lineColor={0,0,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}),
Documentation(info="<html>
<p>
Model <strong>FixedFrame</strong> visualizes the three axes of
its coordinate system <strong>frame_a</strong> together with appropriate axes
labels. A typical example is shown in the following figure:
<br>
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/FixedFrame.png\" alt=\"model Visualizers.FixedFrame\">
</p>
<p>
The sizes of the axes, the axes colors and the specular coefficient
(= reflection factor for
ambient light) can vary dynamically by
providing appropriate expressions in the input fields of the
parameter menu.
</p>
</html>"));
end FixedFrame;
model FixedArrow
"Visualizing an arrow with dynamically varying size in frame_a"
import Modelica.Mechanics.MultiBody.Types;
extends Modelica.Mechanics.MultiBody.Interfaces.PartialVisualizer;
parameter Boolean animation=true "= true, if animation shall be enabled";
input SI.Position r_tail[3]={0,0,0}
"Vector from frame_a to arrow tail, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Axis n={1,0,0} "Vector in arrow direction, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input SI.Length length=0.1 "Length of complete arrow"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Color color={0,0,255} "Color of arrow"
annotation (Dialog(colorSelector=true, group="if animation = true", enable=animation));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.VectorQuantity quantity=Types.VectorQuantity.RelativePosition
"The kind of physical quantity represented by the vector"
annotation (Dialog(group="if animation = true", enable=animation));
input Boolean headAtOrigin=false "= true, if the vector is pointing towards the origin of vector frame"
annotation (Dialog(group="if animation = true", enable=animation));
protected
Visualizers.Advanced.Vector arrowLine(
color=color,
specularCoefficient=specularCoefficient,
coordinates=n*length,
quantity=quantity,
headAtOrigin=headAtOrigin,
r=frame_a.r_0+Modelica.Mechanics.MultiBody.Frames.TransformationMatrices.resolve1(frame_a.R.T, r_tail),
R=frame_a.R) if world.enableAnimation and animation;
equation
frame_a.f = zeros(3);
frame_a.t = zeros(3);
annotation (
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Rectangle(
extent={{-100,28},{20,-28}},
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={{-150,105},{150,65}},
textString="%name",
textColor={0,0,255}),
Text(
extent={{-150,-75},{150,-105}},
textString="%length")}),
Documentation(info="<html>
<p>
Model <strong>FixedArrow</strong> defines an arrow that is
shown at the location of its frame_a.
<br>
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Arrow.png\" alt=\"model Visualizers.FixedArrow\">
</p>
<p>
The direction of the arrow specified with vector
<code>n</code> is with respect to frame_a, i.e., the local frame to which the
arrow component is attached. The direction, length and color of the arrow
can vary dynamically by providing appropriate expressions in the input
fields of the parameter menu.
</p>
<p>
The <code>quantity</code> variable defines what the vector represents, allowing
tools to scale e.g. forces and torques differently in a consistent way.
For the default value <strong>RelativePosition</strong> the obvious scaling is
1 and the relative position is shown as is.
</p>
</html>"));
end FixedArrow;
model SignalArrow
"Visualizing an arrow with dynamically varying size in frame_a based on input signal"
import Modelica.Mechanics.MultiBody.Types;
extends Modelica.Mechanics.MultiBody.Interfaces.PartialVisualizer;
parameter Boolean animation=true "= true, if animation shall be enabled";
input SI.Position r_tail[3]={0,0,0}
"Vector from frame_a to arrow tail, resolved in frame_a"
annotation (Dialog(group="if animation = true", enable=animation));
input Modelica.Mechanics.MultiBody.Types.Color color={0,0,255}
"Color of arrow"
annotation (Dialog(colorSelector=true, group="if animation = true", enable=animation));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.VectorQuantity quantity=Types.VectorQuantity.RelativePosition
"The kind of physical quantity represented by the vector"
annotation(Dialog(group="if animation = true", enable=animation));
input Boolean headAtOrigin=false "= true, if the vector is pointing towards the origin of vector frame"
annotation (Dialog(group="if animation = true", enable=animation));
Modelica.Blocks.Interfaces.RealInput r_head[3]
"Vector resolved in frame_a"
annotation (Placement(transformation(
origin={0,-120},
extent={{-20,-20},{20,20}},
rotation=90)));
protected
Visualizers.Advanced.Arrow arrow(
R=frame_a.R,
r=frame_a.r_0,
r_tail=r_tail,
r_head=r_head,
color=color,
quantity=quantity,
headAtOrigin=headAtOrigin,
specularCoefficient=specularCoefficient) if world.enableAnimation and animation;
equation
frame_a.f = zeros(3);
frame_a.t = zeros(3);
annotation (
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Line(points={{0,-102},{0,-28}}, color={0,0,127}),
Rectangle(
extent={{-100,28},{20,-28}},
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={{-150,105},{150,65}},
textString="%name",
textColor={0,0,255})}),
Documentation(info="<html>
<p>
Model <strong>SignalArrow</strong> defines an arrow that is dynamically visualized
at the location where its frame_a is attached. The
vector from the tail to the head of the arrow,
resolved in frame_a, is defined via the signal vector of
the connector <code>r_head</code> (<code><strong>Real</strong> r_head[3]</code>):<br>
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Arrow.png\" alt=\"model Visualizers.SignalArrow\">
</p>
<p>
The <code>quantity</code> variable defines what the vector represents, allowing
tools to scale e.g. forces and torques differently in a consistent way.
For the default value <strong>RelativePosition</strong> the obvious scaling is
1 and the relative position is shown as is.
</p>
<p>
The tail of the arrow is defined with input <code>r_tail</code>
with respect to frame_a (vector from the origin of frame_a to the arrow tail).
</p>
</html>"));
end SignalArrow;
model Ground "Visualizing the ground (box in z=0)"
extends Modelica.Icons.ObsoleteModel;
parameter Boolean animation=true
"= true, if animation of ground shall be enabled";
parameter Modelica.SIunits.Position length = 10
"Length and width of box (center is at x=y=0)" annotation (Dialog(enable=animation));
parameter Modelica.SIunits.Position height = 0.02
"Height of box (upper surface is at z=0, lower surface is at z=-height)"
annotation (Dialog(enable=animation));
parameter Modelica.Mechanics.MultiBody.Types.Color groundColor={0,255,0}
"Color of box" annotation (Dialog(colorSelector=true, enable=animation));
Modelica.Mechanics.MultiBody.Visualizers.FixedShape ground(
lengthDirection={1,0,0},
widthDirection={0,1,0},
animation=animation,
r_shape={-length/2,0,-height},
length=length,
height=height,
color=groundColor,
width=length)
annotation (Placement(transformation(extent={{-20,0},{0,20}})));
Modelica.Mechanics.MultiBody.Parts.Fixed fixed
annotation (Placement(transformation(extent={{-60,0},{-40,20}})));
equation
connect(fixed.frame_b, ground.frame_a) annotation (Line(
points={{-40,10},{-20,10}},
color={95,95,95},
thickness=0.5));
annotation (
obsolete = "Obsolete model - use ground visualization feature in Modelica.Mechanics.MultiBody.World, or use model Modelica.Mechanics.MultiBody.Visualizers.Rectangle instead",
Icon(
coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}),
graphics = {
Polygon(lineColor = {255, 255, 255}, fillColor = {126, 181, 78}, fillPattern = FillPattern.Solid, points = {{-100, -30}, {20, -90}, {100, 0}, {-10, 40}}),
Text(textColor = {64, 64, 64}, extent = {{20, 70}, {60, 100}}, textString = "z", horizontalAlignment = TextAlignment.Left),
Polygon(lineColor = {255, 255, 255}, fillColor = {14, 111, 1}, fillPattern = FillPattern.Solid, points = {{100, -10}, {20, -100}, {20, -90}, {100, 0}}),
Polygon(lineColor = {255, 255, 255}, fillColor = {14, 111, 1}, fillPattern = FillPattern.Solid, points = {{-100, -40}, {20, -100}, {20, -90}, {-100, -30}}), Line(origin = {6, -8}, points={{-6,-10},{-6,108}}),
Polygon(origin = {6, 0}, points={{-6,102},{-14,72},{2,72},{-6,102}}, fillPattern=FillPattern.Solid),
Text(textColor = {0,0,255}, extent = {{-150, -145}, {150, -105}}, textString = "%name")}),
Documentation(info = "<html>
<p>
This shape visualizes the x-y plane by a box.
</p>
<blockquote>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Ground.png\">
</blockquote>
</html>"));
end Ground;
model Torus "Visualizing a torus"
extends Modelica.Mechanics.MultiBody.Interfaces.PartialVisualizer;
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter Modelica.SIunits.Radius R=0.5 "Major radius (distance from center of torus to center of tube)" annotation(Dialog(enable=animation));
parameter Modelica.SIunits.Radius r=0.1 "Minor radius (radius of tube)"
annotation(Dialog(enable=animation));
parameter Modelica.SIunits.Angle opening=0 "Opening angle of torus" annotation(Dialog(enable=animation));
parameter Modelica.SIunits.Angle startAngle=-3.1415926535898
"Start angle of torus slice" annotation(Dialog(enable=animation));
parameter Modelica.SIunits.Angle stopAngle=3.1415926535898
"End angle of torus slice" annotation(Dialog(enable=animation));
parameter Boolean wireframe=false
"= true: 3D model will be displayed without faces"
annotation (Dialog(enable=animation, group="Material properties"),choices(checkBox=true));
input Modelica.Mechanics.MultiBody.Types.RealColor color={0,128,255}
"Color of surface" annotation(Dialog(enable=animation, colorSelector=true, group="Material properties"));
input Types.SpecularCoefficient specularCoefficient = 0.7
"Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog(enable=animation,group="Material properties"));
input Real transparency=0
"Transparency of shape: 0 (= opaque) ... 1 (= fully transparent)"
annotation(Dialog(enable=animation,group="Material properties"));
parameter Integer n_R=40 "Number of points along major radius R" annotation(Dialog(enable=animation,tab="Discretization"));
parameter Integer n_r=20 "Number of points along minor radius r" annotation(Dialog(enable=animation,tab="Discretization"));
protected
Advanced.Surface surface(
redeclare function surfaceCharacteristic =
Modelica.Mechanics.MultiBody.Visualizers.Advanced.SurfaceCharacteristics.torus (
R=R,
r=r,
opening=opening,
startAngle=startAngle,
stopAngle=stopAngle),
nu=n_R,
nv=n_r,
multiColoredSurface=false,
wireframe=wireframe,
color=color,
specularCoefficient=specularCoefficient,
transparency=transparency,
R=frame_a.R,
r_0=frame_a.r_0) if world.enableAnimation and animation
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
equation
// No forces and torques
frame_a.f = zeros(3);
frame_a.t = zeros(3);
annotation (
Icon(
graphics={
Text(textColor = {0,0,255}, extent = {{-150, 100}, {150, 140}}, textString = "%name"),
Polygon(lineColor = {64, 64, 64}, fillColor = {71, 152, 255}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{-72.253, 64.182}, {-77.03, 59.04}, {-81.278, 53.499}, {-84.986, 47.602}, {-88.145, 41.392}, {-90.745, 34.911}, {-92.777, 28.202}, {-94.231, 21.307}, {-95.097, 14.269}, {-95.365, 7.13}, {-95.027, -0.067}, {-94.072, -7.28}, {-92.491, -14.465}, {-90.273, -21.582}, {-87.411, -28.586}, {-83.892, -35.437}, {-79.709, -42.09}, {-74.852, -48.503}, {-69.309, -54.635}, {-63.785, -59.814}, {-57.839, -64.586}, {-51.519, -68.938}, {-44.871, -72.858}, {-37.943, -76.332}, {-30.782, -79.348}, {-23.434, -81.894}, {-15.947, -83.956}, {-8.367, -85.523}, {-0.741, -86.581}, {6.884, -87.118}, {14.46, -87.121}, {21.941, -86.577}, {29.28, -85.475}, {36.431, -83.8}, {43.345, -81.541}, {49.976, -78.686}, {56.278, -75.22}, {62.203, -71.132}, {67.704, -66.409}, {73.446, -60.364}, {78.374, -54.029}, {82.506, -47.441}, {85.863, -40.637}, {88.462, -33.653}, {90.322, -26.526}, {91.461, -19.294}, {91.899, -11.992}, {91.654, -4.659}, {90.746, 2.669}, {89.192, 9.955}, {87.011, 17.163}, {84.222, 24.255}, {80.845, 31.194}, {76.896, 37.944}, {72.396, 44.468}, {67.363, 50.728}, {61.816, 56.688}, {56.232, 61.872}, {50.304, 66.615}, {44.07, 70.907}, {37.568, 74.735}, {30.835, 78.091}, {23.91, 80.962}, {16.828, 83.337}, {9.63, 85.207}, {2.351, 86.559}, {-4.971, 87.383}, {-12.297, 87.669}, {-19.591, 87.404}, {-26.815, 86.579}, {-33.93, 85.182}, {-40.901, 83.202}, {-47.688, 80.629}, {-54.254, 77.451}, {-60.562, 73.658}, {-66.574, 69.239}, {-72.253, 64.182}, {-42.048, 32.604}, {-36.102, 37.608}, {-29.329, 40.96}, {-21.973, 42.833}, {-14.275, 43.397}, {-6.477, 42.824}, {1.179, 41.286}, {8.45, 38.956}, {15.096, 36.005}, {20.873, 32.604}, {25.864, 28.942}, {31.126, 24.443}, {36.304, 19.198}, {41.044, 13.302}, {44.991, 6.847}, {47.79, -0.074}, {49.086, -7.367}, {48.525, -14.94}, {45.751, -22.698}, {40.409, -30.55}, {33.361, -37.212}, {25.834, -41.649}, {18.025, -44.139}, {10.129, -44.963}, {2.342, -44.4}, {-5.14, -42.728}, {-12.121, -40.228}, {-18.405, -37.179}, {-23.796, -33.86}, {-28.099, -30.55}, {-32.136, -26.889}, {-36.606, -22.388}, {-41.128, -17.142}, {-45.318, -11.244}, {-48.793, -4.788}, {-51.17, 2.134}, {-52.067, 9.427}, {-51.101, 16.999}, {-47.889, 24.756}, {-42.048, 32.604}}),
Polygon(lineColor = {64, 64, 64}, fillColor = {71, 152, 255}, points = {{-72.253, 64.182}, {-66.574, 69.239}, {-60.562, 73.658}, {-54.254, 77.451}, {-47.688, 80.629}, {-40.901, 83.202}, {-33.93, 85.182}, {-26.815, 86.579}, {-19.591, 87.404}, {-12.297, 87.669}, {-4.971, 87.383}, {2.351, 86.559}, {9.63, 85.207}, {16.828, 83.337}, {23.91, 80.962}, {30.835, 78.091}, {37.568, 74.735}, {44.07, 70.907}, {50.304, 66.615}, {56.232, 61.872}, {61.816, 56.688}, {67.363, 50.728}, {72.396, 44.468}, {76.896, 37.944}, {80.845, 31.194}, {84.222, 24.255}, {87.011, 17.163}, {89.192, 9.955}, {90.746, 2.669}, {91.654, -4.659}, {91.899, -11.992}, {91.461, -19.294}, {90.322, -26.526}, {88.462, -33.653}, {85.863, -40.637}, {82.506, -47.441}, {78.374, -54.029}, {73.446, -60.364}, {67.704, -66.409}, {62.203, -71.132}, {56.278, -75.22}, {49.976, -78.686}, {43.345, -81.541}, {36.431, -83.8}, {29.28, -85.475}, {21.941, -86.577}, {14.46, -87.121}, {6.884, -87.118}, {-0.741, -86.581}, {-8.367, -85.523}, {-15.947, -83.956}, {-23.434, -81.894}, {-30.782, -79.348}, {-37.943, -76.332}, {-44.871, -72.858}, {-51.519, -68.938}, {-57.839, -64.586}, {-63.785, -59.814}, {-69.309, -54.635}, {-74.852, -48.503}, {-79.709, -42.09}, {-83.892, -35.437}, {-87.411, -28.586}, {-90.273, -21.582}, {-92.491, -14.465}, {-94.072, -7.28}, {-95.027, -0.067}, {-95.365, 7.13}, {-95.097, 14.269}, {-94.231, 21.307}, {-92.777, 28.202}, {-90.745, 34.911}, {-88.145, 41.392}, {-84.986, 47.602}, {-81.278, 53.499}, {-77.03, 59.04}, {-72.253, 64.182}}, smooth = Smooth.Bezier),
Polygon(fillColor = {10, 90, 224}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{-90.183, 4.774}, {-89.29, -2.507}, {-87.65, -9.672}, {-85.311, -16.688}, {-82.321, -23.518}, {-78.731, -30.128}, {-74.59, -36.482}, {-69.946, -42.545}, {-64.848, -48.282}, {-59.347, -53.657}, {-53.49, -58.634}, {-47.328, -63.18}, {-40.909, -67.257}, {-34.282, -70.832}, {-27.497, -73.868}, {-20.602, -76.331}, {-13.647, -78.185}, {-5.658, -79.626}, {2.34, -80.443}, {10.288, -80.644}, {18.126, -80.24}, {25.794, -79.24}, {33.233, -77.653}, {40.384, -75.488}, {47.186, -72.756}, {53.58, -69.465}, {59.505, -65.625}, {64.904, -61.246}, {69.715, -56.337}, {73.88, -50.907}, {77.338, -44.966}, {72.917, -49.023}, {67.981, -52.591}, {62.575, -55.671}, {56.742, -58.265}, {50.527, -60.374}, {43.974, -62}, {37.126, -63.144}, {30.029, -63.808}, {22.726, -63.992}, {15.26, -63.699}, {7.678, -62.93}, {0.022, -61.686}, {-7.664, -59.969}, {-15.335, -57.779}, {-22.947, -55.12}, {-30.456, -51.991}, {-37.819, -48.395}, {-44.99, -44.333}, {-51.925, -39.806}, {-58.582, -34.816}, {-64.915, -29.364}, {-70.88, -23.451}, {-76.433, -17.08}, {-81.531, -10.251}, {-86.129, -2.966}, {-90.183, 4.774}}, smooth = Smooth.Bezier),
Polygon(fillColor = {156, 203, 255}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{0.803, -51.958}, {11.03, -53.644}, {20.576, -54.192}, {29.425, -53.684}, {37.562, -52.2}, {44.974, -49.821}, {51.644, -46.628}, {57.559, -42.703}, {62.704, -38.126}, {67.064, -32.978}, {70.624, -27.34}, {73.369, -21.294}, {75.285, -14.92}, {76.358, -8.3}, {76.572, -1.513}, {75.912, 5.358}, {74.365, 12.233}, {71.914, 19.03}, {68.546, 25.669}, {64.246, 32.069}, {68.464, 23.809}, {71.022, 16.316}, {71.227, 10.492}, {68.389, 7.237}, {61.817, 7.45}, {63.346, 1.807}, {64.026, -4.042}, {63.843, -9.992}, {62.781, -15.937}, {60.828, -21.772}, {57.969, -27.392}, {54.19, -32.691}, {49.477, -37.563}, {43.817, -41.905}, {37.194, -45.61}, {29.595, -48.574}, {21.006, -50.69}, {11.414, -51.853}, {0.803, -51.958}}, smooth = Smooth.Bezier),
Polygon(fillColor = {10, 90, 224}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{-45.225, -15.029}, {-49.203, -8.642}, {-52.162, -1.742}, {-54.02, 5.476}, {-54.695, 12.821}, {-54.106, 20.097}, {-52.17, 27.112}, {-48.806, 33.671}, {-43.932, 39.581}, {-37.465, 44.648}, {-31.91, 47.581}, {-25.763, 49.807}, {-19.146, 51.3}, {-12.181, 52.031}, {-4.989, 51.974}, {2.308, 51.103}, {9.588, 49.389}, {16.73, 46.807}, {23.612, 43.33}, {30.112, 38.929}, {36.108, 33.579}, {41.479, 27.252}, {35.949, 35.695}, {30.184, 42.766}, {24.221, 48.561}, {18.099, 53.176}, {11.854, 56.706}, {5.525, 59.247}, {-0.853, 60.892}, {-7.24, 61.739}, {-13.601, 61.881}, {-19.897, 61.415}, {-26.091, 60.436}, {-34.854, 57.822}, {-42.105, 53.874}, {-47.925, 48.813}, {-52.395, 42.856}, {-55.596, 36.221}, {-57.609, 29.128}, {-58.514, 21.794}, {-58.393, 14.437}, {-57.327, 7.278}, {-55.396, 0.533}, {-52.681, -5.579}, {-49.264, -10.839}, {-45.225, -15.029}}, smooth = Smooth.Bezier),
Polygon(fillColor = {156, 203, 255}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, points = {{-61.245, -15.029}, {-64.25, -7.37}, {-66.703, 0.324}, {-68.557, 7.994}, {-69.768, 15.582}, {-70.289, 23.03}, {-70.075, 30.28}, {-69.08, 37.274}, {-67.259, 43.954}, {-64.565, 50.261}, {-60.954, 56.138}, {-56.379, 61.526}, {-50.794, 66.368}, {-44.155, 70.605}, {-38.685, 73.337}, {-32.863, 75.726}, {-26.675, 77.722}, {-20.107, 79.277}, {-13.142, 80.344}, {-5.768, 80.876}, {2.031, 80.823}, {10.27, 80.138}, {18.963, 78.773}, {28.124, 76.68}, {17.648, 80.219}, {7.69, 82.637}, {-1.726, 84.047}, {-10.579, 84.565}, {-18.845, 84.302}, {-26.501, 83.375}, {-33.526, 81.896}, {-39.897, 79.98}, {-45.592, 77.74}, {-50.587, 75.291}, {-54.86, 72.746}, {-61.395, 67.72}, {-66.745, 62.054}, {-70.958, 55.843}, {-74.083, 49.184}, {-76.168, 42.174}, {-77.262, 34.908}, {-77.413, 27.483}, {-76.671, 19.994}, {-75.082, 12.539}, {-72.697, 5.213}, {-69.564, -1.888}, {-65.73, -8.667}, {-61.245, -15.029}}, smooth = Smooth.Bezier),
Polygon(lineColor = {64, 64, 64}, fillColor = {255, 255, 255}, points = {{-42.048, 32.604}, {-36.102, 37.608}, {-29.329, 40.96}, {-21.973, 42.833}, {-14.275, 43.397}, {-6.477, 42.824}, {1.179, 41.286}, {8.45, 38.956}, {15.096, 36.005}, {20.873, 32.604}, {25.864, 28.942}, {31.126, 24.443}, {36.304, 19.198}, {41.044, 13.302}, {44.991, 6.847}, {47.79, -0.074}, {49.086, -7.367}, {48.525, -14.94}, {45.751, -22.698}, {40.409, -30.55}, {33.361, -37.212}, {25.834, -41.649}, {18.025, -44.139}, {10.129, -44.963}, {2.342, -44.4}, {-5.14, -42.728}, {-12.121, -40.228}, {-18.405, -37.179}, {-23.796, -33.86}, {-28.099, -30.55}, {-32.136, -26.889}, {-36.606, -22.388}, {-41.128, -17.142}, {-45.318, -11.244}, {-48.793, -4.788}, {-51.17, 2.134}, {-52.067, 9.427}, {-51.101, 16.999}, {-47.889, 24.756}, {-42.048, 32.604}})},
coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true)),
Documentation(info="<html> <p>
Model <strong>Torus</strong> visualizes a torus. The center of the torus is located at
connector frame_a (visualized by the red coordinate system in the figure below).
The left image below shows a torus with <var>R</var> = 0.5 m and
<var>r</var> = 0.2 m.
The right images below shows the torus with the additional parameter
settings:
</p>
<blockquote><pre>
opening = 45 degree
startAngle = -135 degree
stopAngle = 135 degree
</pre></blockquote>
<blockquote>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Visualizers/Torus.png\">
</blockquote>
<p>
In the advanced menu the discretization of the surface visualization can be defined by
the number <var>n<sub>R</sub></var> of points along the major radius of the torus and by
the number <var>n<sub>r</sub></var> of points along the minor radius of the torus.
In case the torus is closed (that is, <code>opening</code> = 0 degree),
the actual number of points is one less (that is <var>n<sub>R</sub></var> - 1, <var>n<sub>r</sub></var> - 1), because the first and
the last point of the parametrization coincide in this case.
</p>
</html>", revisions="<html>
<ul>
<li> July 2010 by Martin Otter<br>
Adapted to the new Surface model.</li>
<li> July 2005 by Dirk Zimmer (practical training at DLR)<br>
First version to visualize a multi-level tyre wheel model.</li>
</ul>
</html>"));
end Torus;
model VoluminousWheel "Visualizing a voluminous wheel"
extends Modelica.Mechanics.MultiBody.Interfaces.PartialVisualizer;
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter SI.Radius rTire=0.25 "Radius of the tire";
parameter SI.Radius rRim= 0.14 "Radius of the rim";
parameter SI.Radius width=0.25 "Width of the tire";
parameter SI.Radius rCurvature=0.30 "Radius of the tire's cross section";
parameter Modelica.Mechanics.MultiBody.Types.RealColor color={64,64,64}
"Color of tire" annotation(Dialog(enable=animation, colorSelector=true, group="Material properties"));
parameter Types.SpecularCoefficient specularCoefficient = 0.5
"Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog(enable=animation, group="Material properties"));
parameter Integer n_rTire=40 "Number of points along rTire" annotation(Dialog(enable=animation, tab="Discretization"));
parameter Integer n_rCurvature=20 "Number of points along rCurvature" annotation(Dialog(enable=animation, tab="Discretization"));
protected
parameter SI.Radius rw = (width/2);
parameter SI.Radius rCurvature2 = if rCurvature > rw then rCurvature else rw;
final parameter Real kw = rw/rCurvature2 "Regularized width ratio (0...1)";
parameter SI.Radius h = sqrt(1 - kw*kw) * rCurvature2;
parameter SI.Length ri = rTire-rCurvature2;
parameter SI.Radius rRim2 = if rRim < 0 then 0 else if rRim > ri+h then ri+h else rRim;
Visualizers.Advanced.Shape pipe(
shapeType="pipe",
color=color,
length= width,
width=2*(ri+h),
height=2*(ri+h),
lengthDirection={0,1,0},
widthDirection={0,0,1},
extra=(rRim2)/(ri+h),
r=frame_a.r_0,
r_shape= -{0,1,0}*(width/2),
R= frame_a.R,
specularCoefficient = specularCoefficient) if world.enableAnimation and animation
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
Visualizers.Advanced.Surface torus(
redeclare function surfaceCharacteristic =
Modelica.Mechanics.MultiBody.Visualizers.Advanced.SurfaceCharacteristics.torus (
R=ri,
r=rCurvature2,
opening=Modelica.Constants.pi - Modelica.Math.asin(kw)),
nu=n_rTire,
nv=n_rCurvature,
multiColoredSurface=false,
wireframe=false,
color=color,
specularCoefficient=specularCoefficient,
transparency=0,
R=frame_a.R,
r_0=frame_a.r_0) if world.enableAnimation and animation
annotation (Placement(transformation(extent={{-50,-10},{-30,10}})));
equation