Created
December 13, 2017 21:03
-
-
Save Timoteohss/14219049b05e5cd1e7f7ed1eb9bc39dc to your computer and use it in GitHub Desktop.
Trabalho de fisica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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