From 04b4a129461f54476530c4b5d8ffb20a2495b49c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 22 Jun 2023 08:32:52 +0300 Subject: [PATCH] antenna example --- demo/playground/src/jvmMain/kotlin/antenna.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/demo/playground/src/jvmMain/kotlin/antenna.kt b/demo/playground/src/jvmMain/kotlin/antenna.kt index 5b92f46f..cd711d11 100644 --- a/demo/playground/src/jvmMain/kotlin/antenna.kt +++ b/demo/playground/src/jvmMain/kotlin/antenna.kt @@ -1,16 +1,27 @@ package space.kscience.visionforge.examples import space.kscience.kmath.complex.Quaternion -import space.kscience.kmath.geometry.RotationOrder +import space.kscience.kmath.complex.QuaternionField +import space.kscience.kmath.geometry.Angle +import space.kscience.kmath.geometry.Euclidean3DSpace import space.kscience.kmath.geometry.degrees -import space.kscience.kmath.geometry.fromEuler +import space.kscience.kmath.geometry.fromRotation import space.kscience.visionforge.html.ResourceLocation import space.kscience.visionforge.solid.* import kotlin.math.PI fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { - val direction = Quaternion.fromEuler( 45.degrees, 45.degrees, 0.degrees, RotationOrder.XYZ) + val azimuth = 60.degrees + val inclination = 15.degrees + + val direction = with(QuaternionField) { + Quaternion.fromRotation(-azimuth, Euclidean3DSpace.zAxis) * + Quaternion.fromRotation(Angle.piDiv2 - inclination, Euclidean3DSpace.yAxis) + } + + //val direction2 = Quaternion.fromEuler(Angle.zero, Angle.piDiv2 - inclination, -azimuth, RotationOrder.ZYX) + vision("canvas") { requirePlugin(Solids) @@ -21,9 +32,6 @@ fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { ambientLight() cylinder(50, 5, name = "base") solidGroup("frame") { - rotationY = PI/2 - rotationX = -PI/2 - rotationZ = -PI/2 z = 60 axes(200) solidGroup("antenna") { @@ -35,7 +43,7 @@ fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) { cylinder(5, 30) { z = 15 } - this.quaternion = direction + quaternion = direction } } }