 |
CLIP Score: 30.93
from AIDL import *
def teapot(
body_radius: float = 3.0*inches,
body_height: float = 5.0*inches,
spout_length: float = 2.0*inches,
handle_width: float = 1.0*inch,
handle_height: float = 3.0*inches,
lid_radius: float = 2.5*inches,
lid_height: float = 1.0*inch
):
"""
Creates a basic teapot with a main body, spout, lid, and handle.
"""
# Structures
teapot = Solid()
body = Solid()
lid = Solid()
spout = Solid()
handle = Solid()
# Hierarchical Relationships
teapot.body = body
teapot.lid = lid
teapot.spout = spout
teapot.handle = handle
# Compositional Constraints
teapot.AddConstraint(body.bb.horizontal_center == teapot.bb.horizontal_center)
teapot.AddConstraint(lid.bb.horizontal_center == body.bb.horizontal_center)
teapot.AddConstraint(lid.bb.bottom == body.bb.top)
teapot.AddConstraint(spout.bb.horizontal_center == body.bb.horizontal_center + body_radius)
teapot.AddConstraint(spout.bb.vertical_center == body.bb.vertical_center + (body_height/4))
teapot.AddConstraint(handle.bb.horizontal_center == body.bb.horizontal_center - body_radius)
teapot.AddConstraint(handle.bb.vertical_center == body.bb.vertical_center)
# Body Geometry
body.main = RoundedRectangle((0, 0), 2*body_radius, body_height, body_radius/5)
# Lid Geometry
lid.base = Circle((0, -lid_height/2), lid_radius)
lid.knob = Circle((0, lid_height/2), lid_radius / 5)
# Spout Geometry
spout.main = RoundedRectangle((0, 0), spout_length, body_radius/2, body_radius/10)
# Handle Geometry
handle.main = Arc((0, 0), 180, 360, body_radius/2)
return teapot
with AIDL_2D:
model = teapot()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a teapot
Creating a teapot using AIDL is a fun and challenging task! Here's a high-level breakdown of the structure and components we might include:
1. **Body**: The main solid part of the teapot.
2. **Lid**: A removable lid, which includes a handle.
3. **Spout**: An attachment that allows pouring liquid.
4. **Handle**: A structure for holding the teapot.
Let's start with the structures and their hierarchical relationships. We will then define the necessary constraints and geometry step-by-step.
Here's the initial approach skeleton for the AIDL program for a teapot:
```python
from AIDL import *
def teapot(
body_radius: float = 3.0*inches,
body_height: float = 5.0*inches,
spout_length: float = 2.0*inches,
handle_width: float = 1.0*inch,
handle_height: float = 3.0*inches,
lid_radius: float = 2.5*inches,
lid_height: float = 1.0*inch
):
"""
Creates a basic teapot with a main body, spout, lid, and handle.
"""
# Structures
teapot = Solid()
body = Solid()
lid = Solid()
spout = Solid()
handle = Solid()
# Hierarchical Relationships
teapot.body = body
teapot.lid = lid
teapot.spout = spout
teapot.handle = handle
# Compositional Constraints
# Align the body, lid, spout, and handle in the frame of the teapot
teapot.AddConstraint(body.bb.horizontal_center == teapot.bb.horizontal_center)
teapot.AddConstraint(lid.bb.horizontal_center == body.bb.horizontal_center)
teapot.AddConstraint(lid.bb.bottom == body.bb.top)
teapot.AddConstraint(spout.bb.horizontal_center == body.bb.horizontal_center + body_radius)
teapot.AddConstraint(spout.bb.vertical_center == body.bb.vertical_center + (body_height/4))
teapot.AddConstraint(handle.bb.horizontal_center == body.bb.horizontal_center - body_radius)
teapot.AddConstraint(handle.bb.vertical_center == body.bb.vertical_center)
return teapot
with AIDL_2D:
model = teapot()
print(model.Solve())
model.Render()
```
This skeleton sets up the basic structure and relationships. Next, we'll define the geometry for each component.
### Geometry and Constraints
1. **Body Geometry**: The main body of the teapot as a rounded rectangle.
2. **Lid Geometry**: The lid will be a circle with a small handle (knob).
3. **Spout Geometry**: The spout is a simple open cylinder.
4. **Handle Geometry**: The handle is an arc.
Here's the extended code with detailed geometry and constraints:
```python
from AIDL import *
def teapot(
body_radius: float = 3.0*inches,
body_height: float = 5.0*inches,
spout_length: float = 2.0*inches,
handle_width: float = 1.0*inch,
handle_height: float = 3.0*inches,
lid_radius: float = 2.5*inches,
lid_height: float = 1.0*inch
):
"""
Creates a basic teapot with a main body, spout, lid, and handle.
"""
# Structures
teapot = Solid()
body = Solid()
lid = Solid()
spout = Solid()
handle = Solid()
# Hierarchical Relationships
teapot.body = body
teapot.lid = lid
teapot.spout = spout
teapot.handle = handle
# Compositional Constraints
teapot.AddConstraint(body.bb.horizontal_center == teapot.bb.horizontal_center)
teapot.AddConstraint(lid.bb.horizontal_center == body.bb.horizontal_center)
teapot.AddConstraint(lid.bb.bottom == body.bb.top)
teapot.AddConstraint(spout.bb.horizontal_center == body.bb.horizontal_center + body_radius)
teapot.AddConstraint(spout.bb.vertical_center == body.bb.vertical_center + (body_height/4))
teapot.AddConstraint(handle.bb.horizontal_center == body.bb.horizontal_center - body_radius)
teapot.AddConstraint(handle.bb.vertical_center == body.bb.vertical_center)
# Body Geometry
body.main = RoundedRectangle((0, 0), 2*body_radius, body_height, body_radius/5)
# Lid Geometry
lid.base = Circle((0, -lid_height/2), lid_radius)
lid.knob = Circle((0, lid_height/2), lid_radius / 5)
# Spout Geometry
spout.main = RoundedRectangle((0, 0), spout_length, body_radius/2, body_radius/10)
# Handle Geometry
handle.main = Arc((0, 0), 180, 360, body_radius/2)
return teapot
with AIDL_2D:
model = teapot()
print(model.Solve())
model.Render()
```
This code should provide a basic visualization of a teapot with a body, lid, spout, and handle. Each component has its own geometry and constraints to ensure proper alignment.
If you have specific dimensions, shapes, or additional features in mind, let me know, and we can refine the model further.
|