- /
- 
        wind turbine and its working
        on 30 Oct 2024
        
        
 
    - 20
- 142
- 0
- 0
- 884
 Cite your audio source here (if applicable): 
drawframe(1);
 Write your drawframe function below
function drawframe(frameNumber)
    % Parameters
    bladeLength = 3; % Length of each blade
    numBlades = 3; % Number of blades
    hubRadius = 0.2; % Radius of the hub at the center
    poleHeight = 8; % Height of the turbine pole
    rotationAngle = frameNumber * 15; % Rotation per frame (degrees)
    % Create figure
    figure;
    hold on;
    axis equal;
    view(3); % 3D view
    grid on;
    axis([-5 5 -5 5 0 poleHeight+2]);
    xlabel('X');
    ylabel('Y');
    zlabel('Height');
    title(['3D Wind Turbine - Frame ' num2str(frameNumber)]);
    % Draw the pole of the turbine
    [X, Y, Z] = cylinder(0.1, 20); % Thin cylinder for pole
    Z = Z * poleHeight;
    surf(X, Y, Z, 'FaceColor', [0.5 0.5 0.5], 'EdgeColor', 'none'); % Grey pole
    % Draw the hub at the top of the pole
    [hubX, hubY, hubZ] = sphere(20);
    surf(hubX * hubRadius, hubY * hubRadius, hubZ * hubRadius + poleHeight, ...
         'FaceColor', [0.7 0.7 0.7], 'EdgeColor', 'none'); % Slightly larger hub
    % Draw the blades
    for b = 1:numBlades
        % Calculate blade angle for each blade
        bladeAngle = rotationAngle + (b-1) * (360 / numBlades);
        % Define blade end points
        xBladeEnd = bladeLength * cosd(bladeAngle);
        yBladeEnd = bladeLength * sind(bladeAngle);
        zBladeEnd = poleHeight;
        % Draw blade as a line from the hub center to blade end
        line([0, xBladeEnd], [0, yBladeEnd], [poleHeight, zBladeEnd], ...
             'Color', [0 0 1], 'LineWidth', 2); % Blue blades
    end
    % Display rotation direction arrow (optional)
    quiver3(0, 0, poleHeight + 0.5, 0, 0, 0.5, 'k', 'LineWidth', 1, 'MaxHeadSize', 1);
    hold off;
end


 

