Skip to content

Instantly share code, notes, and snippets.

@Timoteohss
Created December 13, 2017 21:02
Show Gist options
  • Save Timoteohss/e6c60a1efef867c6e9d22a3e6aec79a9 to your computer and use it in GitHub Desktop.
Save Timoteohss/e6c60a1efef867c6e9d22a3e6aec79a9 to your computer and use it in GitHub Desktop.
Trabalho de fisica
import math
import cv2
import sys
import numpy as np
imfinal = np.zeros([720,1080,1],dtype=np.uint8)
theta = int(sys.argv[1])
vo = float(sys.argv[2])
voy = vo * np.sin(np.deg2rad(theta))
vox = vo * np.cos(np.deg2rad(theta))
g = 9.81;
tempVoo = (2 * vo / g) * np.sin(np.deg2rad(theta))
alcance = (vo * vo / g) * (np.sin(np.deg2rad(2*theta)))
altura = ( (vo * vo) / (2*g) ) * (math.sin(np.deg2rad(theta)) * math.sin(np.deg2rad(theta)))
escalaVertical = altura / 719
escalaHorizontal = alcance / 1079
escalaFinal = max(escalaVertical, escalaHorizontal)
tempo = int(sys.argv[3])
t = 0
while(t <= tempo):
x = vox * t
y = (np.sin(np.deg2rad(theta)) / np.cos(np.deg2rad(theta))) * x - (g * (x*x)) / (2 * vo * vo * np.cos(np.deg2rad(theta)) * np.cos(np.deg2rad(theta)) )
pixelX = int(x/escalaFinal)
pixelY = 719 - int(y/escalaFinal)
if(pixelX > 1079 or pixelY < 0 or pixelY > 719 or pixelX < 0 ):
break
imfinal[pixelY,pixelX] = 255
print("Pixel X: ", pixelX," Pixel Y: ",pixelY ," tempo: ",t)
cv2.imshow('kek',imfinal)
cv2.waitKey(0)
t += 1/30
cv2.imshow('kek',imfinal)
cv2.waitKey(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment