You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
###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)
4
4
5
5
The simple visualization can be made with function `main`. (this part will be supplemented as well)
6
6
```kotlin
@@ -28,19 +28,19 @@ fun main(){
28
28
}
29
29
}
30
30
```
31
-
##Solids properties
31
+
##Solids properties
32
32
**We will analyze which basic properties solids have using `box` solid.**
33
33
34
-
Basic properties:
34
+
*Basic properties:*
35
35
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.
36
36
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.
39
39
40
40
Let's see how properties are set in solids.
41
41
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.
42
42
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.***
If we compare these boxes, we will see all differences.
70
69
71
70
Here is the function `main` with both boxes.
@@ -107,52 +106,90 @@ fun main(){
107
106

108
107

109
108
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.***
111
110
111
+
## Basic Solids
112
112
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
116
128
box(50, 50, 50, name ="box") {
117
-
x =0
118
-
y =0
119
-
z =0
120
129
color("pink")
121
130
}
122
-
```
131
+
```
123
132

133
+
134
+
Now, let's make `box` with bigger `y` value.
124
135
```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") {
129
137
color("black")
130
138
}
131
139
```
140
+
As you can see, only rib of `y-axis` differs from other ribs.
141
+
132
142

143
+
144
+
For final trial, let's create `box` with bigger `x` value.
133
145
134
146
```kotlin
135
-
box(65, 40, 40, name ="wide_box") {
147
+
box(65, 40, 40, name ="wide box") {
136
148
x =0
137
149
y =0
138
150
z =0
139
151
color("black")
140
152
}
141
153
```
154
+
Predictably, only `x-axis` rib bigger than other ribs.
155
+
142
156

143
157
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.
145
164
```kotlin
146
165
sphere(50, name ="sphere") {
147
166
x =0
148
167
y =0
149
168
z =0
169
+
opacity =0.9
150
170
color("blue")
151
171
}
152
172
```
153
173

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
+

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
156
193
hexagon(
157
194
Point3D(25, 30, 25),
158
195
Point3D(35, 30, 25),
@@ -162,11 +199,14 @@ Now, let's see which solids can be visualized:
162
199
Point3D(40, 18, 20),
163
200
Point3D(40, 18, 10),
164
201
Point3D(30, 18, 10),
165
-
name ="classic_hexagon"){
202
+
name ="classic hexagon"){
166
203
color("green")
167
204
}
168
-
```
205
+
```
169
206

207
+
208
+
Now, let's make a custom hexagon.
209
+
170
210
```kotlin
171
211
hexagon(
172
212
Point3D(5, 30, 5),
@@ -182,28 +222,112 @@ Now, let's see which solids can be visualized:
182
222
}
183
223
```
184
224

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
187
236
cone(60, 80, name ="cone") {
188
-
x =0
189
-
y =0
190
-
z =0
191
237
color("beige")
192
238
}
193
239
```
194
240

195
241

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
+

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
+

259
+

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
+

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") {
202
280
color("red")
203
281
rotation =Point3D(2, 50, -9)
204
282
}
205
283
```
206
-

207
-

208
-
7) Extruded
284
+

285
+

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
+

296
+

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
+

311
+

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
+

323
+
324
+
This is an example of tube fragment:
325
+
326
+
```kotlin
327
+
tube(50, 40, 20, 0f, PI, name ="fragmented tube"){
0 commit comments