Ejemplo n.º 1
0
//Dini's Surface
void dini(GLVApp& app, bool reset = false){

    static Dll dll = DLN(0,1,0);
    static Frame frame(PT(0,2,0), Rot(1,0,0,0));
    
    TOUCH(frame); 

    static Pnt p = Ro::null(1,0,0);
    static float period, pitch, amt, nm, lz;

    SET 
        Gui& gui = app.gui;
        gui(period,"period",-10,10)(pitch,"pitch",-10,10)(amt,"amt",-10,10)(nm,"num",10,100); 
        gui(lz, "light_src",-100,100);
        
        amt = -2;
        period = 1;
        pitch = 0;
        lz = .35;
   
     END
    
    if (reset) bSet = false;

    GL::lightPos(0, lz, lz);
    DRAW(frame);//.draw();
    
    Twist tw; tw.along(dll, PI*period, pitch);
    
    Par par = frame.ty(frame.scale() * amt);
        
    int num = nm;
    UVMesh uvmesh(num+1,num+1);
    
    ITJi(i,num)
        Pnt tp = p.sp( tw.mot(-t) );
        ITJi(j, num)
            Par npar = par.trs(0,tp[1],0);
            Bst pp = Gen::bst(npar*t);//Gen::trv(1,npar * t);
            Pnt np = Ro::loc( tp.sp( pp ) );
            
            uvmesh.add(np);

        END 
    END 
    
    //DRAW
    uvmesh.draw(1,0,0);
    uvmesh.drawTri(1,1,0,.5);
    
    app.text("Negatively Curved Surfaces: The Psuedosphere and Dini's Surface");

}
Ejemplo n.º 2
0
void hopf(al::VsrApp& app){
    
    HopfFiber hf;
    
    static int time = 0; time++;  double tphase = PI * time/180.0;

    //GUI Controlled Parameters
    static int num = 2;
    static int res = 3;
    static bool handed, bDrawCir, bDrawPnt,bReset;
    static double phase,amt,minDistance;
    
    //SET UP Gui
    static bool bSet = 0;
    if (!bSet) { 
        bSet = 1; 
        app.glv.gui(num,"num",0,1000)(res,"res",0,1000)(phase,"phase",-100,100)(amt,"amt",0,10)(minDistance,"minDistance",0,1000);
        app.glv.gui(handed)(bDrawCir, "drawcir")(bDrawPnt,"drawpnt")(bReset,"reset"); 
    }    
        
    vector<Pnt> vp;
    for (int i = 0; i < num; ++i){
        double u = 1.0 * i/num;

        for (int j = 0; j < res; ++j){
            double v = 1.0 * j/res;

            Cir tc = hf.fiber(-1.0 + 2*u, -.5 + v);
            
            Pnt tp = Ro::pnt_cir( tc, tphase * Ro::cur(tc) * phase);
            if(bDrawPnt)DRAW3(tp,u,v,1-u);
            if(bDrawCir)DRAW3(tc,v,u,1-u);
        
            vp.push_back( Ro::pnt_cir( tc, v * u * PI ) );
        }
    }
    

    static Dll dll = DLN(0,1,0); app.interface.touch(dll); DRAW(dll);
    static Point point = PT(2,0,0); app.interface.touch(point);  DRAW3(point,1,0,0);
    
    for (int i = 0; i <= 1; ++i){
        double t = i/1.0;
        Dll tdll = dll.sp( Gen::rot(Biv::xy * t*PIOVERTWO) );
        Pnt pa = Ro::split( ( tdll ^ Ro::sur(hf.cir) ).dual(), true);
        Pnt pb = Ro::split( ( tdll ^ Ro::sur(hf.cir) ).dual(), false);
        
        DRAW3(pa,1,1,0); DRAW3(pb,1,1,0);
    
        Coord::Sph spha = Coord::vec2sph( Vector(pa).unit() );
        Coord::Sph sphb = Coord::vec2sph( Vector(pb).unit() );
                
        Cir cca = hf.fiber( spha.theta / PI, spha.phi / PI );
        Cir ccb = hf.fiber( sphb.theta / PI, sphb.phi / PI );
        
        Bst bst = Gen::bst( (cca.dual() * PI/3.0 + ccb.dual() * PI/2.0 )* amt );
        
        
        DRAW3(cca,0,1,0); DRAW3(ccb,0,0,1);
        
        vector<Pnt> pp; 
        Pnt tp = point;//.trs(-t,0,0);
        for (int i = 0; i<1000; ++i){
            tp = Ro::loc( tp.sp( bst ) );
            pp.push_back(tp);
        }
        
        glColor3f(1,0,0);
        glBegin(GL_LINE_STRIP);
         
            for (int i = 0; i<pp.size(); ++i ){
                GL::vertex( pp[i].w() );
            }
         
        glEnd();
    }
    
    int tnum = 10;
    
//    for (int j = 0; j < tnum; ++j){
//    
//        double t = 1.0 * j/tnum;        
//        
//        Bst bst2 = hf.mtt( );
//        
//        for (int i = 0; i<pp.size(); ++i ){
//            for(int k = 0; k < 10; ++k){
//            
//            }
//        }
//
//    }
}