Fix polygon builders
This commit is contained in:
parent
1e29c5dbaa
commit
3529d0efc6
@ -209,9 +209,9 @@ private fun SolidGroup.addShape(
|
|||||||
require(fNz > 1) { "The polyhedron geometry requires at least two planes" }
|
require(fNz > 1) { "The polyhedron geometry requires at least two planes" }
|
||||||
val baseRadius = fRmax[0]
|
val baseRadius = fRmax[0]
|
||||||
shape {
|
shape {
|
||||||
(0..fNedges).forEach {
|
(0..<fNedges).forEach {
|
||||||
val phi = deltaphi * fNedges * it + startphi
|
val phi = deltaphi / fNedges * it + startphi
|
||||||
(baseRadius * cos(phi) to baseRadius * sin(phi))
|
point(baseRadius * cos(phi), baseRadius * sin(phi))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(0 until fNz).forEach { index ->
|
(0 until fNz).forEach { index ->
|
||||||
|
21
demo/playground/src/jvmMain/kotlin/extruded.kt
Normal file
21
demo/playground/src/jvmMain/kotlin/extruded.kt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package space.kscience.visionforge.examples
|
||||||
|
|
||||||
|
import space.kscience.visionforge.solid.ambientLight
|
||||||
|
import space.kscience.visionforge.solid.extruded
|
||||||
|
import space.kscience.visionforge.solid.polygon
|
||||||
|
import space.kscience.visionforge.solid.solid
|
||||||
|
|
||||||
|
fun main() = makeVisionFile {
|
||||||
|
vision("canvas") {
|
||||||
|
solid {
|
||||||
|
ambientLight()
|
||||||
|
extruded("extruded") {
|
||||||
|
shape{
|
||||||
|
polygon(8, 100)
|
||||||
|
layer(-30)
|
||||||
|
layer(30)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -46,7 +46,7 @@ fun main() {
|
|||||||
ambientLight {
|
ambientLight {
|
||||||
color(Colors.white)
|
color(Colors.white)
|
||||||
}
|
}
|
||||||
rootGeo(geo,"BM@N", maxLayer = 3, ignoreRootColors = true).also {
|
rootGeo(geo,"BM@N", ignoreRootColors = true).also {
|
||||||
Path("data/BM@N.vf.json").writeText(Solids.encodeToString(it))
|
Path("data/BM@N.vf.json").writeText(Solids.encodeToString(it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont
|
|||||||
|
|
||||||
public val jsonFormat: Json
|
public val jsonFormat: Json
|
||||||
get() = Json(defaultJson) {
|
get() = Json(defaultJson) {
|
||||||
encodeDefaults = false
|
|
||||||
serializersModule = this@VisionManager.serializersModule
|
serializersModule = this@VisionManager.serializersModule
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +84,6 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont
|
|||||||
serializersModule = defaultSerialModule
|
serializersModule = defaultSerialModule
|
||||||
prettyPrint = true
|
prettyPrint = true
|
||||||
useArrayPolymorphism = false
|
useArrayPolymorphism = false
|
||||||
encodeDefaults = false
|
|
||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
explicitNulls = false
|
explicitNulls = false
|
||||||
}
|
}
|
||||||
|
@ -207,9 +207,9 @@ private class GdmlLoader(val settings: GdmlLoaderOptions) {
|
|||||||
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
|
||||||
shape {
|
shape {
|
||||||
(0..solid.numsides).forEach {
|
(0..<solid.numsides).forEach {
|
||||||
val phi = solid.deltaphi * aScale / solid.numsides * it + solid.startphi * aScale
|
val phi = solid.deltaphi * aScale / solid.numsides * it + solid.startphi * aScale
|
||||||
(baseRadius * cos(phi) to baseRadius * sin(phi))
|
point(baseRadius * cos(phi), baseRadius * sin(phi))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
solid.planes.forEach { plane ->
|
solid.planes.forEach { plane ->
|
||||||
|
@ -23,8 +23,6 @@ public class Shape2DBuilder(private val points: ArrayList<Float32Vector2D> = Arr
|
|||||||
points.add(Float32Vector2D(x, y))
|
points.add(Float32Vector2D(x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
public infix fun Number.to(y: Number): Unit = point(this, y)
|
|
||||||
|
|
||||||
public fun build(): Shape2D = points
|
public fun build(): Shape2D = points
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user