 |
CLIP Score: 28.69
from AIDL import *
def lighthouse(tower_radius: float = 3*inches,
tower_height: float = 10*inches,
roof_height: float = 3*inches,
door_width: float = 1*inch,
window_width: float = 0.5*inch):
"""
Creates a simple lighthouse model with a cylindrical tower, conical roof,
and rectangular windows. The tower has a door at the base.
"""
lighthouse = Solid()
tower = Solid(shift=(0,0))
roof = Solid(shift=(0, tower_height))
lighthouse.tower = tower
lighthouse.roof = roof
# Define the tower's body geometry. It is a simple rectangle representing the side view of the cylinder.
tower.body = Rectangle((0,0), 2*tower_radius, tower_height)
# Define the roof's body geometry. It will be an isosceles triangle representing the cone in 2D.
roof.body = Triangle((0, -roof_height/2), 2*tower_radius, roof_height)
# Create various openings (windows and door) in the tower
door = Hole(shift=(0, -tower_height/2 + door_width/2))
windows = Hole()
tower.door = door
tower.windows = windows
door.rect = Rectangle((0,0), door_width, 1.5*door_width)
# Position windows evenly along the height of the tower
num_windows = 4
for i in range(num_windows):
window_shift = (0, -tower_height/2 + tower_height*(i + 1)/(num_windows + 1))
window = Rectangle(window_shift, window_width, window_width)
setattr(windows, f'window_{i}', window)
# Add circular hole at the top of the roof for the light
roof.light_opening = Hole()
roof.light_opening.hole = Circle((0, roof_height/2 - tower_radius/4), tower_radius/4)
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a lighthouse
Sure! Let's create a model of a simple lighthouse. The design will consist of a main cylindrical tower, a conical roof, and rectangular windows. The tower will have a door at the base, and small windows along its height. The roof will have a small circular hole at the top to represent the lighthouse's light.
Here's the initial design breakdown:
- **Tower**: A cylinder with a door near the base and several small windows.
- **Roof**: A cone on top of the tower with a circular hole (for the light).
- **Windows**: Small rectangular shapes cut out of the tower at different heights.
Let's start implementing this step-by-step:
1. **Main Tower Structure**:
2. **Roof Structure**:
3. **Windows and Door**:
4. **Holes for the Windows and Door**:
5. **Combining All Parts into the Lighthouse Model**:
```python
from AIDL import *
def lighthouse(tower_radius: float = 3*inches,
tower_height: float = 10*inches,
roof_height: float = 3*inches,
door_width: float = 1*inch,
window_width: float = 0.5*inch):
"""
Creates a simple lighthouse model with a cylindrical tower, conical roof,
and rectangular windows. The tower has a door at the base.
"""
lighthouse = Solid()
tower = Solid(shift=(0,0))
roof = Solid(shift=(0, tower_height))
lighthouse.tower = tower
lighthouse.roof = roof
# Define the tower's body geometry. It is a simple rectangle representing the side view of the cylinder.
tower.body = Rectangle((0,0), 2*tower_radius, tower_height)
# Define the roof's body geometry. It will be an isosceles triangle representing the cone in 2D.
roof.body = Triangle((0, -roof_height/2), 2*tower_radius, roof_height)
# Create various openings (windows and door) in the tower
door = Hole(shift=(0, -tower_height/2 + door_width/2))
windows = Hole()
tower.door = door
tower.windows = windows
door.rect = Rectangle((0,0), door_width, 1.5*door_width)
# Position windows evenly along the height of the tower
num_windows = 4
for i in range(num_windows):
window_shift = (0, -tower_height/2 + tower_height*(i + 1)/(num_windows + 1))
window = Rectangle(window_shift, window_width, window_width)
setattr(windows, f'window_{i}', window)
# Add circular hole at the top of the roof for the light
roof.light_opening = Hole()
roof.light_opening.hole = Circle((0, roof_height/2 - tower_radius/4), tower_radius/4)
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
```
This script defines a lighthouse with a cylindrical tower, conical roof, rectangular door, and windows. The lighthouse model has been divided into a tower and a roof, with respective openings for the door and windows on the tower, and a small circular hole on the roof to represent the lighthouse light.
Let me know if you need any adjustments or additional features!
|