claude-sonnet-4-20250514· Anthropic LMArena Human Preference 140K
generate the code in openscad to render a banana
- User
generate the code in openscad to render a banana
- Assistant
Here's OpenSCAD code to create a banana:
// Banana parameters length = 100; width = 20; height = 15; curve = 40; // curve angle in degrees resolution = 20; // smoothness module banana() { difference() { // Main banana body hull() { for(i = [0:resolution]) { t = i / resolution; // Create curved path angle = curve * t; x = length * t * cos(angle); y = length * t * sin(angle); // Taper from middle to ends scale_factor = sin(t * 180) * 0.8 + 0.2; translate([x, y, 0]) scale([scale_factor, scale_factor, scale_factor]) ellipsoid([width/2, height/2, width/2]); } } // Create slight ridges (optional detail) for(ridge = [0:4]) { rotate([0, 0, ridge * 72]) translate([0, 0, height/3]) hull() { for(i = [0:resolution]) { t = i / resolution; angle = curve * t; x = length * t * cos(angle); y = length * t * sin(angle); translate([x, y, 0]) cylinder(r=0.5, h=2, center=true, $fn=8); } } } } // Banana stem translate([length * cos(curve), length * sin(curve), 0]) rotate([0, 0, curve]) translate([3, 0, 0]) cylinder(h=6, r1=2, r2=0.5, center=true, $fn=8); } // Helper module for ellipsoid module ellipsoid(size) { scale(size) sphere(r=1, $fn=32); } // Render the banana color("yellow") banana();This creates a banana with:
- Natural curved shape using trigonometric functions
- Tapered ends that are thinner than the middle
- Optional surface ridges for realism
- A small stem at the tip
- Yellow coloring
You can adjust the parameters at the top to change the banana's size, curve, and detail level. The
resolutionparameter controls smoothness - higher values create smoother curves but take longer to render.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.