Tagged: polyline2polygon, path, reparemeterize, curve
 This topic has 6 replies, 3 voices, and was last updated 4 years, 3 months ago by paul.

AuthorPosts

14 February 2019 at 11:43 #5407hiteshnazcaParticipant
Hi everyone,
I am designing a waveguide which needs to have some holes (or rectangles) defined close to the waveguide. The holes need a period and also needs to go along the waveguide around the bends. I have an image attached below.
Could someone please guide me on how to achieve this on nazca?
Thanks.
Best,
Hitesh
15 February 2019 at 00:26 #5412RonaldKeymasterDear Hitesh,
It seems to me that the center path of the waveguide has to be defined like a polyline and a function is needed similar to the nazca internal function ‘polyline2polygon’ to add a width to the line. A width for the edge of the waveguide and a width for the path on which the circles/squares are to be placed. In curves some care needs to be taken for the distance of the circles on their path on the in and outside, I guess. No magic bullet, but no showstoppers either.
Ronald
25 June 2019 at 02:12 #5616paulMemberHi,
I would also be interested in designing something similar to this. How would you place the circle/squares along the path once it’s been created?
At the moment i’m thinking of using the nazca geometries library to create the shapes but I don’t see how I could place them periodically along a parametric path.
cheers,
Paul
25 June 2019 at 11:07 #5617RonaldKeymaster27 June 2019 at 17:00 #5622paulMemberThanks Ronald,
I have found a quick and ugly way of doing it by calculating the line integral along the path. Whenever the distance gets bigger than an multiple of my desired spacing, I place the desired geometry. This works as long as the curve is defined with enough points.
xy = nd.curve2polyline(nd.sinebend_point, (100, 20, 0), 0.0001, (100, 20)) x, y = map(list, zip(*xy)) dl = 0 # element of length lint = 0 # total integral k = 1 spacing = 10 # desired spacing for i in range(1, len(y)): dl = np.sqrt((x[i]  x[i  1]) ** 2 + (y[i]  y[i  1]) ** 2) lint += dl if lint > k * spacing: hole.put(x[i], y[i]) k += 1 nd.export_plt()
28 June 2019 at 10:31 #5631RonaldKeymasterDear Paul,
That is a good first step. The question is what accuracy do you need? Reusing available modules may save you time and you may, therefore, look into computer vision and animation where arc length on a parametric curve is common (to determine the speed of a camera or other object for example).
See for example opencv:
https://pypi.org/project/opencvpython/
https://opencv.org/opencv248/Ronald
28 June 2019 at 10:51 #5633paulMemberHi Ronald,
That’s a very good question, as I know that my current solution will only get me this far. But as you said it’s a first step and it allows me to push on with my design. What I like though, is that it should work for any path, not just the sbend shown here.
I’m still planning on looking at parametrizing the curve by arc length once I have more time. Will post the outcome here if successful.Cheers,
Paul

AuthorPosts
 You must be logged in to reply to this topic.