-
Notifications
You must be signed in to change notification settings - Fork 2
/
Curvas3.py
106 lines (89 loc) · 4.29 KB
/
Curvas3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
from superficie.book import Page, Chapter
from math import pi, sin, cos, tan
from superficie.util import Vec3, _1, partial
from superficie.nodes import Curve3D, TangentPlane2, SimpleSphere, Plane
from superficie.animations import AnimationGroup, Animation, Animatable
from PyQt4 import QtGui
from superficie.plots import ParametricPlot3D
from pivy.coin import SoTransparencyType
from superficie.widgets import VisibleCheckBox
class HeliceRectificada(Page):
u"""
Esta interacción muestra el <b>triedro de Frenet-Serret</b> en cada
punto <b>p</b> de una hélice. El plano de los vectores tangente y
normal se llama <b>plano tangente</b>, el que contiene al normal y
el binormal se llama <b>plano normal</b>, y al que contiene los
vectores binormal y tangente se llama <b>plano rectificante</b>
porque deja una pequeña porción de la curva que contenga a <b>p</b>
en uno solo de sus lados. Las proyecciones de esa pequeña porción de
la hélice en esos planos que inciden en <b>p</b> son análogas a las de
la cúbica alabeada.
"""
#"""La curvatura de una curva $alpha$ parametrizada por longitud de arco en el punto
# $alpha (s)$ (la norma de $alpha’ (s)= ^t(s)$ es $1$) mide la rapidez con que la curva se
# aleja de su recta tangente, y la torsión en el punto $alpha (s)$ mide la rapidez con que
# la curva se aleja de su plano osculador."""
def __init__(self):
Page.__init__(self, u"Planos osculador, normal y rectificante")
tmin = -2 * pi
tmax = 2 * pi
## ============================================
sq2 = 2 ** 0.5
inv_sq2 = (1. / sq2)
def helix(s):
s_times_sq2 = inv_sq2 * s
return Vec3(cos(s_times_sq2), sin(s_times_sq2), s_times_sq2)
def tangent(s):
s_div_sq2 = s / sq2
return Vec3(-inv_sq2 * sin(s_div_sq2), inv_sq2 * cos(s_div_sq2), inv_sq2)
def normal(s):
s_div_sq2 = s / sq2
return Vec3(-cos(s_div_sq2), -sin(s_div_sq2), 0)
def bi_normal(s):
s_div_sq2 = s / sq2
return Vec3(inv_sq2 * sin(s_div_sq2), -inv_sq2 * cos(s_div_sq2), inv_sq2)
curve = Curve3D(helix, (tmin, tmax, 100), _1(206, 75, 150), 2)
self.addChild(curve)
#=======================================================================
# Vectors
#=======================================================================
field_tangent = curve.attachField("tangent", tangent).show()
field_normal = curve.attachField("normal", normal).show()
field_binormal = curve.attachField("binormal", bi_normal).show()
#=======================================================================
# Planes
#=======================================================================
def get_points(v1, v2): return v2.p1, v1.p2, v2.p2
color = (.5, .5, .5)
plane_osculating = Plane(color, *get_points(field_tangent, field_normal))
plane_normal = Plane(color, *get_points(field_normal, field_binormal))
plane_rectifying = Plane(color, *get_points(field_binormal, field_tangent))
self.addChildren([plane_osculating, plane_normal, plane_rectifying])
def update_planes(n):
plane_osculating.setPoints(*get_points(field_tangent, field_normal))
plane_normal.setPoints(*get_points(field_normal, field_binormal))
plane_rectifying.setPoints(*get_points(field_binormal, field_tangent))
r = (5000, 0, len(curve) - 1)
animation = Animatable(update_planes, r)
self.setupAnimations([
AnimationGroup([field_tangent, field_normal, field_binormal, animation], r)
])
class Curvas3(Chapter):
def __init__(self):
Chapter.__init__(self, name="Planos osculador, normal, rectificante")
figuras = [HeliceRectificada]
for f in figuras:
self.addPage(f())
if __name__ == "__main__":
import sys
from superficie.viewer.Viewer import Viewer
app = QtGui.QApplication(sys.argv)
visor = Viewer()
visor.book.addChapter(Curvas3())
visor.chapter.chapterSpecificIn()
visor.whichPage = 0
visor.resize(400, 400)
visor.show()
visor.chaptersStack.show()
sys.exit(app.exec_())