redundant question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

redundant question

jon_bondy
I'm sure this has been covered before, but how would one take the
example in sweep-path.scad and preserve the circular rotations, but
eliminate the rotations of the object around its own axis. That is, how
would one keep the object flat (for example)?

Thank you

Jon


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: redundant question

Ronaldo
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
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.