Skip to content

Instantly share code, notes, and snippets.

@schneiderfelipe
Created June 15, 2016 13:08
Show Gist options
  • Save schneiderfelipe/660097a5c16d6edd866dc080682f16df to your computer and use it in GitHub Desktop.
Save schneiderfelipe/660097a5c16d6edd866dc080682f16df to your computer and use it in GitHub Desktop.
#!/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")
print
q = read_vector("Q")
print
print "Lendo 3 carbonos do anel de baixo..."
c = read_vector("C")
print
d = read_vector("D")
print
e = read_vector("E")
print
print "Vetores lidos..."
print "P = ", p
print "Q = ", q
print "C = ", c
print "D = ", d
print "E = ", e
print
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
print "Resultados parciais..."
print "PQ = ", pq
print "||PQ|| = ", pq_norm
print
print "v1 = ", v1
print "v2 = ", v2
print
print "n = ", n
print "PQ.n = ", pq_n
print
print "Resultado final..."
print "w = ", w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment