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 render a banana:
// Banana parameters banana_length = 120; banana_width = 25; banana_height = 20; curve_angle = 45; // Degrees of curve segments = 12; // Number of segments for smoothness module banana() { hull() { for(i = [0:segments]) { // Calculate position along the curve t = i / segments; angle = curve_angle * t; // Position along curved path x = banana_length * t * cos(angle); y = banana_length * t * sin(angle); z = 0; // Taper factor - thicker in middle, thinner at ends taper = 1 - pow(abs(t - 0.5) * 2, 1.5) * 0.4; translate([x, y, z]) scale([taper, taper, taper]) resize([banana_width, banana_height, banana_width]) sphere(d=20, $fn=16); } } // Add small stem at the end translate([banana_length * cos(curve_angle), banana_length * sin(curve_angle), 0]) rotate([0, 0, curve_angle]) translate([5, 0, 0]) cylinder(h=8, r1=3, r2=1, center=true, $fn=8); } // Render the banana banana();This code creates a banana by:
- Curved Path: Uses trigonometric functions to create a natural banana curve
- Hull Operation: Connects multiple spheres along the curved path to create a smooth shape
- Tapering: Makes the banana thicker in the middle and thinner at the ends using a taper factor
- Stem: Adds a small conical stem at the tip
Key Parameters you can adjust:
banana_length: Overall length of the bananabanana_width: Width at the thickest pointbanana_height: Height (thickness) of the bananacurve_angle: How much the banana curves (in degrees)segments: Higher values create smoother curves but slower rendering
The result is a realistic-looking 3D banana that you can 3D print or use in your OpenSCAD projects!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.