A demo of first physics "simulation" visualization...
# science
a
A demo of first physics "simulation" visualization in VisionForge: https://www.loom.com/share/fde7375039ba4cb9889f7f31bbdca159 Here is the whole code:
Copy code
val bouncingSphere = SolidGroup {
            sphere(5.0, "ball") {
                detail = 16
                color("red")
                val h = 100.0
                y = h
                GlobalScope.launch {
                    val g = 10.0
                    val dt = 0.1
                    var time = 0.0
                    var velocity = 0.0
                    while (isActive) {
                        delay(20)
                        time += dt
                        velocity -= g * dt
                        y = y.toDouble() + velocity * dt
                        if (y.toDouble() <= 2.5){
                            velocity = sqrt(2*g*h)
                        }
                    }
                }
            }

            box(200, 5, 200, name = "floor"){
                y = -2.5
            }
        }