Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sympy import *
- import numpy as np
- import math
- def det(l):
- return (l[0][0]*l[1][1]-l[0][1]*l[1][0])
- def solve(a,b):
- if det(a) == 0:
- print("\nSistema sem solução.\n\n")
- else:
- return [det([[b[0],a[0][1]],[b[1],a[1][1]]])/det(a),det([[a[0][0],b[0]],[a[1][0],b[1]]])/det(a)]
- x, y, z, t, r = symbols('x y z t r', real=True)
- def first_form_para(func):
- Fx=[]
- Fy=[]
- for k in range(3):
- Fx.append(diff(func[k],x))
- Fy.append(diff(func[k],y))
- E = simplify(np.dot(Fx,Fx))
- F = simplify(np.dot(Fx,Fy))
- G = simplify(np.dot(Fy,Fy))
- return (E,F,G)
- def christopher_symbols_para(func):
- E = first_form_para(func)[0]
- F = first_form_para(func)[1]
- G = first_form_para(func)[2]
- M = [[E,F],[F,G]]
- i = [[simplify(diff(E,x)/2),simplify(diff(F,x)-diff(E,y)/2)],
- [simplify(diff(E,y)/2),simplify(diff(G,x)/2)],
- [simplify(diff(F,y)-diff(G,x)/2),simplify(diff(G,y)/2)]]
- cs = []
- for k in range(3):
- cs.append(simplify(solve(M,i[k])))
- return cs
- def curvature_para(func):
- cs = christopher_symbols_para(func)
- K = simplify((diff(cs[1][1],x)-diff(cs[0][1],y)+cs[1][0]*cs[0][1]+cs[1][1]**2-cs[0][1]*cs[2][1]-cs[0][0]*cs[1][1])/-E)
- return K
- def first_form(func):
- E = simplify(np.dot(diff(func,x),diff(func,x)))
- F = simplify(np.dot(diff(func,x),diff(func,y)))
- G = simplify(np.dot(diff(func,y),diff(func,y)))
- return (E, F, G)
- f = (sin(x)*cos(y),sin(x)*sin(y),cos(x)) # Esfera
- print(first_form_para(f))
- # print(christopher_symbols_para(f))
- g = (y*cos(x),y*sin(x),t*x) # Helicóide
- print(first_form_para(g))
- # print(christopher_symbols_para(g))
- h = ((t+r*cos(x))*cos(y),(t+r*cos(x))*sin(y),r*sin(x)) #
- print(first_form_para(h))
- # print(christopher_symbols_para(h))
- # i = ((2-y*sin(x/2))*sin(x), (2-y*sin(x/2)*cos(x)), cos(x/2)) # Möbius
- # print(first_form_para(i))
- # print(christopher_symbols_para(i))
- j = (x,y,x*y)
- print(first_form_para(j))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement