Posted: Mon Jun 21, 2004 5:39 pm Post subject: (No subject)
Person who won math award for the grade: 126% did NOT know that was possible.
Sponsor Sponsor
Cervantes
Posted: Mon Jun 21, 2004 7:40 pm Post subject: (No subject)
wow. that's a lot. what was his mark multiplied by to get there?!
this is getting a bit offtopic, so ill bring it back. Cervantes to the rescue.
using trig, how would you go about creating a program that has a ball sitting on a ramp and, when pressing the arrow keys, the ramp angles itself up or down. then, depending on how the ramp is angled, the ball rolls down it at the proper speed, according to the laws of physics.
in case anyone didn't understand my blurb, it should look something like this:
Tony
Posted: Mon Jun 21, 2004 8:01 pm Post subject: (No subject)
i hope this helps
figure out Fx and Fy... and that's what you apply to the ball
Posted: Tue Jun 22, 2004 7:48 am Post subject: (No subject)
oops, I probably should have mentioned that I've already done this, and am asking how you guys would do it.
I sort of cheated. In my program the ball doesn't roll down the slope so much as makes tiny bounces all the way down it.
tony, the green line in your drawing, is that the path of the ball if it were not to hit the slope? sorry I don't really understand your drawing
zylum
Posted: Tue Jun 22, 2004 1:58 pm Post subject: (No subject)
the normal (the green line) is just a perpindicular line to the slope
Tony
Posted: Tue Jun 22, 2004 5:06 pm Post subject: (No subject)
normal force is the force that the slope applies to the ball.
Fx is the force which pushes the ball to the side
Fy is the force with which the ball is being pushed vertically up. But when added with the Fg (gravity), then theoretically the ball should be kept rolling on the slope
Posted: Tue Jun 22, 2004 6:02 pm Post subject: (No subject)
I tried to put an example together, are these the right mathematics?
code:
setscreen ("graphics:400,400;offscreenonly")
var mx, my, mb : int
var pointx, pointy : array 1 .. 2 of int
var clicked : int
var x, y, vx, vy, grav : real := 0
var collision : boolean := false
var m, b : real
x := 200
y := 120
grav := 0.001
pointx (1) := 0
pointy (1) := 100
pointx (2) := 400
pointy (2) := 100
loop
cls
mousewhere (mx, my, mb)
drawline (pointx (1), pointy (1), pointx (2), pointy (2), 7)
drawoval (pointx (1), pointy (1), 5, 5, 7)
drawoval (pointx (2), pointy (2), 5, 5, 7)
drawfilloval (round (x), round (y), 10, 10, 4)
if round (Math.Distance (pointx (1), pointy (1), mx, my)) <= 25 and mb = 1 then
clicked := 1
elsif round (Math.Distance (pointx (2), pointy (2), mx, my)) <= 25 and mb = 1 then
clicked := 2
else
clicked := 0
end if
if clicked ~= 0 then
pointx (clicked) := mx
pointy (clicked) := my
end if
y -= vy
vy += grav
m := (pointy (1) - pointy (2)) / (pointx (1) - pointx (2))
b := pointy (1) - m * pointx (1)
if collision then
x -= m
vy := 0
y := m * x + b
end if
if round (y) = m * x + b then
collision := true
end if
View.Update
exit when hasch
end loop
zylum
Posted: Wed Jun 23, 2004 10:09 am Post subject: (No subject)
i dont think those are the correct physics... for one thing, i dont see any friction in your code so therefore the ball should constantly be accelerating down the slope. if there were friction there would be a terminal velocity where the ball could no longer accelerate because of friction. another thing is that the ball has no inertia. so when the ball is moving quickly to the left and then you level the surface, it should keep moving in that direction.