Question: Section plane solids

This is still a  starting procedure and let's see what can be added?

restart;
# Define the procedure to draw a cylinder along the x-axis and a specifically positioned plane
CylinderAndPlane := proc(r, h, alpha_deg, beta_deg, P, axis_length)
    local alpha, beta, cylinder, plane, pointPlot, display, nx, ny, nz, px, py, pz, annotations, plane_type, titleStr, grafiek;  # Added: titleStr
    uses plots, LinearAlgebra;  
    # Convert angles from degrees to radians
    alpha := alpha_deg * Pi / 180;
    beta := beta_deg * Pi / 180;

    # Determine the normal vector based on angles
    nx := cos(alpha) * sin(beta);
    ny := sin(alpha) * sin(beta);
    nz := cos(beta);

    # Point P is directly used as given coordinates
    px, py, pz := op(P);

    # Cylinder along the x-axis
    cylinder := plots:-implicitplot3d(y^2 + z^2 = r^2, x = 0 .. h, y = -r .. r, z = -r .. r, style = surface, color = "LightBlue", transparency = 0.5);

    # Determine the type of plane based on angles alpha and beta
    if beta_deg = 90 then
        plane_type := "yz";
        plane := plots:-implicitplot3d(x = px, x = px - 10 .. px + 10, y = -axis_length .. axis_length, z = -axis_length .. axis_length, style = surface, color = "Yellow", transparency = 0.5);
    elif alpha_deg = 90 and beta_deg = 0 then
        plane_type := "xz";
        plane := plots:-implicitplot3d(y = py, x = -axis_length .. axis_length, y = py - 10 .. py + 10, z = -axis_length .. axis_length, style = surface, color = "Green", transparency = 0.5);
    elif beta_deg = 0 then
        plane_type := "xy";
        plane := plots:-implicitplot3d(z = pz, x = -axis_length .. axis_length, y = -axis_length .. axis_length, z = pz - 10 .. pz + 10, style = surface, color = "Blue", transparency = 0.5);
    else
        plane_type := "arbitrary";
        plane := plots:-implicitplot3d(nx * (x - px) + ny * (y - py) + nz * (z - pz) = 0, x = -axis_length .. axis_length, y = -axis_length .. axis_length, z = -axis_length .. axis_length, style = surface, color =            "Red", transparency = 0.7);
    end if;

    # Mark point P
    pointPlot := plots:-pointplot3d([px, py, pz], symbol = solidcircle, symbolsize = 10, color = "Red");

    # Create dynamic title - New
    titleStr := cat("Plane: ", plane_type, "\nAlpha: ", sprintf("%.2f", alpha_deg), " deg\nBeta: ", sprintf("%.2f", beta_deg), " deg\nPoint: [", sprintf("%.2f", P[1]), ", ", sprintf("%.2f", P[2]), ", ", sprintf("%.2f", P[3]), "]");

    # Display everything together - Modified: titleStr added in the display function
    grafiek := plots:-display(cylinder, plane, pointPlot, axes = normal, scaling = constrained, labels = ["x", "y", "z"], title = titleStr);

    return grafiek;
end proc:

# Example call to the procedure with coordinates of P and setting the axis length
# Alpha and Beta are now angles in degrees, P is a list of coordinates, axis_length is the length of the coordinate axes
CylinderAndPlane(15, 50, 0, 90, [15, 5, 5], 30);  # For yz-plane
#CylinderAndPlane(5, 15, 90, 0, [5, 5, 5], 10);  # For xz-plane
#CylinderAndPlane(5, 15, 0, 0, [5, 5, 5], 10);   # For xy-plane
#CylinderAndPlane(5, 55, 45, 45, [5, 5, 5], 10); # For arbitrary plane

 
 

 

Download maple_primes_-doorsnijdingsvlak_solids_procedureDEF.mw

Please Wait...