Sine wave to 3D Model

180 views
Skip to first unread message

Adhip

unread,
Sep 22, 2023, 4:47:07 AM9/22/23
to CadQuery
Hello all

I'm trying to create a model using sine wave. My initial thought process is to calculate number of points using the sine wave. Push those points on 2D workplane and then connect them using spline. Close the figure and extrude it as desired.

I wanted to know if there is any better way to do the same? 
Thanks in advance!!

Dov Grobgeld

unread,
Sep 22, 2023, 4:49:46 AM9/22/23
to Adhip, CadQuery
If you compromise and make the perpendicular axis a cosine wave, it get's much easier. ;-)



--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/970e6f85-5cae-4864-906e-16732bd08e25n%40googlegroups.com.

Adhip

unread,
Sep 22, 2023, 5:39:40 AM9/22/23
to CadQuery
What do you mean by converting axis into cosine wave? 

tran chan

unread,
Sep 22, 2023, 6:05:48 AM9/22/23
to Adhip, CadQuery
HI Adhip,

I think u no need to create sine function or model
image.png


Just need to download in link & load those function.




Virus-free.www.avg.com



--
----------------------------------------------------------------

Adam Urbanczyk

unread,
Sep 22, 2023, 1:10:02 PM9/22/23
to CadQuery

Yoululauren

unread,
Sep 22, 2023, 5:42:57 PM9/22/23
to CadQuery
I would use spline for this purpose. It is easier for me to understand. parametricCurve does similar things like spline internally. 
Let's say:

width = math.pi * 2.0
steps = 20
inc = width / steps

pts3 = [(x * width / steps, math.sin(x * width / steps)) for x in range(steps + 1)]

or, if you have nump installed

pts3 = [(x, math.sin(x)) for x in numpy.arange(0, width + inc, inc)]

then,

r3 = (cq.Workplane().spline(pts3))

Using parametricCurve() would be

r2 = (cq.Workplane()
     .parametricCurve(lambda t: (t, math.sin(t), 0.0), steps, 0.0, width, makeWire = False)
     )

*** ***
Given 10 programmers the same spec, they could give you 20 solutions, each and every one of them will work.
I love programming.
*** ***

Adhip

unread,
Sep 23, 2023, 3:26:32 AM9/23/23
to CadQuery
Thanks a lot. I will definitely try this. I'm still learning programming so it helps a lot.
Reply all
Reply to author
Forward
0 new messages