 |
CLIP Score: 26.74
from AIDL import *
from math import pi, sin, cos
def fancy_wine_glass(
bowl_radius: float = 2.5*inches,
bowl_height: float = 5*inches,
stem_height: float = 3*inches,
stem_width: float = 0.5*inches,
base_radius: float = 3*inches
):
"""
Create a model of a fancy wine glass with engraved details on the bowl.
"""
wine_glass = Solid()
# Define the bowl
bowl = Solid(shift=(0, stem_height + bowl_height / 2))
wine_glass.bowl = bowl
# Bowl geometry using a series of arcs and lines to create a rounded shape
bowl_outline = Solid()
bowl.outline = bowl_outline
bowl_outline.lower_arc = Arc((0, -bowl_height / 2), (-bowl_radius, -bowl_height / 3), (bowl_radius, -bowl_height / 3))
bowl_outline.upper_arc = Arc((0, bowl_height / 2), (-bowl_radius, bowl_height / 3), (bowl_radius, bowl_height / 3))
bowl_outline.left_side = Line(bowl_outline.lower_arc.start, bowl_outline.upper_arc.start)
bowl_outline.right_side = Line(bowl_outline.upper_arc.end, bowl_outline.lower_arc.end)
# Define the stem
stem = Solid(shift=(0, stem_height / 2))
wine_glass.stem = stem
# Stem geometry
stem.body = RoundedRectangle((0, 0), stem_width, stem_height, stem_width / 6)
# Define the base
base = Solid(shift=(0, -stem_height / 2))
wine_glass.base = base
# Base geometry
base.disk = Circle((0, 0), base_radius)
# Fancy details (engraving) on the bowl
engravings = Drawing()
bowl.engravings = engravings
engraving_lines = 10 # Number of engraving lines
engraving_radius = bowl_radius * 0.9 # Slightly smaller radius than bowl
engravings.lines = [
Line(
(engraving_radius * cos(2 * pi * i / engraving_lines), engraving_radius * sin(2 * pi * i / engraving_lines)),
(engraving_radius * cos(2 * pi * (i + 1) / engraving_lines), engraving_radius * sin(2 * pi * (i + 1) / engraving_lines))
) for i in range(engraving_lines)
]
return wine_glass
with AIDL_2D:
model = fancy_wine_glass()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a fancy wine glass
Certainly! Let's start by laying out the components of a fancy wine glass. We'll break it down into these parts:
1. **Bowl**: The upper part of the glass that holds the wine.
2. **Stem**: The slender part you hold.
3. **Base**: The bottom of the glass that keeps it stable.
We'll add some details to make it more "fancy", which might include engraved lines on the bowl or a slightly curved shape to the stem.
Here's a step-by-step approach to create this wine glass in AIDL:
### 1. Define the Bowl
The bowl can be defined using a combination of arcs and lines to give it a smooth, rounded shape.
### 2. Define the Stem
The stem can be a simple rectangle or slightly curved for a more fancy look.
### 3. Define the Base
The base can be a circular shape with maybe an extra ring engraving for fanciness.
### 4. Combining All Components
We'll combine these components into a Solid structure with appropriate shifts to align everything.
Here's the full code:
```python
from AIDL import *
from math import pi, sin, cos
def fancy_wine_glass(
bowl_radius: float = 2.5*inches,
bowl_height: float = 5*inches,
stem_height: float = 3*inches,
stem_width: float = 0.5*inches,
base_radius: float = 3*inches
):
"""
Create a model of a fancy wine glass with engraved details on the bowl.
"""
wine_glass = Solid()
# Define the bowl
bowl = Solid(shift=(0, stem_height + bowl_height / 2))
wine_glass.bowl = bowl
# Bowl geometry using a series of arcs and lines to create a rounded shape
bowl_outline = Solid()
bowl.outline = bowl_outline
bowl_outline.lower_arc = Arc((0, -bowl_height / 2), (-bowl_radius, -bowl_height / 3), (bowl_radius, -bowl_height / 3))
bowl_outline.upper_arc = Arc((0, bowl_height / 2), (-bowl_radius, bowl_height / 3), (bowl_radius, bowl_height / 3))
bowl_outline.left_side = Line(bowl_outline.lower_arc.start, bowl_outline.upper_arc.start)
bowl_outline.right_side = Line(bowl_outline.upper_arc.end, bowl_outline.lower_arc.end)
# Define the stem
stem = Solid(shift=(0, stem_height / 2))
wine_glass.stem = stem
# Stem geometry
stem.body = RoundedRectangle((0, 0), stem_width, stem_height, stem_width / 6)
# Define the base
base = Solid(shift=(0, -stem_height / 2))
wine_glass.base = base
# Base geometry
base.disk = Circle((0, 0), base_radius)
# Fancy details (engraving) on the bowl
engravings = Drawing()
bowl.engravings = engravings
engraving_lines = 10 # Number of engraving lines
engraving_radius = bowl_radius * 0.9 # Slightly smaller radius than bowl
engravings.lines = [
Line(
(engraving_radius * cos(2 * pi * i / engraving_lines), engraving_radius * sin(2 * pi * i / engraving_lines)),
(engraving_radius * cos(2 * pi * (i + 1) / engraving_lines), engraving_radius * sin(2 * pi * (i + 1) / engraving_lines))
) for i in range(engraving_lines)
]
return wine_glass
with AIDL_2D:
model = fancy_wine_glass()
print(model.Solve())
model.Render()
```
This program defines a fancy wine glass with the bowl, stem, and base. Fancy engraving lines are added on the bowl to make it look elegant. The model can be adjusted by changing the default parameters, such as the radii and heights of the components.
|