Skip to content

Commit 456e01f

Browse files
authored
Merge pull request #50 from kiruma524/tutorial
Tutorial
2 parents 4a2b891 + d51a38e commit 456e01f

File tree

1 file changed

+164
-40
lines changed

1 file changed

+164
-40
lines changed

docs/tutorial.md

Lines changed: 164 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tutorial
1+
# Tutorial
22

3-
###The main goal of this tutorial is to show all capabilities of ... (this part will be supplemented)
3+
#### The main goal of this tutorial is to show all capabilities of ... (this part will be supplemented)
44

55
The simple visualization can be made with function `main`. (this part will be supplemented as well)
66
```kotlin
@@ -28,19 +28,19 @@ fun main(){
2828
}
2929
}
3030
```
31-
##Solids properties
31+
## Solids properties
3232
**We will analyze which basic properties solids have using `box` solid.**
3333

34-
Basic properties:
34+
*Basic properties:*
3535
1. `opacity` - It is set in `float`. It takes on values from 0 to 1, which represent percents of solid opacity. It's initial value is 1.
3636
2. `color` - It can be specified as `Int`, `String`, or as three `Ubytes`, which represent color in `rgb`. Elementally, the solid will have `green` color.
37-
3. `rotation` - it's the point, around which the solid will be rotated. Initially, the value is `Point3D(0, 0, 0)`
38-
4. position, which is given by values `x`, `y`, `z`. Initial values are `x = 0`, `y = 0`, `z = 0`
37+
3. `rotation` - it's the point, around which the solid will be rotated. Initially, the value is `Point3D(0, 0, 0)`. Changing `x` coordinate of the point, you make pivot around `x axis`. The same for other coordinates: changing `y` - pivot around `y axis`, changing `z` - pivot around `z axis`.
38+
4. position, which is given by values `x`, `y`, `z`. Initial values are `x = 0`, `y = 0`, `z = 0`. The coordinate system is Cartesian. It's elemental position is this - vertical `y` axis and horizontal `Oxz` plane.
3939

4040
Let's see how properties are set in solids.
4141
The `small box` will have elemental values of properties. If you will not set properties, it will have the same `position`, `color`, `rotation`, and `opacity` values.
4242

43-
***You can see that `box` take four values. Later, we will discuss what they are doing in more detail. Now, it does not really matter.***
43+
***You can see that `box` take four values. Later, we will discuss what they do in more detail. Now, it does not really matter.***
4444
```kotlin
4545
box(10, 10, 10, name = "small box"){
4646
x = 0
@@ -65,7 +65,6 @@ box(40, 40, 40, name = "big box"){
6565
}
6666
```
6767
![](../docs/images/big-rotated-box.png)
68-
6968
If we compare these boxes, we will see all differences.
7069

7170
Here is the function `main` with both boxes.
@@ -107,52 +106,90 @@ fun main(){
107106
![](../docs/images/two-boxes-1.png)
108107
![](../docs/images/two-boxes-2.png)
109108

110-
###Basic Solids
109+
***There is plenty of other properties, especially of those, which you can create by yourself. Here we mention just small part.***
111110

111+
## Basic Solids
112112
Now, let's see which solids can be visualized:
113-
1) PolyLine
114-
2) Box
115-
```kotlin
113+
### 1) PolyLine
114+
### 2) Box
115+
116+
First thing which has to be mentioned is that `box` takes four values: `box(x, y, z, name)`
117+
* `x` - x-axis length of the `box`
118+
* `y` - y-axis length of the `box`
119+
* `z` - z-axis length of the `box`
120+
121+
These values have `Float` type. *`x`, `y`, and `z` are necessary values, which cannot be ignored. You have to set them.*
122+
123+
* `name` - `box`'es identifier with `String` type. *It's an optional value, but without it you won't be able to control solid.*
124+
125+
Let's create just usual `box` with equal ribs.
126+
127+
```kotlin
116128
box(50, 50, 50, name = "box") {
117-
x = 0
118-
y = 0
119-
z = 0
120129
color("pink")
121130
}
122-
```
131+
```
123132
![](../docs/images/box.png)
133+
134+
Now, let's make `box` with bigger `y` value.
124135
```kotlin
125-
box(10, 25, 10, name = "high_box") {
126-
x = 0
127-
y = 0
128-
z = 0
136+
box(10, 25, 10, name = "high box") {
129137
color("black")
130138
}
131139
```
140+
As you can see, only rib of `y-axis` differs from other ribs.
141+
132142
![](../docs/images/high-box.png)
143+
144+
For final trial, let's create `box` with bigger `x` value.
133145

134146
```kotlin
135-
box(65, 40, 40, name = "wide_box") {
147+
box(65, 40, 40, name = "wide box") {
136148
x = 0
137149
y = 0
138150
z = 0
139151
color("black")
140152
}
141153
```
154+
Predictably, only `x-axis` rib bigger than other ribs.
155+
142156
![](../docs/images/wide-box.png)
143157

144-
3) Sphere
158+
### 3) Sphere
159+
160+
It takes in two values: `radius`, and `name`.
161+
Actually, `name` is general value for all solids, so do not wonder, since all solids need their own identifier.
162+
163+
As for `radius`, it has `Float` type, and, as you can guess, it sets radius of the sphere, which will be created.
145164
```kotlin
146165
sphere(50, name = "sphere") {
147166
x = 0
148167
y = 0
149168
z = 0
169+
opacity = 0.9
150170
color("blue")
151171
}
152172
```
153173
![](../docs/images/sphere.png)
154-
4) Hexagon
155-
```kotlin
174+
175+
### 4) Hexagon
176+
177+
It is solid which has six edges. It is set by eight values: `node1`,..., `node8`. They all have `Point3D` type, so they are just points, vertices.
178+
179+
*Six edges are these:*
180+
1) Edge with vertices `node1`, `node4`, `node3`, `node2`
181+
2) Edge with vertices `node1`, `node2`, `node6`, `node5`
182+
3) Edge with vertices `node2`, `node3`, `node7`, `node6`
183+
4) Edge with vertices `node4`, `node8`, `node7`, `node3`
184+
5) Edge with vertices `node1`, `node5`, `node8`, `node4`
185+
6) Edge with vertices `node8`, `node5`, `node6`, `node7`
186+
187+
![](../docs/images/scheme.png)
188+
189+
As hexagon takes in specific points, we understand that this solid cannot be moved, it fixed in space, and it can't make pivots.
190+
191+
Let's make classic parallelepiped.
192+
```kotlin
156193
hexagon(
157194
Point3D(25, 30, 25),
158195
Point3D(35, 30, 25),
@@ -162,11 +199,14 @@ Now, let's see which solids can be visualized:
162199
Point3D(40, 18, 20),
163200
Point3D(40, 18, 10),
164201
Point3D(30, 18, 10),
165-
name = "classic_hexagon"){
202+
name = "classic hexagon"){
166203
color("green")
167204
}
168-
```
205+
```
169206
![](../docs/images/classic-hexagon.png)
207+
208+
Now, let's make a custom hexagon.
209+
170210
```kotlin
171211
hexagon(
172212
Point3D(5, 30, 5),
@@ -182,28 +222,112 @@ Now, let's see which solids can be visualized:
182222
}
183223
```
184224
![](../docs/images/custom-hexagon.png)
185-
5) Cone
186-
```kotlin
225+
### 3) Cone
226+
It takes in six values: `bottomRadius`, `height`, `upperRadius`, `startAngle`, `angle`, and `name`.
227+
228+
Obviously, `bottomRadius` is responsible for radius of a bottom base, and `height` sets height of a cone along the `z-axis`.
229+
230+
As it takes such values as `upperRadius`, `startAngle`, `angle`, `cone` can build not only usual cones, but also cone segments. Initially, `upperRadius` will have `0.0` value, `startAngle` - `0f`, `angle` - `PI2`, so if you don't set them, you'll get just a simple cone.
231+
232+
Setting `upperRadius`, you make a frustum cone, since it sets a radius of the upper base of a cone. Set `startAngle`, and `angle` let to cut off segments by planes perpendicular to the base. `startAngle` - an angle, starting with which segment will be left, `angle` - an angle of cone, which will be set from `startAngle`.
233+
234+
Let's build a classic cone:
235+
```kotlin
187236
cone(60, 80, name = "cone") {
188-
x = 0
189-
y = 0
190-
z = 0
191237
color("beige")
192238
}
193239
```
194240
![](../docs/images/cone-1.png)
195241
![](../docs/images/cone-2.png)
196-
6) Cone Surface
197-
```kotlin
198-
coneSurface(60, 50, 30, 10, 100, name = "cone_surface") {
199-
x = 0
200-
y = 0
201-
z = 0
242+
243+
First of all, we have to try to build a frustum cone:
244+
```kotlin
245+
cone(60, 80, name = "cone") {
246+
color(0u, 40u, 0u)
247+
}
248+
```
249+
![](../docs/images/frustum-cone.png)
250+
251+
Now, we need to make a try to build a cone segment:
252+
253+
```kotlin
254+
cone(60, 80, angle = PI, name = "cone") {
255+
color(0u, 0u, 200u)
256+
}
257+
```
258+
![](../docs/images/cone-segment-1.png)
259+
![](../docs/images/cone-segment-2.png)
260+
261+
Finally, the segment of frustum cone is left for a try:
262+
```kotlin
263+
cone(60, 100, 20, PI*3/4, angle = PI/3, name = "cone") {
264+
color(190u, 0u, 0u)
265+
}
266+
```
267+
![](../docs/images/frustum-cone-segment.png)
268+
269+
### 4) Cone Surface
270+
This solid is set by seven values:`bottomOuterRadius`, `bottomInnerRadius`, `height`, `topOuterRadius`, `topInnerRadius`, `startAngle`, and `angle`.
271+
272+
In addition to `height`, `startAngle`, and `angle`, which work as they work in `cone`, there are some new values.
273+
`bottomOuterRadius`, and `bottomInnerRadius` set properties of the bottom circle, `topOuterRadius`, `topInnerRadius` - of the upper circle. They have no initial value, so that means they have to be set.
274+
275+
Generally, `cone`, and `coneSurface` buildings work in the same way, it's possible to make `coneSurface`'s fragments as in `cone`
276+
277+
Let's build usual cone surface with almost all properties set:
278+
```kotlin
279+
coneSurface(60, 50, 30, 10, 100, name = "cone surface") {
202280
color("red")
203281
rotation = Point3D(2, 50, -9)
204282
}
205283
```
206-
![](../docs/images/cone-surface-1.png)
207-
![](../docs/images/cone-surface-2.png)
208-
7) Extruded
284+
![](../docs/images/cone-surface-1.png)
285+
![](../docs/images/cone-surface-2.png)
286+
287+
Now, let's create a cone surface and set all it's properties:
288+
289+
```kotlin
290+
coneSurface(30, 25, 10, 10, 8,0f, pi*3/4, name = "cone surface") {
291+
color("fuchsia")
292+
rotation = Point3D(2, 50, -9)
293+
}
294+
```
295+
![](../docs/images/cone-surface-fragment.png)
296+
![](../docs/images/cone-surface-fragment-2.png)
297+
298+
### 5) Cylinder
299+
300+
This solid is set by `radius`, and `height`. As you can see by accepting values, there's no option of building fragments of cylinders.
301+
302+
Here's a demonstration of a cylinder:
303+
304+
```kotlin
305+
cylinder(40, 100, "cylinder"){
306+
rotation = Point3D(40, 0, 0)
307+
color("indigo")
308+
}
309+
```
310+
![](../docs/images/cylinder-1.png)
311+
![](../docs/images/cylinder-2.png)
312+
### 6) Tube
313+
314+
`tube` takes in `radius`, `height`, `innerRadius`, `startAngle`, `angle`, and `name`. *All values are familiar from `cone`, and `coneSurface` solids.*
315+
316+
Here is an example of classic tube:
317+
```kotlin
318+
tube(50, 40, 20, name = "usual tube"){
319+
opacity = 0.4
320+
}
321+
```
322+
![](../docs/images/tube.png)
323+
324+
This is an example of tube fragment:
325+
326+
```kotlin
327+
tube(50, 40, 20, 0f, PI, name = "fragmented tube"){
328+
color("white")
329+
}
330+
```
331+
![](../docs/images/tube-fragment.png)
332+
### 7) Extruded
209333

0 commit comments

Comments
 (0)