 |
CLIP Score: 27.69
from AIDL import *
def teapot(
body_height: float = 6 * inches,
body_diameter: float = 4 * inches,
lid_height: float = 1 * inch,
spout_height: float = 2 * inches,
handle_height: float = 3 * inches
):
teapot = Solid()
# Body
body = Solid()
teapot.body = body
body_base = Circle((0, 0), body_diameter / 2)
body_side = Rectangle((0, body_height / 2), body_diameter, body_height, axis_aligned=False)
body.base = body_base
body.side = body_side
# Lid
lid = Solid(shift=(0, body_height))
teapot.lid = lid
lid_circle = Circle((0, 0), body_diameter / 2.2)
lid_knob = Circle((0, lid_height / 2), body_diameter / 5)
lid.circle = lid_circle
lid.knob = lid_knob
# Spout
spout = Solid(shift=(body_diameter / 2, body_height / 2))
teapot.spout = spout
spout_base = Circle((0, 0), spout_height / 2)
spout_cone = Rectangle((spout_height / 2, 0), spout_height, spout_height / 2)
spout.base = spout_base
spout.cone = spout_cone
# Handle
handle = Solid(shift=(-body_diameter / 2, body_height / 2))
teapot.handle = handle
handle_arc = Arc((0, 0), (-body_diameter, body_height / 2), (0, body_height))
handle.arc = handle_arc
return teapot
with AIDL_2D:
model = teapot()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a teapot
Sure, let's get started on generating a teapot model in AIDL. Here’s how we can break down the design:
1. **Body**: The main container of the teapot.
2. **Lid**: The lid of the teapot.
3. **Spout**: The spout from which the tea is poured.
4. **Handle**: The handle for holding the teapot.
Let's assume some default sizes and shapes for simplicity:
1. **Body**: A cylindrical shape with a rounded bottom.
2. **Lid**: A smaller circular shape that fits on top of the body with a little knob on top.
3. **Spout**: A conical shape protruding from the side of the body.
4. **Handle**: A semicircular arc attached to the back of the body.
Here’s the complete AIDL program:
```python
from AIDL import *
def teapot(
body_height: float = 6 * inches,
body_diameter: float = 4 * inches,
lid_height: float = 1 * inch,
spout_height: float = 2 * inches,
handle_height: float = 3 * inches
):
teapot = Solid()
# Body
body = Solid()
teapot.body = body
body_base = Circle((0, 0), body_diameter / 2)
body_side = Rectangle((0, body_height / 2), body_diameter, body_height, axis_aligned=False)
body.base = body_base
body.side = body_side
# Lid
lid = Solid(shift=(0, body_height))
teapot.lid = lid
lid_circle = Circle((0, 0), body_diameter / 2.2)
lid_knob = Circle((0, lid_height / 2), body_diameter / 5)
lid.circle = lid_circle
lid.knob = lid_knob
# Spout
spout = Solid(shift=(body_diameter / 2, body_height / 2))
teapot.spout = spout
spout_base = Circle((0, 0), spout_height / 2)
spout_cone = Rectangle((spout_height / 2, 0), spout_height, spout_height / 2)
spout.base = spout_base
spout.cone = spout_cone
# Handle
handle = Solid(shift=(-body_diameter / 2, body_height / 2))
teapot.handle = handle
handle_arc = Arc((0, 0), (-body_diameter, body_height / 2), (0, body_height))
handle.arc = handle_arc
return teapot
with AIDL_2D:
model = teapot()
print(model.Solve())
model.Render()
```
### Explanation:
1. **Body**:
- `body_base`: A circle at the bottom with the radius `body_diameter / 2`.
- `body_side`: A vertical rectangle representing the side of the body. Adjusted to align the center.
2. **Lid**:
- `lid_circle`: A smaller circle on top of the body to represent the lid.
- `lid_knob`: A small circle on top of the lid to represent the knob.
3. **Spout**:
- `spout_base`: A circular base for the spout.
- `spout_cone`: A rectangle to represent the conical shape of the spout.
4. **Handle**:
- `handle_arc`: An arc representing the handle.
Each part is added to the `teapot` structure and positioned relative to each other using the `shift` parameter.
Let me know if you need any adjustments or further details!
|