openscad / list-comprehension-demos

106 stars 34 forks source link

Smoother augment_profile #10

Open jacekkopecky opened 5 years ago

jacekkopecky commented 5 years ago

augment_profile in skin.scad inserts new vertices in a profile so that the result has a given number of vertices. Currently, the order of insertions is not specified, and in some cases the new vertices cause distortion.

This profile (in context of extrusion.scad) demonstrates the issue: the cylinder is visibly distorted:

// profiles that have different vertex counts
skin([
    transform(translation([0,0,0]), circle($fn=70,r=1)),
    transform(translation([0,0,1]), circle($fn=75,r=1)),
    transform(translation([0,0,2]), circle($fn=100,r=1)),
]);

This image shows the distortion.

screen shot 2018-12-25 at 14 50 39

The example above is artificial, but the issue comes up when combining profiles that you naturally produce with different vertex counts.

This pull requests introduces insert_extra_vertices_1 which distributes new vertices uniformly around the length of the profile, resulting in much smaller distortions.

I'll be happy to polish the code if need be.

jacekkopecky commented 5 years ago

Hi, do we have any maintainers here please? I know no commits happened in over 3 years, but maybe?

OskarLinde commented 5 years ago

Thanks for submitting. This looks like a reasonable approach. (note that both this and the original code are quite inefficient – there are better ways to do it)

Have you verified that none of the samples degrade by taking this approach?

jacekkopecky commented 5 years ago

Hi, thanks; I'll do that but need a few more weeks before I get to it due to $dayjob.

jacekkopecky commented 5 years ago

Hi, yes, I can now confirm that all the other examples in this repo that use skin work correctly.