This example demonstrates a ball bouncing on a slanted surface, implemented using vector calculations for reflection.
The code makes extensive use of the p5.Vector class, including the createVector() function to create new vectors, and the vector methods add() and dot() for the vector calculations.
Related Examples
![](/_astro/15_Math_And_Physics-00_Non_Orthogonal_Reflection-thumbnail.DeYbXLbr_Z2sprbi.webp)
No alt text
Non-Orthogonal Reflection
Simulate a ball bouncing on a slanted surface.
![](/_astro/15_Math_And_Physics-01_Soft_Body-thumbnail.CaUlsLEf_Z2t2M4j.webp)
No alt text
Soft Body
Simulate the physics of a soft body accelerating toward the mouse.
![](/_astro/15_Math_And_Physics-02_Forces-thumbnail.76GklzEL_HHQbe.webp)
No alt text
Forces
Simulate forces on multiple bodies as they move through liquid.
![](/_astro/15_Math_And_Physics-03_Smoke_Particle_System-thumbnail.DKQ430DH_2kCjh8.webp)
No alt text
Smoke Particles
Simulate smoke with a particle system.
![](/_astro/15_Math_And_Physics-04_Game_Of_Life-thumbnail.5UrIGGfY_1qP5lX.webp)
No alt text
Game of Life
Recreate John Conway's cellular automaton.
![](/_astro/15_Math_And_Physics-05_Mandelbrot-thumbnail.DrMp2tOi_Z2016jT.webp)
No alt text
Mandelbrot Set
Visualize a mathematical set that produces fractal structures.