Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- g = 9.82
- p0 = 0
- posy = 0
- posx = 0
- rposy = 0
- rposx = 0
- vvekx = 0
- vveky = 0
- p0[1] = readline("x0")
- p0[2] = readline("y0")
- vinkel = readline("vinkel")
- v0 = readline("kastehastighed")
- p0 = as.double(p0)
- vinkel = as.double(vinkel)
- v0 = as.double(v0)
- vinkel = pi/180*vinkel
- vx = cos(vinkel)
- vy = sin(vinkel)
- thyme = seq(0, 200, 0.1)
- for(i in 1:length(thyme)){
- posy[i] = (p0[2]+vy*thyme[i]*v0-1/2*g*thyme[i]^2)
- posx[i] = (p0[1]+vx*thyme[i]*v0)
- vvekx[i] = vx*v0
- vveky[i] = (vy*v0-g*thyme[i])
- }
- for(o in 1:1000){
- if(posy[o] < 0){
- break()
- }else{
- rposx[o] = posx[o]
- rposy[o] = posy[o]
- }
- }
- cho = readline("1:animation, 2:graf")
- if(cho =="2"){
- for(r in 1:length(rposy)){
- plot(rposx,rposy,xlab="længde", ylab="højde", col="red")
- arrows(rposx[r], rposy[r], rposx[r]+vvekx[r], vveky[r]+rposy[r], length = 0.5, col="green")
- arrows(rposx[r]-2, rposy[r], rposx[r]+2, rposy[r], length = 0.001, col = "blue")
- arrows(rposx[r], rposy[r]-2, rposx[r], 2+rposy[r], length = 0.001, col = "blue")
- print(vveky[r])
- Sys.sleep(0.5)
- }
- }else{
- for(u in 1:length(rposy)){
- anix = c(0, rposx[u], rposx[length(rposx)])
- aniy = c(0, rposy[u], 20)
- plot(anix,aniy,xlab="længde", ylab="højde", col="red")
- Sys.sleep(0.1)
- print("Padoru Padoru")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement