 |
CLIP Score: 26.27
from AIDL import *
def fancy_wine_glass(
base_diameter: float = 3 * inches,
stem_height: float = 6 * inches,
stem_width: float = 0.5 * inches,
bowl_diameter: float = 4 * inches,
bowl_height: float = 5 * inches):
"""
Creates a model of a fancy wine glass which includes a circular base, a rectangular
stem, and a compound bowl. The bowl is defined using arcs to simulate a more
natural curved shape.
"""
wine_glass = Solid()
# Define the base
base = Solid()
base.disk = Circle((0, 0), base_diameter / 2)
wine_glass.base = base
# Define the stem
stem = Solid(shift=(0, stem_height / 2))
stem.shaft = Rectangle((0, 0), stem_width, stem_height)
wine_glass.stem = stem
# Define the bowl
bowl = Solid(shift=(0, stem_height))
bowl.inner_arc = Arc((0, 0), 0, 180, bowl_diameter / 2)
bowl.outer_arc = Arc((0, bowl_height - bowl_diameter / 2), 0, 180, bowl_diameter / 2)
bowl.bottom_line = Line(bowl.inner_arc.end, bowl.outer_arc.start)
wine_glass.bowl = bowl
# Add constraints
# Base and stem are horizontally centered
wine_glass.AddConstraint(base.disk.center.u == stem.shaft.center.u)
# Connect the bowl to the stem
wine_glass.AddConstraint(Coincident(bowl.inner_arc.start, stem.shaft.top))
# Ensure the arcs in the bowl are concentric and smooth
bowl.AddConstraint(Coincident(bowl.inner_arc.center, bowl.outer_arc.center))
bowl.AddConstraint(Distance(bowl.inner_arc.start, bowl.outer_arc.start, stem_width / 2))
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
Sure, I'd be happy to help you create an AIDL program for a fancy wine glass. Let's break down the wine glass into its main components: the base, the stem, and the bowl.
Here's a step-by-step guide:
1. **Define the structure**:
- A wine glass can be divided into three solids: the base, the stem, and the bowl.
2. **Add the geometry**:
- The base can be a circle.
- The stem can be a rectangle.
- The bowl can be a compound shape. For simplicity, we will use two arcs to define the outer and inner contours of the bowl.
3. **Add constraints**:
- The base should be horizontally centered with the stem.
- The stem should be connected to the bowl at their boundary.
Here's a complete AIDL program following these steps:
```python
from AIDL import *
def fancy_wine_glass(
base_diameter: float = 3 * inches,
stem_height: float = 6 * inches,
stem_width: float = 0.5 * inches,
bowl_diameter: float = 4 * inches,
bowl_height: float = 5 * inches):
"""
Creates a model of a fancy wine glass which includes a circular base, a rectangular
stem, and a compound bowl. The bowl is defined using arcs to simulate a more
natural curved shape.
"""
wine_glass = Solid()
# Define the base
base = Solid()
base.disk = Circle((0, 0), base_diameter / 2)
wine_glass.base = base
# Define the stem
stem = Solid(shift=(0, stem_height / 2))
stem.shaft = Rectangle((0, 0), stem_width, stem_height)
wine_glass.stem = stem
# Define the bowl
bowl = Solid(shift=(0, stem_height))
bowl.inner_arc = Arc((0, 0), 0, 180, bowl_diameter / 2)
bowl.outer_arc = Arc((0, bowl_height - bowl_diameter / 2), 0, 180, bowl_diameter / 2)
bowl.bottom_line = Line(bowl.inner_arc.end, bowl.outer_arc.start)
wine_glass.bowl = bowl
# Add constraints
# Base and stem are horizontally centered
wine_glass.AddConstraint(base.disk.center.u == stem.shaft.center.u)
# Connect the bowl to the stem
wine_glass.AddConstraint(Coincident(bowl.inner_arc.start, stem.shaft.top))
# Ensure the arcs in the bowl are concentric and smooth
bowl.AddConstraint(Coincident(bowl.inner_arc.center, bowl.outer_arc.center))
bowl.AddConstraint(Distance(bowl.inner_arc.start, bowl.outer_arc.start, stem_width / 2))
return wine_glass
with AIDL_2D:
model = fancy_wine_glass()
print(model.Solve())
model.Render()
```
In this example:
- The base is a simple **Circle** centered at the origin of its coordinate system.
- The stem is a **Rectangle**, shifted up by half its height because its center is at `(0, 0)` in its local coordinate system.
- The bowl consists of an **inner arc** (the transition boundary from the stem to the bowl), an **outer arc**, and a **bottom line** connecting the arcs.
- Constraints include aligning the base and stem, ensuring concentric arcs for the bowl, and smooth connections.
If you have any modifications or specific features in mind for the wine glass (e.g., fancier curvature for the bowl, adding details for engraving), feel free to let me know!
|