 |
CLIP Score: 33.25
from AIDL import *
def fancy_teapot(
body_width: float = 6 * inches,
body_height: float = 4 * inches,
corner_radius: float = 1 * inches,
spout_length: float = 3 * inches,
spout_width: float = 1 * inches,
handle_radius: float = 2 * inches,
handle_thickness: float = 0.5 * inches,
lid_radius: float = 2 * inches,
knob_radius: float = 0.5 * inches
):
teapot = Solid()
# Body
teapot.body = RoundedRectangle((0, 0), body_width, body_height, corner_radius)
# Spout
spout = Solid(shift=(body_width/2, body_height/4))
teapot.spout = spout
spout.base = Rectangle((spout_length/2, 0), spout_length, spout_width)
# Handle
handle = Solid(shift=(-body_width/2, body_height/4))
teapot.handle = handle
handle.outer_arc = Arc((0,0), 0, 180, handle_radius)
handle.inner_arc = Arc((0,0), 0, 180, handle_radius - handle_thickness)
# Lid and Knob
lid = Solid(shift=(0, body_height/2))
teapot.lid = lid
lid.disk = Circle((0, 0), lid_radius)
knob = Solid(shift=(0, 0.5*inches))
lid.knob = knob
knob.disk = Circle((0, 0), knob_radius)
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a fancy teapot
Sure, let's create a program to generate a fancy teapot in AIDL. Teapots typically have several components: a body, a spout, a handle, and sometimes a lid with a knob. We will construct these parts step by step. Let's break down each part and create an AIDL program for them.
Here’s the step-by-step process to create the fancy teapot:
1. **Teapot Body**: This will be a rounded rectangle for simplicity.
2. **Spout**: The spout will be a truncated cone shape for simplicity.
3. **Handle**: The handle will be an arc.
4. **Lid**: The lid can be a circle, and the knob can be a smaller circle positioned on top of the lid.
First, let’s define the body of the teapot.
### Step 1: Define the Body of the Teapot
```python
from AIDL import *
def fancy_teapot(
body_width: float = 6 * inches,
body_height: float = 4 * inches,
corner_radius: float = 1 * inches
):
"""
Model a fancy teapot with a rounded rectangular body,
a spout, a handle, and a lid with a knob.
"""
# Define the model structure
teapot = Solid()
# Define the body geometry
teapot.body = RoundedRectangle((0, 0), body_width, body_height, corner_radius)
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
This code creates a rounded rectangular body for the teapot.
### Step 2: Add the Spout
Now let’s add a spout to the body. The spout will be a truncated cone shape, approximated by a series of straight lines and arcs.
```python
from AIDL import *
def fancy_teapot(
body_width: float = 6 * inches,
body_height: float = 4 * inches,
corner_radius: float = 1 * inches,
spout_length: float = 3 * inches,
spout_width: float = 1 * inches
):
teapot = Solid()
# Body
teapot.body = RoundedRectangle((0, 0), body_width, body_height, corner_radius)
# Spout
spout = Solid(shift=(body_width/2, body_height/4))
teapot.spout = spout
spout.base = Rectangle((spout_length/2, 0), spout_length, spout_width)
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
### Step 3: Add the Handle
Next, we’ll add a handle in the form of an arc on the opposite side of the spout.
```python
from AIDL import *
def fancy_teapot(
body_width: float = 6 * inches,
body_height: float = 4 * inches,
corner_radius: float = 1 * inches,
spout_length: float = 3 * inches,
spout_width: float = 1 * inches,
handle_radius: float = 2 * inches,
handle_thickness: float = 0.5 * inches
):
teapot = Solid()
# Body
teapot.body = RoundedRectangle((0, 0), body_width, body_height, corner_radius)
# Spout
spout = Solid(shift=(body_width/2, body_height/4))
teapot.spout = spout
spout.base = Rectangle((spout_length/2, 0), spout_length, spout_width)
# Handle
handle = Solid(shift=(-body_width/2, body_height/4))
teapot.handle = handle
handle.outer_arc = Arc((0,0), 0, 180, handle_radius)
handle.inner_arc = Arc((0,0), 0, 180, handle_radius - handle_thickness)
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
### Step 4: Add the Lid and Knob
Lastly, we’ll add a lid and a knob on top of the body.
```python
from AIDL import *
def fancy_teapot(
body_width: float = 6 * inches,
body_height: float = 4 * inches,
corner_radius: float = 1 * inches,
spout_length: float = 3 * inches,
spout_width: float = 1 * inches,
handle_radius: float = 2 * inches,
handle_thickness: float = 0.5 * inches,
lid_radius: float = 2 * inches,
knob_radius: float = 0.5 * inches
):
teapot = Solid()
# Body
teapot.body = RoundedRectangle((0, 0), body_width, body_height, corner_radius)
# Spout
spout = Solid(shift=(body_width/2, body_height/4))
teapot.spout = spout
spout.base = Rectangle((spout_length/2, 0), spout_length, spout_width)
# Handle
handle = Solid(shift=(-body_width/2, body_height/4))
teapot.handle = handle
handle.outer_arc = Arc((0,0), 0, 180, handle_radius)
handle.inner_arc = Arc((0,0), 0, 180, handle_radius - handle_thickness)
# Lid and Knob
lid = Solid(shift=(0, body_height/2))
teapot.lid = lid
lid.disk = Circle((0, 0), lid_radius)
knob = Solid(shift=(0, 0.5*inches))
lid.knob = knob
knob.disk = Circle((0, 0), knob_radius)
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
This creates a fancy teapot model with a body, spout, handle, lid, and knob. The python function `fancy_teapot` accepts design parameters with reasonable defaults.
You can modify these parameters to customize the teapot to your liking. Please let me know if there are specific details or additional features you’d like to add or modify.
|