Esempio n. 1
0
    def __init__(self):
        super(Mobius,
              self).__init__(u"No orientabilidad de la Banda de Möbius")

        #        self.camera_position = (3.0, 2.8, 2.8)

        def par(u, v):
            return cos(u) + v * cos(u / 2) * cos(u), sin(u) + v * cos(
                u / 2) * sin(u), v * sin(u / 2)

        mobius = ParametricPlot3D(par, (-pi, pi, 60), (-.5, .5, 14))
        mobius.setTransparency(0.5)

        def curva(t):
            return par(t, 0)

        def puntos(u):
            return Vec3(
                cos(u) * sin(u / 2.0),
                sin(u / 2.0) * sin(u), -cos(u / 2.0))

        cm = Curve3D(curva, (-pi, pi, 200), color=_1(255, 255, 255), width=3)
        aceleracion_cm = cm.attachField(
            "aceleracion", puntos).setLengthFactor(1).setWidthFactor(.5)
        aceleracion_cm.animation.setDuration(12000)

        self.addChild(mobius)
        self.addChild(cm)
        self.addChild(Arrow((-1, 0, 0), (0, 0, 0), 0.02))

        self.setupAnimations([aceleracion_cm])
Esempio n. 2
0
    def __init__(self):
        super(Toro3,self).__init__(u'Secciones normales de un toro en un punto hiperbólico')

        self.showAxis(False)

        torus = createTorus(r1, r2)
        self.addChild(torus)

        normal = Arrow((r1-r2,0,0), (r1-r2-1,0,0), 0.03)
        normal.setDiffuseColor(_1(240,10,200))
        self.addChild(normal)

        class TorusCurve(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                cosp = cos(param1)
                sinp = sin(param1)
                v = s
                btor = 2.0*v**2 - 20.0
                ctor = v**4 + (16.0 - 36.0*sinp**2)*v**2 + 64.0
                dis = btor**2 - 4.0*ctor
                if dis < 0.0:
                    #v = 0.0
                    u = 4.0
                else:
                    inside = -btor-sqrt(dis)
                    if inside < 0.0:
                        #v = 0.0
                        u = 4.0
                    else:
                        u = sqrt( inside/2.0 )
                return Vec3(u, sinp*v, -cosp*v)

            def setParam(self, t):
                self.param = t

        torusc_obj = TorusCurve()
        curve = Curve3DParam(torusc_obj, (-2.0, 2.0, 200), color=(0.9, 0.2, 0.1), width=6)
        curve.setBoundingBox((-0.05,2.95),(-4.1,4.1),(-1.1,1.1))

        normal_plane_function = lambda u, v: (u, sin(pi_2*tt3)*v, -cos(pi_2*tt3)*v)
        normal_plane_function.func_globals['tt3']=t
        normal_plane = ParametricPlot3D(normal_plane_function, (-4.1, 4.1), (-4.1, 4.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['tt3'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(r1-r2,0,0)

        def endTangentPoint(t):
            # ||curve'(0)||
            s = pi_2*t #/1000.0
            #vn = sqrt((b*sin(s))**2 + (c*cos(s))**2)
            return Vec3(r1-r2, -sin(s), cos(s))

        def endCurvaturePoint(t):
            # ||curve'(0)||**2
            #s = pi_2*t/1000.0
            s = t #/1000.0
            #vn = (b*sin(s))**2 + (c*cos(s))**2
            # ||curve''(0)||
            # nn = a
            return Vec3(r1-2*s*r2, 0, 0)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['tt3']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1.0,0,40),func=setSyncParam, duration=4000, parent=self)
Esempio n. 3
0
    def __init__(self):
        super(Toro1,self).__init__(u'Secciones normales de un toro en un punto elíptico')

        self.showAxis(False)

        torus = createTorus(r1, r2)
        self.addChild(torus)

        normal = Arrow((r1+r2,0,0), (r1+r2+1,0,0), 0.03)
        normal.setDiffuseColor(_1(240,10,200))
        self.addChild(normal)

        class TorusCurve(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                cosp = cos(param1)
                sinp = sin(param1)
                u = s #*rot
                btor = 2.0*u**2 + 16.0 - 36.0*sinp**2
                v = sqrt( (-btor+sqrt(btor**2 - 4.0*(u**4-20.0*u**2+64.0)) )/2.0 )
                return Vec3(u, sinp*v, cosp*v)

            def setParam(self, t):
                self.param = t

        torusc_obj = TorusCurve()
        curve = Curve3DParam(torusc_obj, (2.0, 4.0, 200), color=(0.9, 0.2, 0.1), width=6)

        class TorusCurve2(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                cosp = cos(param1)
                sinp = sin(param1)
                u = s #*rot
                btor = 2.0*u**2 + 16.0 - 36.0*sinp**2
                v = -sqrt( (-btor+sqrt(btor**2 - 4.0*(u**4-20.0*u**2+64.0)) )/2.0 )
                return Vec3(u, sinp*v, cosp*v)

            def setParam(self, t):
                self.param = t

        torusc2_obj = TorusCurve2()
        curve2 = Curve3DParam(torusc2_obj, (2.0, 4.0, 200), color=(0.9, 0.2, 0.1), width=6)

        normal_plane_function = lambda u, v: (u, sin(pi_2*tt1)*v, cos(pi_2*tt1)*v)
        normal_plane_function.func_globals['tt1']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-4.1, 4.1), (-4.1, 4.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['tt1'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(r1+r2,0,0)

        def endTangentPoint(t):
            # ||curve'(0)||
            s = pi_2*t #/1000.0
            return Vec3(r1+r2, sin(s), cos(s))

        def endCurvaturePoint(t):
            # ||curve'(0)||**2
            s = t #/1000.0
            #vn = (b*sin(s))**2 + (c*cos(s))**2
            # ||curve''(0)||
            return Vec3(r1+s*(r2-1/r1), 0, 0)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, curve2, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['tt1']=t
            normal_plane.updateAll()
            curve.setParam(t)
            curve2.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1.0,0,40),func=setSyncParam, duration=4000, parent=self)
Esempio n. 4
0
    def __init__(self):
        super(Hiperboloide,self).__init__(u'Secciones normales de un paraboloide hiperbólico<br><br>x<sup>2</sup>/4 - y<sup>2</sup>/9 = z')

        self.showAxis(False)

        hyperboloid = createHyperboloid(2,3)
        self.addChild(hyperboloid)

        normal = Arrow((0,0,0), (0,0,1), 0.03)
        normal.setDiffuseColor(_1(240,10,200))
        self.addChild(normal)

        class Parabole(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                return Vec3(cos(pi_2*self.param)*s, sin(pi_2*self.param)*s, (cos(pi_2*self.param)*s)**2/4 - (sin(pi_2*self.param)*s)**2/9)

            def setParam(self, t):
                self.param = t

        parabole_obj = Parabole()
        curve = Curve3DParam(parabole_obj, (-4.0, 4.0, 200), color=(0.9, 0.2, 0.1), width=6)

        normal_plane_function = lambda u, v: (cos(pi_2*th)*v, sin(pi_2*th)*v, u)
        normal_plane_function.func_globals['th']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-4.1, 4.1), (-4.1, 4.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['th'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(0,0,0)

        def endTangentPoint(t):
            s = pi_2*t #/1000.0
            return Vec3(cos(s), sin(s), 0)

        def endCurvaturePoint(t):
            # ||curve'(0)||**2
            s = pi_2*t #/1000.0
            # vn = 1.0
            # ||curve''(0)||
            nn = ((cos(s))**2)/2 - 2*((sin(s))**2)/9
            return Vec3(0, 0, 2.0*nn)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['th']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1.0,0,20),func=setSyncParam, duration=4000, parent=self)
Esempio n. 5
0
    def __init__(self):
        super(Cilindro,self).__init__('Secciones normales de un cilindro recto circular<br><br>x<sup>2</sup> + z<sup>2</sup> = 1')

        self.showAxis(False)

        cyl = SoCylinder()
        cyl.radius.setValue(1.0)
        cyl.height.setValue(4.0)
        cyl.parts = SoCylinder.SIDES

        light = SoShapeHints()

        mat = SoMaterial()
        mat.emissiveColor = _1(80, 120, 200)
        mat.diffuseColor = _1(80, 120, 200)
        mat.transparency.setValue(0.5)

        sep = SoSeparator()
        sep.addChild(light)
        sep.addChild(mat)
        sep.addChild(cyl)

        self.addChild(sep)

        normal = Arrow((0,0,1), (0,0,2), 0.03)
        normal.setDiffuseColor(_1(240,10,200))
        self.addChild(normal)

        class CylCurve(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                #pi_2*self.param/1000.0
                return Vec3(cos(s), tan(pi_2*self.param) * cos(s), sin(s))

            def setParam(self, t):
                self.param = t

        cylc_obj = CylCurve()
        curve = Curve3DParam(cylc_obj, (-3.14, 3.14, 200), color=(0.9, 0.2, 0.1), width=6)
        curve.setBoundingBox((-3.1,3.1),(-3.1,3.1),(-3.1,3.1))
# Ojo! No basta con "acotar", la vista se recalcula con todo el objeto...

        normal_plane_function = lambda u, v: (cos(pi_2*tc)*v, sin(pi_2*tc)*v, u)
        normal_plane_function.func_globals['tc']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-1.1, 1.1), (-2.1, 2.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['tc'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(0,0,1)

        def endTangentPoint(t):
            s = pi_2*t #/1000.0
            return Vec3(cos(s), sin(s), 1)

        def endCurvaturePoint(t):
            return Vec3(0, 0, 0.9-cos(pi_2*t)) #/1000.0

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['tc']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,0.99,0,20),func=setSyncParam, duration=4000, parent=self)
Esempio n. 6
0
    def __init__(self):
        super(Elipsoide3,self).__init__(u'Secciones normales de un elipsoide un punto umbílico<br><br>x<sup>2</sup>/9 + y<sup>2</sup>/4 + z<sup>2</sup> = 1')

        self.showAxis(False)

        ellipsoid = createEllipsoid(a, b, c)
        self.addChild(ellipsoid)

        # umbilic point U = (px, 0, pz)
        #px = sqrt((a**2-b**2)/(a**2-c**2))
        #pz = sqrt((c**2)*(b**2-c**2)/(a**2-c**2))
        pz = sqrt((c**2-b**2)/(c**2-a**2))
        px = sqrt((a**2)*(b**2-a**2)/(c**2-a**2))

        # gradient in umbilic point U
        nx = 2*px/(a**2)
        nz = 2*pz/(c**2)

        n = sqrt(nx**2+nz**2)

        nx = nx/n
        nz = nz/n

        #print px, pz, px**2/(a**2)+pz**2/(c**2), nx, nz

        normal = Arrow((px,0,pz), (px+nx,0,pz+nz), 0.03)
        normal.setDiffuseColor(_1(240,10,200))
        self.addChild(normal)

        curvature_arrow = Arrow((px,0,pz), (px-0.5*nx,0,pz-0.5*nz), 0.05)
        curvature_arrow.setDiffuseColor(_1(220,200,20))
        self.addChild(curvature_arrow)

        class Ellipse(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                cosp = cos(param1)
                sinp = sin(param1)
                A = (nx**2)/9.0 + nz**2
                C = ((nz**2)/9.0 + nx**2)*cosp**2+(sinp**2)/4.0
                B = (16.0/9.0)*nx*nz*cosp
                D = 2.0*(nx*px/9.0 + nz*pz)
                E = 2.0*(nx*pz - nz*px/9.0)*cosp
                #F = 0
                ins_sqrt = A**2 + C**2 + B**2 - 2.0*A*C
                L1 = (A + C + sqrt(ins_sqrt) )/2.0
                L2 = (A + C - sqrt(ins_sqrt) )/2.0
                dis = 4.0*A*C-B**2
                C1 = (B*E-2.0*C*D)/dis
                C2 = (D*B-2.0*A*E)/dis
                detq = (A*(E**2) + C*(D**2) - B*D*E) #/4.0
                aell = sqrt(dis/(L1*detq))/(1.0+sinp*sinp)
                bell = sqrt(dis/(L2*detq))/(1.0+sinp*sinp)
                theta = atan( B/(A-C) )/2.0
                u = aell*cos(s)*cos(theta) - bell*sin(s)*sin(theta) + C1
                v = bell*sin(s)*cos(theta) + aell*cos(s)*sin(theta) + C2
                return Vec3(px+u*nx-cosp*v*nz, sinp*v, pz+u*nz+cosp*v*nx)

            def setParam(self, t):
                self.param = t

        ellipse_obj = Ellipse()
        curve = Curve3DParam(ellipse_obj, (-3.14, 3.14, 200), color=(0.9, 0.2, 0.1), width=6)

        # Rotation Z_Axis=(0,0,1) -> n=(nx,0,nz) (||n||=1)
        # Rot(x,y,z)=(x*nz+z*nx,y,-x*nx+z*nz)
        normal_plane_function = lambda u, v: (px+u*nx-cos(pi_2*t3)*v*nz, sin(pi_2*t3)*v, pz+u*nz+cos(pi_2*t3)*v*nx)
        normal_plane_function.func_globals['t3']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-3.3, 0.1), (-1.9, 4.9))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        normal_plane.setBoundingBox((-3.5,3.5),(-2.1,2.1),(-1.5,1.5))
        #normal_plane.animation = normal_plane.parameters['t3'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(px,0,pz)

        def endTangentPoint(t):
            # ||curve'(0)||
            s = pi_2*t #/1000.0
            vn = sqrt((nz*cos(s))**2 + (sin(s))**2 + (nx*cos(s))**2)
            return Vec3(px - nz*cos(s)/vn, sin(s)/vn, pz + nx*cos(s)/vn)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        objects = [curve, normal_plane, tangent_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['t3']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            #curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1,0,20),func=setSyncParam, duration=4000, parent=self)
Esempio n. 7
0
    def __init__(self):
        super(Elipsoide2,self).__init__('Secciones normales de un elipsoide en el punto (0,0,1)<br><br>x<sup>2</sup>/9 + y<sup>2</sup>/4 + z<sup>2</sup> = 1')

        self.showAxis(False)

        ellipsoid = createEllipsoid(a, b, c)
        self.addChild(ellipsoid)

        normal = Arrow((0,0,c), (0,0,c+1), 0.03)
        normal.setDiffuseColor(_1(240,10,200))
        self.addChild(normal)

        class Ellipse(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                return Vec3(a*cos(param1)*sin(s), b*sin(param1)*sin(s), c*cos(s))

            def setParam(self, t):
                self.param = t

        ellipse_obj = Ellipse()
        curve = Curve3DParam(ellipse_obj, (-3.14, 3.14, 200), color=(0.9, 0.2, 0.1), width=6)

        normal_plane_function = lambda u, v: (a*cos(pi_2*t2)*v, b*sin(pi_2*t2)*v, c*u)
        normal_plane_function.func_globals['t2']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-1.1, 1.1), (-1.1, 1.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['t2'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(0,0,c)

        def endTangentPoint(t):
            # ||curve'(0)||
            s = pi_2*t #/1000.0
            vn = sqrt((a*cos(s))**2 + (b*sin(s))**2)
            return Vec3(a*cos(s)/vn, b*sin(s)/vn, c)

        def endCurvaturePoint(t):
            # ||curve'(0)||**2
            s = pi_2*t #/1000.0
            vn = (a*cos(s))**2 + (b*sin(s))**2
            # ||curve''(0)||
            # nn = c
            return Vec3(0, 0, c-2.0*c/vn)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['t2']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1,0,20),func=setSyncParam, duration=4000, parent=self)
Esempio n. 8
0
    def __init__(self):
        super(Toro3,self).__init__(u'Secciones normales de un toro en un punto hiperbólico')

        self.showAxis(False)

        torus = createTorus(r1, r2)
        self.addChild(torus)

        normal = Arrow((r1-r2,0,0), (r1-r2-1,0,0), 0.03)
        self.addChild(normal)

        class TorusCurve(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                cosp = cos(param1)
                sinp = sin(param1)
                v = s
                btor = 2.0*v**2 - 20.0
                ctor = v**4 + (16.0 - 36.0*sinp**2)*v**2 + 64.0
                dis = btor**2 - 4.0*ctor
                if dis < 0.0:
                    #v = 0.0
                    u = 4.0
                else:
                    inside = -btor-sqrt(dis)
                    if inside < 0.0:
                        #v = 0.0
                        u = 4.0
                    else:
                        u = sqrt( inside/2.0 )
                return Vec3(u, sinp*v, -cosp*v)

            def setParam(self, t):
                self.param = t

        torusc_obj = TorusCurve()
        curve = Curve3DParam(torusc_obj, (-2.0, 2.0, 200), color=(0.9, 0.2, 0.1), width=6)
        curve.setBoundingBox((-0.05,2.95),(-4.1,4.1),(-1.1,1.1))

        normal_plane_function = lambda u, v: (u, sin(pi_2*tt3)*v, -cos(pi_2*tt3)*v)
        normal_plane_function.func_globals['tt3']=t
        normal_plane = ParametricPlot3D(normal_plane_function, (-4.1, 4.1), (-4.1, 4.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['tt3'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(r1-r2,0,0)

        def endTangentPoint(t):
            # ||curve'(0)||
            s = pi_2*t #/1000.0
            #vn = sqrt((b*sin(s))**2 + (c*cos(s))**2)
            return Vec3(r1-r2, -sin(s), cos(s))

        def endCurvaturePoint(t):
            # ||curve'(0)||**2
            #s = pi_2*t/1000.0
            s = t #/1000.0
            #vn = (b*sin(s))**2 + (c*cos(s))**2
            # ||curve''(0)||
            # nn = a
            return Vec3(r1-2*s*r2, 0, 0)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['tt3']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1.0,0,40),func=setSyncParam, duration=4000, parent=self)
Esempio n. 9
0
    def __init__(self):
        super(Toro1,self).__init__(u'Secciones normales de un toro en un punto elíptico')

        self.showAxis(False)

        torus = createTorus(r1, r2)
        self.addChild(torus)

        normal = Arrow((r1+r2,0,0), (r1+r2+1,0,0), 0.03)
        self.addChild(normal)

        class TorusCurve(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                cosp = cos(param1)
                sinp = sin(param1)
                u = s #*rot
                btor = 2.0*u**2 + 16.0 - 36.0*sinp**2
                v = sqrt( (-btor+sqrt(btor**2 - 4.0*(u**4-20.0*u**2+64.0)) )/2.0 )
                return Vec3(u, sinp*v, cosp*v)

            def setParam(self, t):
                self.param = t

        torusc_obj = TorusCurve()
        curve = Curve3DParam(torusc_obj, (2.0, 4.0, 200), color=(0.9, 0.2, 0.1), width=6)

        class TorusCurve2(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                cosp = cos(param1)
                sinp = sin(param1)
                u = s #*rot
                btor = 2.0*u**2 + 16.0 - 36.0*sinp**2
                v = -sqrt( (-btor+sqrt(btor**2 - 4.0*(u**4-20.0*u**2+64.0)) )/2.0 )
                return Vec3(u, sinp*v, cosp*v)

            def setParam(self, t):
                self.param = t

        torusc2_obj = TorusCurve2()
        curve2 = Curve3DParam(torusc2_obj, (2.0, 4.0, 200), color=(0.9, 0.2, 0.1), width=6)

        normal_plane_function = lambda u, v: (u, sin(pi_2*tt1)*v, cos(pi_2*tt1)*v)
        normal_plane_function.func_globals['tt1']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-4.1, 4.1), (-4.1, 4.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['tt1'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(r1+r2,0,0)

        def endTangentPoint(t):
            # ||curve'(0)||
            s = pi_2*t #/1000.0
            return Vec3(r1+r2, sin(s), cos(s))

        def endCurvaturePoint(t):
            # ||curve'(0)||**2
            s = t #/1000.0
            #vn = (b*sin(s))**2 + (c*cos(s))**2
            # ||curve''(0)||
            return Vec3(r1+s*(r2-1/r1), 0, 0)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, curve2, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['tt1']=t
            normal_plane.updateAll()
            curve.setParam(t)
            curve2.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1.0,0,40),func=setSyncParam, duration=4000, parent=self)
Esempio n. 10
0
    def __init__(self):
        super(Hiperboloide,self).__init__(u'Secciones normales de un paraboloide hiperbólico<br><br>x<sup>2</sup>/4 - y<sup>2</sup>/9 = z')

        self.showAxis(False)

        hyperboloid = createHyperboloid(2,3)
        self.addChild(hyperboloid)

        normal = Arrow((0,0,0), (0,0,1), 0.03)
        self.addChild(normal)

        class Parabole(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                return Vec3(cos(pi_2*self.param)*s, sin(pi_2*self.param)*s, (cos(pi_2*self.param)*s)**2/4 - (sin(pi_2*self.param)*s)**2/9)

            def setParam(self, t):
                self.param = t

        parabole_obj = Parabole()
        curve = Curve3DParam(parabole_obj, (-4.0, 4.0, 200), color=(0.9, 0.2, 0.1), width=6)

        normal_plane_function = lambda u, v: (cos(pi_2*th)*v, sin(pi_2*th)*v, u)
        normal_plane_function.func_globals['th']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-4.1, 4.1), (-4.1, 4.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['th'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(0,0,0)

        def endTangentPoint(t):
            s = pi_2*t #/1000.0
            return Vec3(cos(s), sin(s), 0)

        def endCurvaturePoint(t):
            # ||curve'(0)||**2
            s = pi_2*t #/1000.0
            # vn = 1.0
            # ||curve''(0)||
            nn = ((cos(s))**2)/2 - 2*((sin(s))**2)/9
            return Vec3(0, 0, 2.0*nn)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['th']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1.0,0,20),func=setSyncParam, duration=4000, parent=self)
Esempio n. 11
0
    def __init__(self):
        super(Cilindro,self).__init__('Secciones normales de un cilindro recto circular<br><br>x<sup>2</sup> + z<sup>2</sup> = 1')

        self.showAxis(False)

        cyl = SoCylinder()
        cyl.radius.setValue(1.0)
        cyl.height.setValue(4.0)
        cyl.parts = SoCylinder.SIDES

        light = SoShapeHints()

        mat = SoMaterial()
        mat.emissiveColor = _1(80, 120, 200)
        mat.diffuseColor = _1(80, 120, 200)
        mat.transparency.setValue(0.5)

        sep = SoSeparator()
        sep.addChild(light)
        sep.addChild(mat)
        sep.addChild(cyl)

        self.addChild(sep)

        normal = Arrow((0,0,1), (0,0,2), 0.03)
        self.addChild(normal)

        class CylCurve(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                #pi_2*self.param/1000.0
                return Vec3(cos(s), tan(pi_2*self.param) * cos(s), sin(s))

            def setParam(self, t):
                self.param = t

        cylc_obj = CylCurve()
        curve = Curve3DParam(cylc_obj, (-3.14, 3.14, 200), color=(0.9, 0.2, 0.1), width=6)
        curve.setBoundingBox((-3.1,3.1),(-3.1,3.1),(-3.1,3.1))
# Ojo! No basta con "acotar", la vista se recalcula con todo el objeto...

        normal_plane_function = lambda u, v: (cos(pi_2*tc)*v, sin(pi_2*tc)*v, u)
        normal_plane_function.func_globals['tc']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-1.1, 1.1), (-2.1, 2.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['tc'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(0,0,1)

        def endTangentPoint(t):
            s = pi_2*t #/1000.0
            return Vec3(cos(s), sin(s), 1)

        def endCurvaturePoint(t):
            return Vec3(0, 0, 0.9-cos(pi_2*t)) #/1000.0

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['tc']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,0.99,0,20),func=setSyncParam, duration=4000, parent=self)
Esempio n. 12
0
    def __init__(self):
        super(Elipsoide3,self).__init__(u'Secciones normales de un elipsoide un punto umbílico<br><br>x<sup>2</sup>/9 + y<sup>2</sup>/4 + z<sup>2</sup> = 1')

        self.showAxis(False)

        ellipsoid = createEllipsoid(a, b, c)
        self.addChild(ellipsoid)

        # umbilic point U = (px, 0, pz)
        #px = sqrt((a**2-b**2)/(a**2-c**2))
        #pz = sqrt((c**2)*(b**2-c**2)/(a**2-c**2))
        pz = sqrt((c**2-b**2)/(c**2-a**2))
        px = sqrt((a**2)*(b**2-a**2)/(c**2-a**2))

        # gradient in umbilic point U
        nx = 2*px/(a**2)
        nz = 2*pz/(c**2)

        n = sqrt(nx**2+nz**2)

        nx = nx/n
        nz = nz/n

        #print px, pz, px**2/(a**2)+pz**2/(c**2), nx, nz

        normal = Arrow((px,0,pz), (px+nx,0,pz+nz), 0.03)
        self.addChild(normal)

        curvature_arrow = Arrow((px,0,pz), (px-0.5*nx,0,pz-0.5*nz), 0.05)
        curvature_arrow.setDiffuseColor(_1(220,200,20))
        self.addChild(curvature_arrow)

        class Ellipse(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                cosp = cos(param1)
                sinp = sin(param1)
                A = (nx**2)/9.0 + nz**2
                C = ((nz**2)/9.0 + nx**2)*cosp**2+(sinp**2)/4.0
                B = (16.0/9.0)*nx*nz*cosp
                D = 2.0*(nx*px/9.0 + nz*pz)
                E = 2.0*(nx*pz - nz*px/9.0)*cosp
                #F = 0
                ins_sqrt = A**2 + C**2 + B**2 - 2.0*A*C
                L1 = (A + C + sqrt(ins_sqrt) )/2.0
                L2 = (A + C - sqrt(ins_sqrt) )/2.0
                dis = 4.0*A*C-B**2
                C1 = (B*E-2.0*C*D)/dis
                C2 = (D*B-2.0*A*E)/dis
                detq = (A*(E**2) + C*(D**2) - B*D*E) #/4.0
                aell = sqrt(dis/(L1*detq))/(1.0+sinp*sinp)
                bell = sqrt(dis/(L2*detq))/(1.0+sinp*sinp)
                theta = atan( B/(A-C) )/2.0
                u = aell*cos(s)*cos(theta) - bell*sin(s)*sin(theta) + C1
                v = bell*sin(s)*cos(theta) + aell*cos(s)*sin(theta) + C2
                return Vec3(px+u*nx-cosp*v*nz, sinp*v, pz+u*nz+cosp*v*nx)

            def setParam(self, t):
                self.param = t

        ellipse_obj = Ellipse()
        curve = Curve3DParam(ellipse_obj, (-3.14, 3.14, 200), color=(0.9, 0.2, 0.1), width=6)

        # Rotation Z_Axis=(0,0,1) -> n=(nx,0,nz) (||n||=1)
        # Rot(x,y,z)=(x*nz+z*nx,y,-x*nx+z*nz)
        normal_plane_function = lambda u, v: (px+u*nx-cos(pi_2*t3)*v*nz, sin(pi_2*t3)*v, pz+u*nz+cos(pi_2*t3)*v*nx)
        normal_plane_function.func_globals['t3']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-3.3, 0.1), (-1.9, 4.9))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        normal_plane.setBoundingBox((-3.5,3.5),(-2.1,2.1),(-1.5,1.5))
        #normal_plane.animation = normal_plane.parameters['t3'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(px,0,pz)

        def endTangentPoint(t):
            # ||curve'(0)||
            s = pi_2*t #/1000.0
            vn = sqrt((nz*cos(s))**2 + (sin(s))**2 + (nx*cos(s))**2)
            return Vec3(px - nz*cos(s)/vn, sin(s)/vn, pz + nx*cos(s)/vn)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        objects = [curve, normal_plane, tangent_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['t3']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            #curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1,0,20),func=setSyncParam, duration=4000, parent=self)
Esempio n. 13
0
    def __init__(self):
        super(Elipsoide2,self).__init__('Secciones normales de un elipsoide en el punto (0,0,1)<br><br>x<sup>2</sup>/9 + y<sup>2</sup>/4 + z<sup>2</sup> = 1')

        self.showAxis(False)

        ellipsoid = createEllipsoid(a, b, c)
        self.addChild(ellipsoid)

        normal = Arrow((0,0,c), (0,0,c+1), 0.03)
        self.addChild(normal)

        class Ellipse(object):

            def __init__(self, t=0.0):
                self.param = t

            def __call__(self, s):
                param1 = pi_2*self.param #/1000.0
                return Vec3(a*cos(param1)*sin(s), b*sin(param1)*sin(s), c*cos(s))

            def setParam(self, t):
                self.param = t

        ellipse_obj = Ellipse()
        curve = Curve3DParam(ellipse_obj, (-3.14, 3.14, 200), color=(0.9, 0.2, 0.1), width=6)

        normal_plane_function = lambda u, v: (a*cos(pi_2*t2)*v, b*sin(pi_2*t2)*v, c*u)
        normal_plane_function.func_globals['t2']=0.0
        normal_plane = ParametricPlot3D(normal_plane_function, (-1.1, 1.1), (-1.1, 1.1))
        normal_plane.setTransparency(0.75)
        normal_plane.setTransparencyType(SoTransparencyType.SCREEN_DOOR)
        #normal_plane.animation = normal_plane.parameters['t2'].asAnimation()

        VisibleCheckBox("Plano Normal", normal_plane, True, parent=self)

        def basePoint(t):
            return Vec3(0,0,c)

        def endTangentPoint(t):
            # ||curve'(0)||
            s = pi_2*t #/1000.0
            vn = sqrt((a*cos(s))**2 + (b*sin(s))**2)
            return Vec3(a*cos(s)/vn, b*sin(s)/vn, c)

        def endCurvaturePoint(t):
            # ||curve'(0)||**2
            s = pi_2*t #/1000.0
            vn = (a*cos(s))**2 + (b*sin(s))**2
            # ||curve''(0)||
            # nn = c
            return Vec3(0, 0, c-2.0*c/vn)

        tangent_arrow = AnimatedArrow(basePoint, endTangentPoint)
        tangent_arrow.setDiffuseColor(_1(20,10,220))

        curvature_arrow = AnimatedArrow(basePoint, endCurvaturePoint)
        curvature_arrow.setDiffuseColor(_1(220,200,20))

        objects = [curve, normal_plane, tangent_arrow, curvature_arrow]
        self.addChildren( objects )

        def setSyncParam(t):
            normal_plane_function.func_globals['t2']=t
            normal_plane.updateAll()
            curve.setParam(t)
            tangent_arrow.animateArrow(t)
            curvature_arrow.animateArrow(t)

        Slider(rangep=('t', 0,1,0,20),func=setSyncParam, duration=4000, parent=self)