0.2.0 #71
@ -108,7 +108,7 @@ fun VisionLayout<Solid>.showcase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
demo("extrude", "extruded shape") {
|
demo("extrude", "extruded shape") {
|
||||||
extrude {
|
extruded {
|
||||||
shape {
|
shape {
|
||||||
polygon(8, 50)
|
polygon(8, 50)
|
||||||
}
|
}
|
||||||
|
BIN
docs/images/polyline-points-2.png
Normal file
BIN
docs/images/polyline-points-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
docs/images/polyline-points.png
Normal file
BIN
docs/images/polyline-points.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
706
docs/tutorial.md
706
docs/tutorial.md
@ -1,333 +1,373 @@
|
|||||||
# Tutorial
|
# Tutorial
|
||||||
|
|
||||||
#### The main goal of this tutorial is to show all capabilities of ... (this part will be supplemented)
|
#### The main goal of this tutorial is to show the main capabilities of the visualization instrument.
|
||||||
|
|
||||||
The simple visualization can be made with function `main`. (this part will be supplemented as well)
|
The simple visualization can be made with function `main`. (this part will be supplemented)
|
||||||
```kotlin
|
```kotlin
|
||||||
import kotlinx.html.div
|
import kotlinx.html.div
|
||||||
import space.kscience.dataforge.context.Context
|
import space.kscience.dataforge.context.Context
|
||||||
import space.kscience.visionforge.html.ResourceLocation
|
import space.kscience.visionforge.html.ResourceLocation
|
||||||
import space.kscience.visionforge.solid.*
|
import space.kscience.visionforge.solid.*
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
fun main(){
|
fun main(){
|
||||||
val context = Context{
|
val context = Context{
|
||||||
plugin(Solids)
|
plugin(Solids)
|
||||||
}
|
}
|
||||||
|
|
||||||
context.makeVisionFile (
|
context.makeVisionFile (
|
||||||
Paths.get("customFile.html"),
|
Paths.get("nameFile.html"),
|
||||||
resourceLocation = ResourceLocation.EMBED
|
resourceLocation = ResourceLocation.EMBED
|
||||||
){
|
){
|
||||||
div {
|
div {
|
||||||
vision {
|
//first vision
|
||||||
solid {
|
vision {
|
||||||
}
|
solid {
|
||||||
}
|
//solids which you want to visualize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//second vision
|
||||||
```
|
vision {
|
||||||
## Solids properties
|
solid {
|
||||||
**We will analyze which basic properties solids have using `box` solid.**
|
//solids which you want to visualize
|
||||||
|
}
|
||||||
*Basic properties:*
|
}
|
||||||
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.
|
}
|
||||||
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.
|
}
|
||||||
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`.
|
}
|
||||||
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.
|
```
|
||||||
|
## Solids properties
|
||||||
Let's see how properties are set in solids.
|
**We will analyze which basic properties solids have using `box` solid.**
|
||||||
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.
|
|
||||||
|
*Basic properties:*
|
||||||
***You can see that `box` take four values. Later, we will discuss what they do in more detail. Now, it does not really matter.***
|
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.
|
||||||
```kotlin
|
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.
|
||||||
box(10, 10, 10, name = "small box"){
|
3. `rotation` — it's the point, which sets rotations along axes. 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`.
|
||||||
x = 0
|
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.
|
||||||
y = 0
|
|
||||||
z = 0
|
Let's see how properties are set in solids.
|
||||||
opacity = 1 //100% opacity
|
The `small box` will have elemental values of properties. If you don't set properties, it will have the same `position`, `color`, `rotation`, and `opacity` values.
|
||||||
color("red") //as string
|
|
||||||
rotation = Point3D(0, 0, 0)
|
***You can see that `box` take four values. Later, we will discuss what they do in more detail. Now, it does not really matter.***
|
||||||
}
|
```kotlin
|
||||||
```
|
box(10, 10, 10, name = "small box"){
|
||||||
![](../docs/images/small-box.png)
|
x = 0
|
||||||
|
y = 0
|
||||||
The `big box` will have properties with custom values.
|
z = 0
|
||||||
```kotlin
|
opacity = 1 //100% opacity
|
||||||
box(40, 40, 40, name = "big box"){
|
color("red") //as string
|
||||||
x = 20
|
rotation = Point3D(0, 0, 0)
|
||||||
y = 10
|
}
|
||||||
z = 60
|
```
|
||||||
opacity = 0.5 //50% opacity
|
![](../docs/images/small-box.png)
|
||||||
color(0u, 179u, 179u) //color in rgb
|
|
||||||
rotation = Point3D(60, 80, 0)
|
The `big box` will have properties with custom values.
|
||||||
}
|
```kotlin
|
||||||
```
|
box(40, 40, 40, name = "big box"){
|
||||||
![](../docs/images/big-rotated-box.png)
|
x = 20
|
||||||
If we compare these boxes, we will see all differences.
|
y = 10
|
||||||
|
z = 60
|
||||||
Here is the function `main` with both boxes.
|
opacity = 0.5 //50% opacity
|
||||||
```kotlin
|
color(0u, 179u, 179u) //color in rgb
|
||||||
fun main(){
|
rotation = Point3D(60, 80, 0)
|
||||||
val context = Context{
|
}
|
||||||
plugin(Solids)
|
```
|
||||||
}
|
![](../docs/images/big-rotated-box.png)
|
||||||
|
If we compare these boxes, we will see all differences.
|
||||||
context.makeVisionFile (
|
|
||||||
Paths.get("customFile.html"),
|
Here is the function `main` with both boxes.
|
||||||
resourceLocation = ResourceLocation.EMBED
|
```kotlin
|
||||||
){
|
fun main(){
|
||||||
div {
|
val context = Context{
|
||||||
vision {
|
plugin(Solids)
|
||||||
solid {
|
}
|
||||||
box(10, 10, 10, name = "small box"){
|
|
||||||
x = 0
|
context.makeVisionFile (
|
||||||
y = 0
|
Paths.get("customFile.html"),
|
||||||
z = 0
|
resourceLocation = ResourceLocation.EMBED
|
||||||
opacity = 1 //100% opacity
|
){
|
||||||
color("red") //as string
|
div {
|
||||||
rotation = Point3D(0, 0, 0)
|
vision {
|
||||||
}
|
solid {
|
||||||
box(40, 40, 40, name = "big box"){
|
box(10, 10, 10, name = "small box"){
|
||||||
x = 20
|
x = 0
|
||||||
y = 10
|
y = 0
|
||||||
z = 60
|
z = 0
|
||||||
opacity = 0.5 //50% opacity
|
opacity = 1 //100% opacity
|
||||||
color(0u, 179u, 179u) //rgb
|
color("red") //as string
|
||||||
rotation = Point3D(60, 80, 0)
|
rotation = Point3D(0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
box(40, 40, 40, name = "big box"){
|
||||||
}
|
x = 20
|
||||||
}
|
y = 10
|
||||||
}
|
z = 60
|
||||||
}
|
opacity = 0.5 //50% opacity
|
||||||
```
|
color(0u, 179u, 179u) //rgb
|
||||||
![](../docs/images/two-boxes-1.png)
|
rotation = Point3D(60, 80, 0)
|
||||||
![](../docs/images/two-boxes-2.png)
|
}
|
||||||
|
}
|
||||||
***There is plenty of other properties, especially of those, which you can create by yourself. Here we mention just small part.***
|
}
|
||||||
|
}
|
||||||
## Basic Solids
|
}
|
||||||
Now, let's see which solids can be visualized:
|
}
|
||||||
### 1) PolyLine
|
```
|
||||||
### 2) Box
|
![](../docs/images/two-boxes-1.png)
|
||||||
|
![](../docs/images/two-boxes-2.png)
|
||||||
First thing which has to be mentioned is that `box` takes four values: `box(x, y, z, name)`
|
|
||||||
* `x` - x-axis length of the `box`
|
***There is plenty of other properties, especially those, which you can create by yourself. Here we mention just a small part.***
|
||||||
* `y` - y-axis length of the `box`
|
|
||||||
* `z` - z-axis length of the `box`
|
## Basic Solids
|
||||||
|
Now, let's see which solids can be visualized:
|
||||||
These values have `Float` type. *`x`, `y`, and `z` are necessary values, which cannot be ignored. You have to set them.*
|
### 1) PolyLine
|
||||||
|
|
||||||
* `name` - `box`'es identifier with `String` type. *It's an optional value, but without it you won't be able to control solid.*
|
It's scarcely a solid, but it can be visualized, so we mention it.
|
||||||
|
`polyline` build lines, obviously. Let's take a look at it's work.
|
||||||
Let's create just usual `box` with equal ribs.
|
|
||||||
|
`polyline` requires two values — `points`, and `name`:
|
||||||
```kotlin
|
* `points` is a `vararg` with `Point3D` type. It takes pairs of points, which you want to connect.
|
||||||
box(50, 50, 50, name = "box") {
|
* `name` is an identifier of *any solid*; but in this case, it is an identifier of `polyline`.
|
||||||
color("pink")
|
It's type is `String`. **This value can be required by any solid;
|
||||||
}
|
you can set it, you can not to set it, but without you won't be able to control solid, since it won't be inherited.**
|
||||||
```
|
|
||||||
![](../docs/images/box.png)
|
This is an example of polyline with other solid `box`:
|
||||||
|
```kotlin
|
||||||
Now, let's make `box` with bigger `y` value.
|
box(100, 100, 100, name = "box"){
|
||||||
```kotlin
|
x = -10
|
||||||
box(10, 25, 10, name = "high box") {
|
y = -10
|
||||||
color("black")
|
z = -10
|
||||||
}
|
opacity = 0.4
|
||||||
```
|
}
|
||||||
As you can see, only rib of `y-axis` differs from other ribs.
|
polyline(Point3D(30, 20, 10), Point3D(30, -100, 30), Point3D(30, -100, 30), Point3D(50, -100, 30), name = "polyline"){
|
||||||
|
color("red")
|
||||||
![](../docs/images/high-box.png)
|
}
|
||||||
|
```
|
||||||
For final trial, let's create `box` with bigger `x` value.
|
|
||||||
|
![](../docs/images/polyline-points.png)
|
||||||
```kotlin
|
![](../docs/images/polyline-points-2.png)
|
||||||
box(65, 40, 40, name = "wide box") {
|
|
||||||
x = 0
|
### 2) Box
|
||||||
y = 0
|
|
||||||
z = 0
|
First thing which has to be mentioned is that `box` takes four values: `box(x, y, z, name)`
|
||||||
color("black")
|
* `x` — x-axis length of the `box`
|
||||||
}
|
* `y` — y-axis length of the `box`
|
||||||
```
|
* `z` — z-axis length of the `box`
|
||||||
Predictably, only `x-axis` rib bigger than other ribs.
|
|
||||||
|
These values have `Float` type.
|
||||||
![](../docs/images/wide-box.png)
|
|
||||||
|
*`x`, `y`, and `z` are necessary values, which cannot be ignored. You have to set them.*
|
||||||
### 3) Sphere
|
|
||||||
|
* `name` — `box`'es identifier. You've already met it.
|
||||||
It takes in two values: `radius`, and `name`.
|
|
||||||
Actually, `name` is general value for all solids, so do not wonder, since all solids need their own identifier.
|
Let's create just usual `box` with equal ribs.
|
||||||
|
|
||||||
As for `radius`, it has `Float` type, and, as you can guess, it sets radius of the sphere, which will be created.
|
```kotlin
|
||||||
```kotlin
|
box(50, 50, 50, name = "box") {
|
||||||
sphere(50, name = "sphere") {
|
color("pink")
|
||||||
x = 0
|
}
|
||||||
y = 0
|
```
|
||||||
z = 0
|
![](../docs/images/box.png)
|
||||||
opacity = 0.9
|
|
||||||
color("blue")
|
Now, let's make `box` with bigger `y` value.
|
||||||
}
|
```kotlin
|
||||||
```
|
box(10, 25, 10, name = "high box") {
|
||||||
![](../docs/images/sphere.png)
|
color("black")
|
||||||
|
}
|
||||||
### 4) Hexagon
|
```
|
||||||
|
As you can see, only the rib of `y-axis` differs from other ribs.
|
||||||
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.
|
|
||||||
|
![](../docs/images/high-box.png)
|
||||||
*Six edges are these:*
|
|
||||||
1) Edge with vertices `node1`, `node4`, `node3`, `node2`
|
For a final trial, let's create a `box` with a bigger `x` value.
|
||||||
2) Edge with vertices `node1`, `node2`, `node6`, `node5`
|
|
||||||
3) Edge with vertices `node2`, `node3`, `node7`, `node6`
|
```kotlin
|
||||||
4) Edge with vertices `node4`, `node8`, `node7`, `node3`
|
box(65, 40, 40, name = "wide box") {
|
||||||
5) Edge with vertices `node1`, `node5`, `node8`, `node4`
|
x = 0
|
||||||
6) Edge with vertices `node8`, `node5`, `node6`, `node7`
|
y = 0
|
||||||
|
z = 0
|
||||||
![](../docs/images/scheme.png)
|
color("black")
|
||||||
|
}
|
||||||
As hexagon takes in specific points, we understand that this solid cannot be moved, it fixed in space, and it can't make pivots.
|
```
|
||||||
|
Predictably, only the `x-axis` rib is bigger than other ribs.
|
||||||
Let's make classic parallelepiped.
|
|
||||||
```kotlin
|
![](../docs/images/wide-box.png)
|
||||||
hexagon(
|
|
||||||
Point3D(25, 30, 25),
|
### 3) Sphere
|
||||||
Point3D(35, 30, 25),
|
|
||||||
Point3D(35, 30, 15),
|
It takes in two values: `radius`, and `name`.
|
||||||
Point3D(25, 30, 15),
|
We bring you to mind that `name` is a general value for all solids, so do not wonder, since all solids need their own identifier.
|
||||||
Point3D(30, 18, 20),
|
|
||||||
Point3D(40, 18, 20),
|
As for `radius`, it has `Float` type, and, as you can guess, it sets the radius of the sphere which will be created.
|
||||||
Point3D(40, 18, 10),
|
```kotlin
|
||||||
Point3D(30, 18, 10),
|
sphere(50, name = "sphere") {
|
||||||
name = "classic hexagon"){
|
x = 0
|
||||||
color("green")
|
y = 0
|
||||||
}
|
z = 0
|
||||||
```
|
opacity = 0.9
|
||||||
![](../docs/images/classic-hexagon.png)
|
color("blue")
|
||||||
|
}
|
||||||
Now, let's make a custom hexagon.
|
```
|
||||||
|
![](../docs/images/sphere.png)
|
||||||
```kotlin
|
|
||||||
hexagon(
|
### 4) Hexagon
|
||||||
Point3D(5, 30, 5),
|
|
||||||
Point3D(24, 30, 8),
|
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.
|
||||||
Point3D(20, 30, -10),
|
|
||||||
Point3D(5, 30, -7),
|
*Six edges are these:*
|
||||||
Point3D(8, 16, 0),
|
1) Edge with vertices `node1`, `node4`, `node3`, `node2`
|
||||||
Point3D(12, 16, 0),
|
2) Edge with vertices `node1`, `node2`, `node6`, `node5`
|
||||||
Point3D(10, 16, -5),
|
3) Edge with vertices `node2`, `node3`, `node7`, `node6`
|
||||||
Point3D(6.5, 12, -3),
|
4) Edge with vertices `node4`, `node8`, `node7`, `node3`
|
||||||
name = "custom_hexagon"){
|
5) Edge with vertices `node1`, `node5`, `node8`, `node4`
|
||||||
color("brown")
|
6) Edge with vertices `node8`, `node5`, `node6`, `node7`
|
||||||
}
|
|
||||||
```
|
![](../docs/images/scheme.png)
|
||||||
![](../docs/images/custom-hexagon.png)
|
|
||||||
### 3) Cone
|
As the hexagon takes in specific points, we understand that this solid cannot be moved, it is fixed in space, and it can't make pivots.
|
||||||
It takes in six values: `bottomRadius`, `height`, `upperRadius`, `startAngle`, `angle`, and `name`.
|
|
||||||
|
Let's make classic parallelepiped.
|
||||||
Obviously, `bottomRadius` is responsible for radius of a bottom base, and `height` sets height of a cone along the `z-axis`.
|
```kotlin
|
||||||
|
hexagon(
|
||||||
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.
|
Point3D(25, 30, 25),
|
||||||
|
Point3D(35, 30, 25),
|
||||||
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`.
|
Point3D(35, 30, 15),
|
||||||
|
Point3D(25, 30, 15),
|
||||||
Let's build a classic cone:
|
Point3D(30, 18, 20),
|
||||||
```kotlin
|
Point3D(40, 18, 20),
|
||||||
cone(60, 80, name = "cone") {
|
Point3D(40, 18, 10),
|
||||||
color("beige")
|
Point3D(30, 18, 10),
|
||||||
}
|
name = "classic hexagon"){
|
||||||
```
|
color("green")
|
||||||
![](../docs/images/cone-1.png)
|
}
|
||||||
![](../docs/images/cone-2.png)
|
```
|
||||||
|
![](../docs/images/classic-hexagon.png)
|
||||||
First of all, we have to try to build a frustum cone:
|
|
||||||
```kotlin
|
Now, let's make a custom hexagon.
|
||||||
cone(60, 80, name = "cone") {
|
|
||||||
color(0u, 40u, 0u)
|
```kotlin
|
||||||
}
|
hexagon(
|
||||||
```
|
Point3D(5, 30, 5),
|
||||||
![](../docs/images/frustum-cone.png)
|
Point3D(24, 30, 8),
|
||||||
|
Point3D(20, 30, -10),
|
||||||
Now, we need to make a try to build a cone segment:
|
Point3D(5, 30, -7),
|
||||||
|
Point3D(8, 16, 0),
|
||||||
```kotlin
|
Point3D(12, 16, 0),
|
||||||
cone(60, 80, angle = PI, name = "cone") {
|
Point3D(10, 16, -5),
|
||||||
color(0u, 0u, 200u)
|
Point3D(6.5, 12, -3),
|
||||||
}
|
name = "custom_hexagon"
|
||||||
```
|
) {
|
||||||
![](../docs/images/cone-segment-1.png)
|
color("brown")
|
||||||
![](../docs/images/cone-segment-2.png)
|
}
|
||||||
|
```
|
||||||
Finally, the segment of frustum cone is left for a try:
|
![](../docs/images/custom-hexagon.png)
|
||||||
```kotlin
|
### 3) Cone
|
||||||
cone(60, 100, 20, PI*3/4, angle = PI/3, name = "cone") {
|
It takes in six values: `bottomRadius`, `height`, `upperRadius`, `startAngle`, `angle`, and `name`.
|
||||||
color(190u, 0u, 0u)
|
|
||||||
}
|
Obviously, `bottomRadius` is responsible for the radius of a bottom base, and `height` sets the height of a cone along the `z-axis`.
|
||||||
```
|
|
||||||
![](../docs/images/frustum-cone-segment.png)
|
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.
|
||||||
|
|
||||||
### 4) Cone Surface
|
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`.
|
||||||
This solid is set by seven values:`bottomOuterRadius`, `bottomInnerRadius`, `height`, `topOuterRadius`, `topInnerRadius`, `startAngle`, and `angle`.
|
|
||||||
|
Let's build a classic cone:
|
||||||
In addition to `height`, `startAngle`, and `angle`, which work as they work in `cone`, there are some new values.
|
```kotlin
|
||||||
`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.
|
cone(60, 80, name = "cone") {
|
||||||
|
color("beige")
|
||||||
Generally, `cone`, and `coneSurface` buildings work in the same way, it's possible to make `coneSurface`'s fragments as in `cone`
|
}
|
||||||
|
```
|
||||||
Let's build usual cone surface with almost all properties set:
|
![](../docs/images/cone-1.png)
|
||||||
```kotlin
|
![](../docs/images/cone-2.png)
|
||||||
coneSurface(60, 50, 30, 10, 100, name = "cone surface") {
|
|
||||||
color("red")
|
First of all, we have to try to build a frustum cone:
|
||||||
rotation = Point3D(2, 50, -9)
|
```kotlin
|
||||||
}
|
cone(60, 80, name = "cone") {
|
||||||
```
|
color(0u, 40u, 0u)
|
||||||
![](../docs/images/cone-surface-1.png)
|
}
|
||||||
![](../docs/images/cone-surface-2.png)
|
```
|
||||||
|
![](../docs/images/frustum-cone.png)
|
||||||
Now, let's create a cone surface and set all it's properties:
|
|
||||||
|
Now, we need to make a try to build a cone segment:
|
||||||
```kotlin
|
|
||||||
coneSurface(30, 25, 10, 10, 8,0f, pi*3/4, name = "cone surface") {
|
```kotlin
|
||||||
color("fuchsia")
|
cone(60, 80, angle = PI, name = "cone") {
|
||||||
rotation = Point3D(2, 50, -9)
|
color(0u, 0u, 200u)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
![](../docs/images/cone-surface-fragment.png)
|
![](../docs/images/cone-segment-1.png)
|
||||||
![](../docs/images/cone-surface-fragment-2.png)
|
![](../docs/images/cone-segment-2.png)
|
||||||
|
|
||||||
### 5) Cylinder
|
Finally, the segment of frustum cone is left for a try:
|
||||||
|
```kotlin
|
||||||
This solid is set by `radius`, and `height`. As you can see by accepting values, there's no option of building fragments of cylinders.
|
cone(60, 100, 20, PI*3/4, angle = PI/3, name = "cone") {
|
||||||
|
color(190u, 0u, 0u)
|
||||||
Here's a demonstration of a cylinder:
|
}
|
||||||
|
```
|
||||||
```kotlin
|
![](../docs/images/frustum-cone-segment.png)
|
||||||
cylinder(40, 100, "cylinder"){
|
|
||||||
rotation = Point3D(40, 0, 0)
|
### 4) Cone Surface
|
||||||
color("indigo")
|
This solid is set by seven values:`bottomOuterRadius`, `bottomInnerRadius`, `height`, `topOuterRadius`, `topInnerRadius`, `startAngle`, and `angle`.
|
||||||
}
|
|
||||||
```
|
In addition to `height`, `startAngle`, and `angle`, which work as they work in `cone`, there are some new values.
|
||||||
![](../docs/images/cylinder-1.png)
|
`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.
|
||||||
![](../docs/images/cylinder-2.png)
|
|
||||||
### 6) Tube
|
Generally, `cone`, and `coneSurface` buildings work in the same way, it's possible to make `coneSurface`'s fragments as in `cone`
|
||||||
|
|
||||||
`tube` takes in `radius`, `height`, `innerRadius`, `startAngle`, `angle`, and `name`. *All values are familiar from `cone`, and `coneSurface` solids.*
|
Let's build usual cone surface with almost all properties set:
|
||||||
|
```kotlin
|
||||||
Here is an example of classic tube:
|
coneSurface(60, 50, 30, 10, 100, name = "cone surface") {
|
||||||
```kotlin
|
color("red")
|
||||||
tube(50, 40, 20, name = "usual tube"){
|
rotation = Point3D(2, 50, -9)
|
||||||
opacity = 0.4
|
}
|
||||||
}
|
```
|
||||||
```
|
![](../docs/images/cone-surface-1.png)
|
||||||
![](../docs/images/tube.png)
|
![](../docs/images/cone-surface-2.png)
|
||||||
|
|
||||||
This is an example of tube fragment:
|
Now, let's create a cone surface and set all it's properties:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
tube(50, 40, 20, 0f, PI, name = "fragmented tube"){
|
coneSurface(30, 25, 10, 10, 8,0f, pi*3/4, name = "cone surface") {
|
||||||
color("white")
|
color("fuchsia")
|
||||||
}
|
rotation = Point3D(2, 50, -9)
|
||||||
```
|
}
|
||||||
![](../docs/images/tube-fragment.png)
|
```
|
||||||
### 7) Extruded
|
![](../docs/images/cone-surface-fragment.png)
|
||||||
|
![](../docs/images/cone-surface-fragment-2.png)
|
||||||
|
|
||||||
|
### 5) Cylinder
|
||||||
|
|
||||||
|
This solid is set by `radius`, and `height`. As you can see by accepting values, there's no option of building fragments of cylinders.
|
||||||
|
|
||||||
|
Here's a demonstration of a cylinder:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
cylinder(40, 100, "cylinder"){
|
||||||
|
rotation = Point3D(40, 0, 0)
|
||||||
|
color("indigo")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
![](../docs/images/cylinder-1.png)
|
||||||
|
![](../docs/images/cylinder-2.png)
|
||||||
|
### 6) Tube
|
||||||
|
|
||||||
|
`tube` takes in `radius`, `height`, `innerRadius`, `startAngle`, `angle`, and `name`. *All values are familiar from `cone`, and `coneSurface` solids.*
|
||||||
|
|
||||||
|
Here is an example of classic tube:
|
||||||
|
```kotlin
|
||||||
|
tube(50, 40, 20, name = "usual tube"){
|
||||||
|
opacity = 0.4
|
||||||
|
}
|
||||||
|
```
|
||||||
|
![](../docs/images/tube.png)
|
||||||
|
|
||||||
|
This is an example of tube fragment:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
tube(50, 40, 20, 0f, PI, name = "fragmented tube"){
|
||||||
|
color("white")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
![](../docs/images/tube-fragment.png)
|
||||||
|
### 7) Extruded
|
||||||
|
|
||||||
|
`extruded` is set by two values: `shape`, and `layer`.
|
||||||
|
* `shape` is a value of `List<Point2D>` type. It's just a list of all points of the solid. *`shape` has to consist of not less than two points!*
|
||||||
|
* `layer` is `MutableList` types variable. (here is a sentence with a description of the work of this function). *The amount of `layer`-s has to be more than one*
|
||||||
|
@ -248,7 +248,7 @@ private class GdmlTransformerEnv(val settings: GdmlTransformer) {
|
|||||||
name = name
|
name = name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is GdmlXtru -> extrude(name) {
|
is GdmlXtru -> extruded(name) {
|
||||||
shape {
|
shape {
|
||||||
solid.vertices.forEach {
|
solid.vertices.forEach {
|
||||||
point(it.x * lScale, it.y * lScale)
|
point(it.x * lScale, it.y * lScale)
|
||||||
@ -284,7 +284,7 @@ private class GdmlTransformerEnv(val settings: GdmlTransformer) {
|
|||||||
name = name,
|
name = name,
|
||||||
)
|
)
|
||||||
is GdmlOrb -> sphere(solid.r * lScale, name = name)
|
is GdmlOrb -> sphere(solid.r * lScale, name = name)
|
||||||
is GdmlPolyhedra -> extrude(name) {
|
is GdmlPolyhedra -> extruded(name) {
|
||||||
//getting the radius of first
|
//getting the radius of first
|
||||||
require(solid.planes.size > 1) { "The polyhedron geometry requires at least two planes" }
|
require(solid.planes.size > 1) { "The polyhedron geometry requires at least two planes" }
|
||||||
val baseRadius = solid.planes.first().rmax * lScale
|
val baseRadius = solid.planes.first().rmax * lScale
|
||||||
|
@ -94,7 +94,9 @@ public class Extruded(
|
|||||||
|
|
||||||
public class ExtrudeBuilder(
|
public class ExtrudeBuilder(
|
||||||
public var shape: List<Point2D> = emptyList(),
|
public var shape: List<Point2D> = emptyList(),
|
||||||
public var layers: ArrayList<Layer> = ArrayList(),
|
|
||||||
|
public var layers: MutableList<Layer> = ArrayList(),
|
||||||
|
|
||||||
config: Config = Config()
|
config: Config = Config()
|
||||||
) : SimpleVisionPropertyContainer<Extruded>(config) {
|
) : SimpleVisionPropertyContainer<Extruded>(config) {
|
||||||
public fun shape(block: Shape2DBuilder.() -> Unit) {
|
public fun shape(block: Shape2DBuilder.() -> Unit) {
|
||||||
@ -109,7 +111,7 @@ public class ExtrudeBuilder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisionBuilder
|
@VisionBuilder
|
||||||
public fun VisionContainerBuilder<Solid>.extrude(
|
public fun VisionContainerBuilder<Solid>.extruded(
|
||||||
name: String? = null,
|
name: String? = null,
|
||||||
action: ExtrudeBuilder.() -> Unit = {}
|
action: ExtrudeBuilder.() -> Unit = {}
|
||||||
): Extruded = ExtrudeBuilder().apply(action).build().also { set(name, it) }
|
): Extruded = ExtrudeBuilder().apply(action).build().also { set(name, it) }
|
Loading…
Reference in New Issue
Block a user