 |
CLIP Score: 20.49
from AIDL import *
def lighthouse(base_radius: float = 2*inch,
tower_height: float = 10*inch,
tower_top_radius: float = 1*inch,
light_room_radius: float = 1.5*inch,
light_room_height: float = 2*inch):
"""
Create a simple model of a lighthouse.
"""
lighthouse = Solid()
# Base
base = Solid()
base.circle = Circle((0, 0), base_radius)
lighthouse.base = base
# Tower - approximation by using a frustum of a cone with polygonal sections
tower = Solid(shift=(0, base_radius + (tower_height / 2)))
base_circle_points = [
(base_radius * cos(angle), base_radius * sin(angle))
for angle in range(0, 360, 30) # Using a 12-sided polygon approx
]
top_circle_points = [
(tower_top_radius * cos(angle), tower_top_radius * sin(angle))
for angle in range(0, 360, 30) # Same polygon pattern at the top, but smaller radius
]
tower.polygons = [Line(base_circle_points[i], top_circle_points[i]) for i in range(len(base_circle_points))]
lighthouse.tower = tower
# Light Room
light_room = Solid(shift=(0, tower_height / 2 + light_room_height / 2 + base_radius))
light_room.circle = Circle((0, 0), light_room_radius)
lighthouse.light_room = light_room
# Optional Details via Drawing nodes (engraving windows and doors)
details = Drawing(shift=(0, 0))
door = Line((-0.5*inch, -light_room_height / 2), (-0.5*inch, light_room_height / 2))
window1 = Line((0.25*inch, 0.5*inch), (0.25*inch, 1*inch))
window2 = Line((0.25*inch + 0.5*inch, 0.5*inch), (0.25*inch + 0.5*inch, 1*inch))
details.door = door
details.window1 = window1
details.window2 = window2
lighthouse.details = details
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a lighthouse
Alright, let's break down the components needed to construct a lighthouse. Typically, a lighthouse has:
1. A base (circular or polygonal)
2. A tapered tower section
3. A light room at the top
4. Possible engravings for details (like windows and doors)
We'll start with a simple model that captures these fundamental components. Let’s create a step-by-step plan:
1. **Base**: A solid circular base.
2. **Tower**: Tapered cylindrical or polygonal tower section.
3. **Light Room**: A circular or polygonal section at the top.
4. **Details**: Optional details for engraving (doors/windows).
Here's the implementation:
```python
from AIDL import *
def lighthouse(base_radius: float = 2*inch,
tower_height: float = 10*inch,
tower_top_radius: float = 1*inch,
light_room_radius: float = 1.5*inch,
light_room_height: float = 2*inch):
"""
Create a simple model of a lighthouse.
"""
lighthouse = Solid()
# Base
base = Solid()
base.circle = Circle((0, 0), base_radius)
lighthouse.base = base
# Tower - approximation by using a frustum of a cone with polygonal sections
tower = Solid(shift=(0, base_radius + (tower_height / 2)))
base_circle_points = [
(base_radius * cos(angle), base_radius * sin(angle))
for angle in range(0, 360, 30) # Using a 12-sided polygon approx
]
top_circle_points = [
(tower_top_radius * cos(angle), tower_top_radius * sin(angle))
for angle in range(0, 360, 30) # Same polygon pattern at the top, but smaller radius
]
tower.polygons = [Line(base_circle_points[i], top_circle_points[i]) for i in range(len(base_circle_points))]
lighthouse.tower = tower
# Light Room
light_room = Solid(shift=(0, tower_height / 2 + light_room_height / 2 + base_radius))
light_room.circle = Circle((0, 0), light_room_radius)
lighthouse.light_room = light_room
# Optional Details via Drawing nodes (engraving windows and doors)
details = Drawing(shift=(0, 0))
door = Line((-0.5*inch, -light_room_height / 2), (-0.5*inch, light_room_height / 2))
window1 = Line((0.25*inch, 0.5*inch), (0.25*inch, 1*inch))
window2 = Line((0.25*inch + 0.5*inch, 0.5*inch), (0.25*inch + 0.5*inch, 1*inch))
details.door = door
details.window1 = window1
details.window2 = window2
lighthouse.details = details
return lighthouse
with AIDL_2D:
model = lighthouse()
print(model.Solve())
model.Render()
```
### Explanation
- **Base**: We define a circular base using the `Circle` primitive.
- **Tower**: To represent the tower, we construct a polygonal frustum (approximating a tapered cylinder) by connecting corresponding points on the base and top circles of the frustum.
- **Light Room**: The top section is modeled as another circle.
- **Details**: Engraving details include lines representing a door and windows.
Please review this initial model layout. If further adjustments or additional features/details are needed, we can iterate on this design.
|