Created
June 15, 2016 13:08
-
-
Save schneiderfelipe/660097a5c16d6edd866dc080682f16df to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
import numpy as np | |
from scipy.linalg import norm | |
def read_vector(nome): | |
p = np.zeros(3) | |
for i in range(3): | |
p[i] = float(raw_input("%s_%d = " % (nome, i))) | |
return p | |
print "Lendo centroides..." | |
p = read_vector("P") | |
q = read_vector("Q") | |
print "Lendo 3 carbonos do anel de baixo..." | |
c = read_vector("C") | |
d = read_vector("D") | |
e = read_vector("E") | |
print "Vetores lidos..." | |
print "P = ", p | |
print "Q = ", q | |
print "C = ", c | |
print "D = ", d | |
print "E = ", e | |
print "Calculando..." | |
pq = p - q # entre centroides | |
v1 = c - d # d carbono central | |
v2 = e - d | |
pren = np.cross(v1, v2) | |
n = pren/norm(pren) # normal | |
pq_norm = norm(pq) # norma de PQ | |
pq_n = np.inner(pq, n) # proj. de PQ na normal | |
w = np.sqrt(pq_norm**2 - pq_n**2) | |
print "Resultados parciais..." | |
print "PQ = ", pq | |
print "||PQ|| = ", pq_norm | |
print "v1 = ", v1 | |
print "v2 = ", v2 | |
print "n = ", n | |
print "PQ.n = ", pq_n | |
print "Resultado final..." | |
print "w = ", w |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment