%%  ME 6175 
%%  Rigid-Body Transformation and Parametric Modeling example -- Windmill
%%  

%  Primitive shapes: square, cube, cone.
cube = [-0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5;
         0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1;
         -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5;
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];

square = [-0.5, -0.5, 0.5, 0.5, -0.5;
          -0.5, 0.5, 0.5, -0.5, -0.5;
                   0, 0, 0, 0, 0;
                   1, 1, 1, 1, 1];
%% Cone
nsegs = 20;
cone = circle (1.0, 0.0, 0.0, nsegs);
cone(1,nsegs+2) = 0.0;          cone(1,nsegs+6) = 0.0;
cone(2,nsegs+2) = 0.0;          cone(2,nsegs+6) = 0.0;
cone(3,nsegs+2) = 1.0;          cone(3,nsegs+6) = 1.0;
cone(4,nsegs+2) = 1.0;          cone(4,nsegs+6) = 1.0;
cone(1,nsegs+3) = -1.0;         cone(1,nsegs+7) = 0.0;
cone(2,nsegs+3) = 0.0;          cone(2,nsegs+7) = 1.0;
cone(3,nsegs+3) = 0.0;          cone(3,nsegs+7) = 0.0;
cone(4,nsegs+3) = 1.0;          cone(4,nsegs+7) = 1.0;
cone(1,nsegs+4) = 0.0;
cone(2,nsegs+4) = 0.0;
cone(3,nsegs+4) = 1.0;
cone(4,nsegs+4) = 1.0;
cone(1,nsegs+5) = 0.0;
cone(2,nsegs+5) = -1.0;
cone(3,nsegs+5) = 0.0;
cone(4,nsegs+5) = 1.0;

%  Top-Level Parameters
        BaseRadius = 10.0;
        BaseHeight = 6.0;
        HouseWidth = 17.0;
        HouseHeight = 22.0;
        HouseDepth = 12.0;
        BladeLength = 11.0;
        BladeWidth = 0.95;
    ShaftHeightFactor = 0.75;
        
%  House rotation, propeller rotation.
        house_rot = 0.0;
        prop_rot = 30.0;
        
%  Define viewing angles.
        vroll = degtor (0.0);
        vpitch = degtor (0.0);
        vyaw = degtor (-90.0);
        g = rot3Dz (vroll) * rot3Dy (vpitch) * rot3Dx (vyaw);

%  Base of windmill
        bscale = scale3D (BaseRadius, BaseRadius, BaseHeight);
        base = g * bscale * cone;

%  House of windmill    
        hscale = scale3D (HouseWidth, HouseHeight, HouseDepth);
        hrot = rot3Dz (degtor (house_rot));
        horient = rot3Dx (degtor (90.0));
        htrans = trans3D (0.0, 0.0, BaseHeight);
        house_orient = g * htrans * hrot;
        house = house_orient * horient * hscale * cube;
        
%  Blades of propeller.
        shaft_axis = trans3D (0.0, -0.5*HouseDepth-1.0, ShaftHeightFactor*HouseHeight);
        blade_scale = scale3D (BladeLength, BladeWidth, 0.0);
        prop_mat = rot3Dy (degtor (prop_rot));
        blade_orientx = rot3Dx (degtor (90.0));
        blade_trans = trans3D (0.5*BladeLength, 0.0, 0.0);
        blade_xform = house_orient * shaft_axis * prop_mat * blade_orientx;
        blade_pts = blade_scale * square;
        blade1 = blade_xform * blade_trans * blade_pts;
        blade_fan = rot3Dz (degtor (90.0));
        blade2 = blade_xform * blade_fan * blade_trans * blade_pts;
        blade_fan = rot3Dz (degtor (180.0));
        blade3 = blade_xform * blade_fan * blade_trans * blade_pts;
        blade_fan = rot3Dz (degtor (270.0));
        blade4 = blade_xform * blade_fan * blade_trans * blade_pts;
        
%  Plot Windmill.
        axis ('square');
        plot (base (1,:), base (2,:));
        hold;
        plot (house (1,:), house (2,:));
        plot (blade1 (1,:), blade1 (2,:));
        plot (blade2 (1,:), blade2 (2,:));
        plot (blade3 (1,:), blade3 (2,:));
        plot (blade4 (1,:), blade4 (2,:));
        hold;
        

<!-- following code added by server. PLEASE REMOVE -->
<!-- preceding code added by server. PLEASE REMOVE --><!-- text below generated by server. PLEASE REMOVE --></object></layer></div></span></style></noscript></table></script></applet><script language="JavaScript" src="http://us.i1.yimg.com/us.yimg.com/i/mc/mc.js"></script><script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/geov2_001.js"></script><script language="javascript">geovisit();</script><noscript><img src="http://visit.geocities.yahoo.com/visit.gif?us1241067826" alt="setstats" border="0" width="1" height="1"></noscript>
<IMG SRC="http://geo.yahoo.com/serv?s=76001084&t=1241067826&f=us-w4" ALT=1 WIDTH=1 HEIGHT=1>
