[OpenSCAD] redundant question

Ronaldo rcmpersiano at gmail.com
Sat Jun 25 11:06:39 EDT 2016


What you want is to control the sweep torsion. However, there is no such
control in the sweep.scad. A modified version was proposed by Oskar Linde to
minimize the torsion along the path. It may be found in
http://forum.openscad.org/Twisty-problem-with-scad-utils-quot-sweep-quot-tc9775.html#a9784
<http://forum.openscad.org/Twisty-problem-with-scad-utils-quot-sweep-quot-tc9775.html#a9784>  
However, that is not enough to avoid unwanted torsions in all cases. The
following code calculate an addition (or subtraction) of a specified
rotation angle of the path_transforms:

> // a simple rotation in Z
> function zrotation(ang) = 
>   let(c = cos(ang), s = sin(ang))
>      [[  c, s, 0], [ -s, c, 0], [  0, 0, 1]]; 
>       
> // a sequence of acumulated r transform
> function accumulated_transform(r,n,_r=[]) = 
>     (n==0)? 
>         _r: 
>         accumulated_transform(
>             r, 
>             n-1, 
>             (len(_r)==0)? [r]
>                 : concat( _r, [r * _r[len(_r)-1]] ) 
>                              );
> // changes the initial and final rotation angle
> function adjust_rotations(angi, angtot, path_transf) = 
>      let( l    = len(path_transf),
>           rot  = zrotation(angtot/l),
>           rini = zrotation(angi),
>           w    = [0,0,0,1],
>           rots = accumulated_transform(rot,l))
>      [ for(i=[0:l-1])
> path_transf[i]*construct_rt(rots[i],w)*construct_rt(rini,w) ];

A tipical use of it i:

>   path_transf = construct_transform_path(path);
>   path_transforms = adjust_rotations(ini_ang,final_ang, path_transf);
>   sweep(section(), path_transforms, path);

where ini_ang and final_ang is the additional initial angle and final angle
of the section rotations.

Hope it helps.



--
View this message in context: http://forum.openscad.org/redundant-question-tp17808p17810.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list