Add dynamic rotation example
This commit is contained in:
parent
07b54fde51
commit
f2d7e20fd3
@ -4,6 +4,8 @@ import kotlinx.coroutines.*
|
||||
import space.kscience.dataforge.meta.Meta
|
||||
import space.kscience.dataforge.meta.invoke
|
||||
import space.kscience.dataforge.names.Name
|
||||
import space.kscience.kmath.geometry.Euclidean3DSpace
|
||||
import space.kscience.kmath.geometry.radians
|
||||
import space.kscience.visionforge.Colors
|
||||
import space.kscience.visionforge.solid.*
|
||||
import space.kscience.visionforge.solid.specifications.Canvas3DOptions
|
||||
@ -103,8 +105,15 @@ fun VisionLayout<Solid>.showcase() {
|
||||
solidGroup {
|
||||
x = 200
|
||||
rotationY = PI / 4
|
||||
axes(200)
|
||||
box(100, 100, 100) {
|
||||
rotationZ = PI / 4
|
||||
rotate((PI / 4).radians, Euclidean3DSpace.zAxis)
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
while (isActive) {
|
||||
delay(100)
|
||||
rotate((PI/20).radians,Euclidean3DSpace.yAxis)
|
||||
}
|
||||
}
|
||||
color.set(Colors.red)
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import space.kscience.dataforge.names.Name
|
||||
import space.kscience.dataforge.names.asName
|
||||
import space.kscience.dataforge.names.plus
|
||||
import space.kscience.kmath.complex.Quaternion
|
||||
import space.kscience.kmath.complex.QuaternionField
|
||||
import space.kscience.kmath.geometry.*
|
||||
import space.kscience.visionforge.*
|
||||
import space.kscience.visionforge.Vision.Companion.VISIBLE_KEY
|
||||
@ -245,6 +246,6 @@ public var Solid.scaleZ: Number by float(Z_SCALE_KEY, 1f)
|
||||
/**
|
||||
* Add rotation with given [angle] relative to given [axis]
|
||||
*/
|
||||
public fun Solid.rotate(angle: Angle, axis: DoubleVector3D) {
|
||||
quaternion = Quaternion.fromRotation(angle, axis)
|
||||
public fun Solid.rotate(angle: Angle, axis: DoubleVector3D) = with(QuaternionField) {
|
||||
quaternion = Quaternion.fromRotation(angle, axis)*quaternion
|
||||
}
|
Loading…
Reference in New Issue
Block a user