Generate a parametric surface with equations

190 views
Skip to first unread message

sriramakrishna turaga

unread,
Jun 13, 2022, 8:34:36 AM6/13/22
to CadQuery
Hi All

I am new to this tool started learning I would like to generate a parametric surface from equations (please find the below link) and then fill it will solid. 



Request you to help me with sample code and guidance. 

Thanks in advance
Sriramakrishna Turaga

Roger Maitland

unread,
Jun 14, 2022, 12:35:09 PM6/14/22
to CadQuery
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
Reply all
Reply to author
Forward
0 new messages