Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 cos and sin
Index -> General Programming
Goto page Previous  1, 2, 3
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Paul




PostPosted: Mon Jun 21, 2004 5:39 pm   Post subject: (No subject)

Person who won math award for the grade: 126% Shocked did NOT know that was possible.
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Mon Jun 21, 2004 7:40 pm   Post subject: (No subject)

wow. that's a lot. Confused what was his mark multiplied by to get there?!

this is getting a bit offtopic, so ill bring it back. Smile 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:
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Tony




PostPosted: 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 Image, might have been reduced in size. Click Image to view fullscreen.



slope.gif
 Description:
 Filesize:  2.38 KB
 Viewed:  1955 Time(s)

slope.gif


Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Cervantes




PostPosted: 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 Confused
zylum




PostPosted: 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




PostPosted: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
GlobeTrotter




PostPosted: 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




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 3 of 3  [ 38 Posts ]
Goto page Previous  1, 2, 3
Jump to:   


Style:  
Search: