Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-4-20250514· AnthropicHugging Face LMArena Human Preference 140K

generate the code in openscad to render a banana

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-sonnet-4-20250514-thinking-32k’s answer.
  1. User

    generate the code in openscad to render a banana

  2. Claude Assistant

    Here's OpenSCAD code to create a 3D banana model:

    // Banana parameters
    banana_length = 120;
    banana_radius = 12;
    curve_height = 40;
    segments = 20;
    
    module banana() {
        // Create the main curved body of the banana
        hull() {
            for (i = [0:segments]) {
                t = i / segments;
                
                // Calculate position along banana curve
                x = t * banana_length;
                y = 0;
                z = sin(t * 180) * curve_height;
                
                // Calculate radius that tapers toward the ends
                radius = banana_radius * (1 - pow(abs(t - 0.5) * 2, 2) * 0.6);
                
                translate([x, y, z])
                rotate([0, atan2(z - (t > 0 ? sin((t-0.05) * 180) * curve_height : 0), 
                                banana_length/segments), 0])
                cylinder(h=0.1, r=radius, center=true);
            }
        }
        
        // Add the stem end
        translate([0, 0, 0])
        rotate([0, 15, 0])
        cylinder(h=8, r1=3, r2=1);
        
        // Add the tip end
        translate([banana_length, 0, sin(180) * curve_height])
        rotate([0, -15, 0])
        sphere(r=4);
    }
    
    // Create ridges on the banana surface
    module banana_with_ridges() {
        difference() {
            banana();
            
            // Create longitudinal ridges
            for (angle = [0:60:300]) {
                rotate([0, 0, angle])
                translate([0, banana_radius + 2, 0])
                hull() {
                    for (i = [0:segments]) {
                        t = i / segments;
                        x = t * banana_length;
                        z = sin(t * 180) * curve_height;
                        
                        translate([x, 0, z])
                        cylinder(h=0.1, r=1, center=true);
                    }
                }
            }
        }
    }
    
    // Render the banana
    banana_with_ridges();
    

    This code creates a banana with the following features:

    Main Structure:

    • Uses a hull() operation to connect cylindrical segments along a curved path
    • The curve follows a sine wave to create the characteristic banana arc
    • Radius tapers toward both ends for a natural banana shape

    Key Elements:

    • Curved body: Created by positioning cylinders along a sine curve
    • Tapered ends: The radius calculation makes the banana thinner at the tips
    • Stem: A small tapered cylinder at the starting end
    • Tip: A sphere at the pointed end
    • Surface ridges: Longitudinal grooves that give the banana texture

    Parameters you can adjust:

    • banana_length: Overall length of the banana
    • banana_radius: Thickness at the widest point
    • curve_height: How much the banana curves upward
    • segments: Number of segments (higher = smoother curve)

    The banana will have a natural curved shape with surface ridges similar to a real banana. You can modify the parameters to create bananas of different sizes and curvatures.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.