Skip to content

Commit 8552f6d

Browse files
committed
docu: update GettingStarted tutorial
1 parent b4984cb commit 8552f6d

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed
23.9 KB
Loading

docs/src/tutorial/CollisionHandling.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ plot(bouncingSphere, "free.r", figure=1)
3636
3737
end
3838
```
39+
The commands above generate an instance of the model, simulate it and generate the following plot:
3940

41+
![Tutorial-Collision](../../resources/images/Tutorial/bouncingSphere.png)
4042

4143
Note:
4244

docs/src/tutorial/GettingStarted.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ An [Object3D](@ref) constructor is the core element of Modia3D. It defines a coo
88

99
## 1. Pendulum
1010

11-
In the following example a simple pendulum is defined (this is a copy of `$(Modia3D.path)/test/Tutorial/Pendulum1.jl`):
11+
In the following example a simple pendulum is defined. This example is a copy of: `$(Modia3D.path)/test/Tutorial/Pendulum1.jl`
1212

1313
```julia
1414
module Pendulum1
@@ -25,10 +25,15 @@ Pendulum = Model(
2525
pendulum = @instantiateModel(buildModia3D(Pendulum), unitless=true)
2626
simulate!(pendulum, stopTime=3.0)
2727

28-
@usingModiaPlot # use the plot package defined by ENV["MODIA_PLOT"]
28+
@usingModiaPlot # use the plot package defined by ENV["MODIA_PLOT"]
2929
plot(pendulum, "rev.phi")
3030
end
3131
```
32+
or
33+
```julia
34+
import Modia3D
35+
include("$(Modia3D.path)/test/Tutorial/Pendulum1.jl")
36+
```
3237

3338
The `world` [Object3D](@ref) has feature [Scene](@ref) and is therefore the inertial system. The `body` Object3D is a [Solid](@ref) and defines the pendulum as a mass point with `mass = 1.0`. The `bodyFrame` Object3D defines a coordinate system on the `body` that is translated along the x-axis. A revolute joint connects `world` with `bodyFrame`.
3439

@@ -41,7 +46,7 @@ The commands above generate an instance of the model, simulate it and generate t
4146

4247
## 2. Pendulum with Animation
4348

44-
The Object3Ds of the first example are extended with [Visual](@ref) and [Solid](@ref) features in order that the pendulum parts are visualized and exported for offline animation by defining `animationFile = "Pendulum2.json"` in [Scene](@ref). The first Object3D `obj1` is defined as a solid [Box](@ref) with `"Blue"`color and its [Solid material](@ref) is made of `"Steel"`. Mass, center of mass and inertia tensor are computed from Steel density and from the [Box](@ref) shape. The second Object3D `obj2` is a visual red [Cylinder](@ref) that is used to visualize the axis of the revolute joint.
49+
The Object3Ds of the first example are extended with [Visual](@ref) and [Solid](@ref) features in order that the pendulum parts are visualized and exported for offline animation by defining `animationFile = "Pendulum2.json"` in [Scene](@ref). The first Object3D `obj1` is defined as a solid [Box](@ref) with `"Blue"`color and its [Solid material](@ref) is made of `"Steel"`. Mass, center of mass and inertia tensor are computed from Steel density and from the [Box](@ref) shape. The second Object3D `obj2` is a visual red [Cylinder](@ref) that is used to visualize the axis of the revolute joint. Please, see example: `$(Modia3D.path)/test/Tutorial/Pendulum2.jl`
4550

4651
```julia
4752
module Pendulum2
@@ -64,10 +69,15 @@ simulate!(pendulum, stopTime=3.0)
6469
plot(pendulum, "rev.phi")
6570
end
6671
```
72+
or
73+
```julia
74+
import Modia3D
75+
include("$(Modia3D.path)/test/Tutorial/Pendulum2.jl")
76+
```
6777

6878
Open [https://threejs.org/editor/](https://threejs.org/editor/), import the json file (File --> Import) and inspect the model in threejs:
6979

70-
![Tutorial-Pendulum3](../../resources/images/Tutorial/threejs.png)
80+
![Tutorial-Pendulum2](../../resources/images/Tutorial/threejs.png)
7181

7282

7383
Export the animation in glb format (File --> Export GLB) and use an glb/glTF-viewer to inspect the animation (for example the 3D-Viewer of Windows 10).
@@ -76,16 +86,14 @@ Export the animation in glb format (File --> Export GLB) and use an glb/glTF-vie
7686

7787
## 3. Pendulum with Modia equations
7888

79-
The pendulum model from the previous section is extended with a damper that is defined with Modia language components and models the damping (sliding friction) in the revolute joint. In order that this is possible, a `RevoluteWithFlange` joints has to be used that provides a `Flange` connector to which a rotational 1-dim. `Flange` of Modia can be connected. This flange and the Damper, and the Fixed component are defined in a small Modia model library that is included via`include("$(Modia.path)/models/AllModels.jl")`.
89+
The pendulum model from the previous section is extended with a damper that is defined with Modia language components and models the damping (sliding friction) in the revolute joint. In order that this is possible, a `RevoluteWithFlange` joints has to be used that provides a `Flange` connector to which a rotational 1-dim. `Flange` of Modia can be connected. This flange and the Damper, and the Fixed component are defined in a small Modia model library that is included via`include("$(Modia.path)/models/AllModels.jl")`. Please, see example: `$(Modia3D.path)/test/Tutorial/Pendulum3.jl`
8090

8191
```julia
8292
module Pendulum3
8393

8494
using Modia
85-
import Modia3D
86-
using Modia3D.ModiaInterface
8795

88-
# Modia Modia equation-based models
96+
# Modia equation-based models
8997
include("$(Modia.modelsPath)/AllModels.jl")
9098

9199
Pendulum = Model(
@@ -96,7 +104,6 @@ Pendulum = Model(
96104
visualMaterial=VisualMaterial(color="Red")), translation=[-0.5, 0.0, 0.0]),
97105
rev = RevoluteWithFlange(obj1=:world, obj2=:obj2),
98106

99-
# combine equation based modeling with 3D models
100107
damper = Damper | Map(d=100.0),
101108
fixed = Fixed,
102109
connect = :[(damper.flange_b, rev.flange),
@@ -110,11 +117,15 @@ simulate!(pendulum, stopTime=3.0)
110117
plot(pendulum, "rev.phi")
111118
end
112119
```
120+
or
121+
```julia
122+
import Modia3D
123+
include("$(Modia3D.path)/test/Tutorial/Pendulum3.jl")
124+
```
113125

114126
The commands above generate an instance of the model, simulate it and generate the following plot:
115127

116-
![Pendulum3](../../resources/images/Tutorial/Pendulum3.png)
117-
128+
![Tutorial-Pendulum3](../../resources/images/Tutorial/Pendulum3.png)
118129

119130

120131
## 4. Example and Test Models
@@ -126,7 +137,7 @@ All examples of this tutorial are stored in `$(Modia3D.path)/test/Tutorial`.
126137
include("$(Modia3D.path)/test/Tutorial/Pendulum1.jl")
127138
include("$(Modia3D.path)/test/Tutorial/Pendulum2.jl")
128139
include("$(Modia3D.path)/test/Tutorial/Pendulum3.jl")
129-
include("$(Modia3D.path)/test/Collision/NewtonsCradle.jl")
140+
include("$(Modia3D.path)/test/Tutorial/BouncingSphere.jl")
130141
```
131142

132143
To run all tests, execute:

0 commit comments

Comments
 (0)