list-comprehension-demos icon indicating copy to clipboard operation
list-comprehension-demos copied to clipboard

Difference between sweep() and skin()

Open jgrizou opened this issue 10 years ago • 6 comments

I have been testing the sweep() and skin() function, they are trully amazing. I am still confused about the difference between these two functions. Which is more suited for what? For example, here are two ways to do the same thing:

use <scad-utils/transformations.scad>
use <scad-utils/trajectory_path.scad>
use <scad-utils/trajectory.scad>
use <scad-utils/shapes.scad>

use <skin.scad>
use <sweep.scad>

path_definition = [
trajectory(forward = 10, roll  =  0),
trajectory(forward =  5*3.14159265359, pitch = 180),
trajectory(forward = 10, roll  =  0)
];

// sweep
path = quantize_trajectories(path_definition, steps=100);
sweep(rectangle_profile([2,3]), path);

// skin
trans = [ for (i=[0:len(path)-1]) transform(path[i], rectangle_profile([2,3])) ];

translate([0,10,0])
  skin(trans);

Is there any fundamental differences between these two methods? Do you recommend one of them for this kind of part?

jgrizou avatar Jan 12 '15 20:01 jgrizou

I haven't looked at the code in the examples, but it's probably that sweep is for rigidly transformed profiles, and skin is for more plastic changes in profiles.

There's a discussion about the various ways to handle more general notions of extrusion where it came up.

https://github.com/openscad/openscad/issues/114

NateTG avatar Feb 11 '15 15:02 NateTG

@jgrizou One primary difference is that skin() will be able to skin differently shaped layers, while sweep can only do linear transformations.

kintel avatar Feb 11 '15 15:02 kintel

@jgrizou this is the difference

use <scad-utils/transformations.scad>
use <scad-utils/trajectory_path.scad>
use <scad-utils/trajectory.scad>
use <scad-utils/shapes.scad>

use <list-comprehension-demo/skin.scad>
use <list-comprehension-demo/sweep.scad>

path_definition = [
trajectory(forward = 10, roll  =  0),
trajectory(forward =  5*3.14159265359, pitch = 180),
trajectory(forward = 10, roll  =  0)
];

// sweep
path = quantize_trajectories(path_definition, steps=100);
sweep(rectangle_profile([2,3]), path);

// skin
myLen = len(path)-1;
trans = [ for (i=[0:len(path)-1]) transform(path[i], rounded_rectangle_profile([4,4], i/myLen*2)) ];

translate([0,10,0])
  skin(trans);

screen shot 2015-07-24 at 10 15 32 am

atartanian avatar Jul 24 '15 14:07 atartanian

I cannot find rounded_rectangle_profile()... can someone point?

petaflot avatar Aug 29 '23 09:08 petaflot

Probably that one: https://github.com/openscad/scad-utils/blob/26f8c2cf8124cdafe2fc21f9f9bbf2514e404834/shapes.scad#L7

t-paul avatar Aug 29 '23 15:08 t-paul

Probably that one: https://github.com/openscad/scad-utils/blob/26f8c2cf8124cdafe2fc21f9f9bbf2514e404834/shapes.scad#L7

doesn't look rounded to me ; also, see line 16:

// FIXME: Move rectangle and rounded rectangle from extrusion

petaflot avatar Sep 08 '23 13:09 petaflot