Simulated Slide – Write a program to simulate the slide of a block down an inclined plane, given an input angle and coefficient of kinetic friction between the block and the inclined plane. Show a sample calculation to demonstrate that the program output is what you would expect. Include a free-body diagram. Assessment criteria:
- Code is clear with comments and appropriate variable names
- Code can accept different inputs for the angle and coefficient
- Output simulation is clear and correct
- Calculations to verify the accuracy of the output are correct
- Free-body diagram is clear and correct
Motion:
- Total time to reach the end of the plane
- Acceleration
- Final velocity
Forces:
- Force of gravity in the x
- Force of gravity in the y
- Normal Force
- Force of kinetic friction
- Net force
The program has two non-graphics files which are used by all other files:
- GlobalVars.kt, which contains all variables used across the program
- Calculations.kt, which performs all calculations, given the inputs from the user
The program starts in App.kt, which lays out the ui, and calls functions in other files for each part, including:
- Inputs.kt, which provides the sliders and text inputs for the angle, coefficient of friction, the button for mass/length, mass, and length. It makes Calculations.kt recalculate everything each time an input is changed
- FreeBodyDiagram.kt, which draws the FBD. It displays different parts of the FBD based on the math (ex. Fk vs Fs)
- DisplaysOutputs.kt, which tells the user the outputs of the program, as calculated in Calculations.kt
- InclinePlane.kt, which displays the incline plane and box, and animates it moving with the time and acceleration values to find displacement throughout the animation. The animation restarts with the new value whenever sliding time changes
To build and run the development version of the desktop app, use the run configuration from the run widget in your IDE’s toolbar or run it directly from the terminal:
./gradlew :composeApp:runTo build and run the development version of the web app, use the run configuration from the run widget in your IDE's toolbar or run it directly from the terminal:
-
for the Wasm target (faster, modern browsers):
./gradlew :composeApp:wasmJsBrowserDevelopmentRun
-
for the JS target (slower, supports older browsers):
./gradlew :composeApp:jsBrowserDevelopmentRun