Here is a bit of the following flag example:
https://github.com/gumyr/cq_warehouse/blob/main/examples/projection.py
def surface(amplitude, u, v):
"""Calculate the surface displacement of the flag at a given position"""
return v * amplitude / 20 * cos(3.5 * pi * u) + amplitude / 10 * v * sin(
1.1 * pi * v
)
# Note that the surface to project on must be a little larger than the faces
# being projected onto it to create valid projected faces
the_wind = (
cq.Workplane("XY")
.parametricSurface(
lambda u, v: cq.Vector(
width * (v * 1.1 - 0.05),
height * (u * 1.2 - 0.1),
height * surface(wave_amplitude, u, v) / 2,
),
N=40,
)
.thicken(0.5)
.val()
)
Cheers,
Roger