 |
CLIP Score: 29.06
from AIDL import *
def fancy_teapot(
body_radius = 4*inches,
body_height = 5*inches,
spout_length = 3*inches,
handle_width = 1*inch,
handle_height = 3*inches,
lid_radius = 2*inches,
lid_height = 1*inch):
teapot = Solid()
teapot.body = Solid()
teapot.spout = Solid(shift=(body_radius, body_height / 2))
teapot.handle = Solid(shift=(-body_radius - handle_width, body_height / 2))
teapot.lid = Solid(shift=(0, body_height))
teapot.body.ellipse = RoundedRectangle((0,0), 2*body_radius, body_height, body_radius/2)
spout_outer = [
Line((0,0), (spout_length/2, spout_length/4)),
Arc((spout_length/2, spout_length/4), start_angle=0, end_angle=90, radius=spout_length/2)
]
spout_inner = [
Line((0,0), (spout_length/3, spout_length/6)),
Arc((spout_length/3, spout_length/6), start_angle=0, end_angle=90, radius=spout_length/3)
]
teapot.spout.spout_outer = spout_outer
teapot.spout.spout_inner = spout_inner
teapot.handle.outer_arc = Arc((0, 0), start_angle=180, end_angle=0, radius=handle_height)
teapot.handle.inner_arc = Arc((0, handle_width/2), start_angle=180, end_angle=0, radius=handle_height - handle_width)
teapot.lid.disk = Circle((0, 0), lid_radius)
teapot.lid.knob = Circle((0, lid_height), lid_radius / 2)
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 break down the design of a fancy teapot into manageable components such as the body, spout, handle, and lid. We'll start with the basic structure and then refine the geometry details step-by-step.
### Step 1: Define the Teapot Structure
We will define the main structure of the teapot with substructures for the body, spout, handle, and lid. Here is a basic outline:
```python
from AIDL import *
def fancy_teapot(
body_radius = 4*inches,
body_height = 5*inches,
spout_length = 3*inches,
handle_width = 1*inch,
handle_height = 3*inches,
lid_radius = 2*inches,
lid_height = 1*inch):
teapot = Solid()
teapot.body = Solid()
teapot.spout = Solid(shift=(body_radius, body_height / 2))
teapot.handle = Solid(shift=(-body_radius - handle_width, body_height / 2))
teapot.lid = Solid(shift=(0, body_height))
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
This initial structure creates the main components of the teapot. Next, let's proceed to define the geometry for each of these components.
### Step 2: Define the Body Geometry
The body of the teapot can be a simple ellipse representing its round shape:
```python
from AIDL import *
def fancy_teapot(
body_radius = 4*inches,
body_height = 5*inches,
spout_length = 3*inches,
handle_width = 1*inch,
handle_height = 3*inches,
lid_radius = 2*inches,
lid_height = 1*inch):
teapot = Solid()
teapot.body = Solid()
teapot.spout = Solid(shift=(body_radius, body_height / 2))
teapot.handle = Solid(shift=(-body_radius - handle_width, body_height / 2))
teapot.lid = Solid(shift=(0, body_height))
teapot.body.ellipse = RoundedRectangle((0,0), 2*body_radius, body_height, body_radius/2)
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
### Step 3: Define the Spout Geometry
The spout of the teapot can be represented with a combination of lines and arcs to create a gentle curve:
```python
from AIDL import *
def fancy_teapot(
body_radius = 4*inches,
body_height = 5*inches,
spout_length = 3*inches,
handle_width = 1*inch,
handle_height = 3*inches,
lid_radius = 2*inches,
lid_height = 1*inch):
teapot = Solid()
teapot.body = Solid()
teapot.spout = Solid(shift=(body_radius, body_height / 2))
teapot.handle = Solid(shift=(-body_radius - handle_width, body_height / 2))
teapot.lid = Solid(shift=(0, body_height))
teapot.body.ellipse = RoundedRectangle((0,0), 2*body_radius, body_height, body_radius/2)
spout_outer = [
Line((0,0), (spout_length/2, spout_length/4)),
Arc((spout_length/2, spout_length/4), start_angle=0, end_angle=90, radius=spout_length/2)
]
spout_inner = [
Line((0,0), (spout_length/3, spout_length/6)),
Arc((spout_length/3, spout_length/6), start_angle=0, end_angle=90, radius=spout_length/3)
]
teapot.spout.spout_outer = spout_outer
teapot.spout.spout_inner = spout_inner
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
### Step 4: Define the Handle Geometry
The handle can be created with an arc for the outer edge and scaled-down arc for the inner edge:
```python
from AIDL import *
def fancy_teapot(
body_radius = 4*inches,
body_height = 5*inches,
spout_length = 3*inches,
handle_width = 1*inch,
handle_height = 3*inches,
lid_radius = 2*inches,
lid_height = 1*inch):
teapot = Solid()
teapot.body = Solid()
teapot.spout = Solid(shift=(body_radius, body_height / 2))
teapot.handle = Solid(shift=(-body_radius - handle_width, body_height / 2))
teapot.lid = Solid(shift=(0, body_height))
teapot.body.ellipse = RoundedRectangle((0,0), 2*body_radius, body_height, body_radius/2)
spout_outer = [
Line((0,0), (spout_length/2, spout_length/4)),
Arc((spout_length/2, spout_length/4), start_angle=0, end_angle=90, radius=spout_length/2)
]
spout_inner = [
Line((0,0), (spout_length/3, spout_length/6)),
Arc((spout_length/3, spout_length/6), start_angle=0, end_angle=90, radius=spout_length/3)
]
teapot.spout.spout_outer = spout_outer
teapot.spout.spout_inner = spout_inner
teapot.handle.outer_arc = Arc((0, 0), start_angle=180, end_angle=0, radius=handle_height)
teapot.handle.inner_arc = Arc((0, handle_width/2), start_angle=180, end_angle=0, radius=handle_height - handle_width)
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
### Step 5: Define the Lid Geometry
The lid can be created as a circle with a small knob on top:
```python
from AIDL import *
def fancy_teapot(
body_radius = 4*inches,
body_height = 5*inches,
spout_length = 3*inches,
handle_width = 1*inch,
handle_height = 3*inches,
lid_radius = 2*inches,
lid_height = 1*inch):
teapot = Solid()
teapot.body = Solid()
teapot.spout = Solid(shift=(body_radius, body_height / 2))
teapot.handle = Solid(shift=(-body_radius - handle_width, body_height / 2))
teapot.lid = Solid(shift=(0, body_height))
teapot.body.ellipse = RoundedRectangle((0,0), 2*body_radius, body_height, body_radius/2)
spout_outer = [
Line((0,0), (spout_length/2, spout_length/4)),
Arc((spout_length/2, spout_length/4), start_angle=0, end_angle=90, radius=spout_length/2)
]
spout_inner = [
Line((0,0), (spout_length/3, spout_length/6)),
Arc((spout_length/3, spout_length/6), start_angle=0, end_angle=90, radius=spout_length/3)
]
teapot.spout.spout_outer = spout_outer
teapot.spout.spout_inner = spout_inner
teapot.handle.outer_arc = Arc((0, 0), start_angle=180, end_angle=0, radius=handle_height)
teapot.handle.inner_arc = Arc((0, handle_width/2), start_angle=180, end_angle=0, radius=handle_height - handle_width)
teapot.lid.disk = Circle((0, 0), lid_radius)
teapot.lid.knob = Circle((0, lid_height), lid_radius / 2)
return teapot
with AIDL_2D:
model = fancy_teapot()
print(model.Solve())
model.Render()
```
This basic structure can be further refined with additional details if needed; but for now, it represents a fancy teapot with body, spout, handle, and lid. Let me know if you want to add or modify any specific parts or details!
|