 |
CLIP Score: 33.69
from AIDL import *
def fish(
body_length: float = 6 * inches,
body_height: float = 3 * inches,
tail_width: float = 2 * inches,
tail_height: float = 4 * inches,
fin_length: float = 1.5 * inches,
eye_radius: float = 0.25 * inches
):
"""
Model a fish with an oval body, triangular tail, triangular fins, and eye.
"""
# Define the model structure
fish = Solid()
# Body structure as an ellipse
fish.body = Solid()
# Tail structure
fish.tail = Solid(shift=(body_length / 2 + tail_width / 2, 0))
# Top fin structure
fish.top_fin = Solid(shift=(0, -body_height / 2))
# Bottom fin structure
fish.bottom_fin = Solid(shift=(0, body_height / 2))
# Eye structure
fish.eye = Solid(shift=(-body_length / 4, -body_height / 4))
# Body geometry: an ellipse (approximated by a rounded rectangle with a large corner radius).
fish.body.ellipse = RoundedRectangle((0, 0), body_length, body_height, body_height / 2)
# Tail geometry
fish.tail.left = Line((-tail_width / 2, 0), (tail_width / 2, -tail_height / 2))
fish.tail.right = Line((-tail_width / 2, 0), (tail_width / 2, tail_height / 2))
fish.tail.base = Line((tail_width / 2, tail_height / 2), (tail_width / 2, -tail_height / 2))
# Top fin geometry
fish.top_fin.left = Line((0, 0), (fin_length, -fin_length / 2))
fish.top_fin.right = Line((0, 0), (fin_length, fin_length / 2))
fish.top_fin.base = Line((fin_length, -fin_length / 2), (fin_length, fin_length / 2))
# Bottom fin geometry
fish.bottom_fin.left = Line((0, 0), (fin_length, -fin_length / 2))
fish.bottom_fin.right = Line((0, 0), (fin_length, fin_length / 2))
fish.bottom_fin.base = Line((fin_length, -fin_length / 2), (fin_length, fin_length / 2))
# Eye geometry
fish.eye.pupil = Circle((0, 0), eye_radius)
# Add constraints to the tail so it is centered vertically.
fish.tail.AddConstraint(fish.tail.base.midpoint.v == 0)
# Add constraints to the top and bottom fins so they are centered horizontally.
fish.top_fin.AddConstraint(fish.top_fin.base.midpoint.u == fish.top_fin.left.start.u)
fish.bottom_fin.AddConstraint(fish.bottom_fin.base.midpoint.u == fish.bottom_fin.left.start.u)
return fish
with AIDL_2D:
model = fish()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a fish
Sure! Let's start by breaking down the design of a fish into several parts: the body, the tail, the fins, and potentially the eye. Given the structure of the AIDL language, we can model each of these as separate geometrical shapes combined into a hierarchical structure.
Here's a possible high-level plan:
1. **Body**: A rounded rectangle or ellipse.
2. **Tail**: A triangle or right triangle.
3. **Fins**: Triangles for the top and bottom fins.
4. **Eye**: A small circle.
Let's start designing the fish step by step.
### Fish Body and Tail
We'll first create the body of the fish and then add the tail.
#### 1. Fish Body
We'll use an ellipse for the body for a more natural look.
#### 2. Fish Tail
We'll use triangles for the tail geometry.
#### 3. Fins
We'll add top and bottom fins as triangle shapes.
#### 4. Eye
We'll add the eye as a small circle.
Let's proceed to write the code for the fish:
```python
from AIDL import *
def fish(
body_length: float = 6 * inches,
body_height: float = 3 * inches,
tail_width: float = 2 * inches,
tail_height: float = 4 * inches,
fin_length: float = 1.5 * inches,
eye_radius: float = 0.25 * inches
):
"""
Model a fish with an oval body, triangular tail, triangular fins, and eye.
"""
# Define the model structure
fish = Solid()
# Body structure as an ellipse
fish.body = Solid()
# Tail structure
fish.tail = Solid(shift=(body_length / 2 + tail_width / 2, 0))
# Top fin structure
fish.top_fin = Solid(shift=(0, -body_height / 2))
# Bottom fin structure
fish.bottom_fin = Solid(shift=(0, body_height / 2))
# Eye structure
fish.eye = Solid(shift=(-body_length / 4, -body_height / 4))
# Body geometry: an ellipse (approximated by a rounded rectangle with a large corner radius).
fish.body.ellipse = RoundedRectangle((0, 0), body_length, body_height, body_height / 2)
# Tail geometry
fish.tail.left = Line((-tail_width / 2, 0), (tail_width / 2, -tail_height / 2))
fish.tail.right = Line((-tail_width / 2, 0), (tail_width / 2, tail_height / 2))
fish.tail.base = Line((tail_width / 2, tail_height / 2), (tail_width / 2, -tail_height / 2))
# Top fin geometry
fish.top_fin.left = Line((0, 0), (fin_length, -fin_length / 2))
fish.top_fin.right = Line((0, 0), (fin_length, fin_length / 2))
fish.top_fin.base = Line((fin_length, -fin_length / 2), (fin_length, fin_length / 2))
# Bottom fin geometry
fish.bottom_fin.left = Line((0, 0), (fin_length, -fin_length / 2))
fish.bottom_fin.right = Line((0, 0), (fin_length, fin_length / 2))
fish.bottom_fin.base = Line((fin_length, -fin_length / 2), (fin_length, fin_length / 2))
# Eye geometry
fish.eye.pupil = Circle((0, 0), eye_radius)
# Add constraints to the tail so it is centered vertically.
fish.tail.AddConstraint(fish.tail.base.midpoint.v == 0)
# Add constraints to the top and bottom fins so they are centered horizontally.
fish.top_fin.AddConstraint(fish.top_fin.base.midpoint.u == fish.top_fin.left.start.u)
fish.bottom_fin.AddConstraint(fish.bottom_fin.base.midpoint.u == fish.bottom_fin.left.start.u)
return fish
with AIDL_2D:
model = fish()
print(model.Solve())
model.Render()
```
This code defines a fish by modeling its body as an ellipse, the tail as a triangle, the top and bottom fins as triangles, and the eye as a circle. It adds constraints to ensure the fish parts are aligned correctly.
Feel free to adjust any dimensions or shapes to better match the design you have in mind. Let me know if you need any adjustments or additional features!
|