discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Sweep

DE
David Eccles (gringer)
Thu, Jul 9, 2015 8:10 PM

in sweep-path, a function f() is defined, which appears to define a path
through 3D space. Why does the shape rotate as it is swept out?

Got me. I suspect tangent_path() is involved.

I've had this problem myself when trying to make my own path extrude
function:

http://www.thingiverse.com/thing:186660

The problem is that the manipulations you make to rotate the 2D object
around in 3D space will frequently also induce a rotation of the object.
It's not immediately obvious how to alter the initial rotation of the
object to get it to have the least amount of warping when extruding a
path.

When I've tried to have a look at the issue further, I get the feeling
that this rotation is dependent on prior and future states. In other
words, it's context sensitive; it doesn't seem possible to determine the
best initial rotation given just a start state and a position in 3D space.

  • David
>> in sweep-path, a function f() is defined, which appears to define a path >> through 3D space. Why does the shape rotate as it is swept out? > > Got me. I suspect tangent_path() is involved. I've had this problem myself when trying to make my own path extrude function: http://www.thingiverse.com/thing:186660 The problem is that the manipulations you make to rotate the 2D object around in 3D space will frequently also induce a rotation of the object. It's not immediately obvious how to alter the initial rotation of the object to get it to have the least amount of warping when extruding a path. When I've tried to have a look at the issue further, I get the feeling that this rotation is dependent on prior and future states. In other words, it's context sensitive; it doesn't seem possible to determine the best initial rotation given just a start state and a position in 3D space. - David
R
runsun
Thu, Jul 9, 2015 10:38 PM

About the issue of twisting during sweeping:

The way I approach this is not to calc points independently, but calc them
by projecting points of previous frame onto the plane at the current point.

Approaches:

  1. Calc angle-bisect Point, Pb:

For each point i, P(i), we have a pqr= [ P(i-1), P(i), P(i+1) ]
and the angle A(i) of P(i). Calc the angle bisect point Pb using
pqr, such that line [ P(i), Pb ] divides A(i) equally;

  1. Make the projection plane at i:

Calc the point N such that line [ P(i),N ] is the normal of [
P(i-1), P(i), Pb ]. The plane, S=[ P(i), N, Pb ], the plane
that cuts angle A(i) in half, will be the target plane to which we project
previous frame.

  1. Projection:

Retrieve points from the previous frame and project them along the line [
P(i-1), P(i) ] onto S.

Thus, we will have an array Fs= [ frame0, frame1, frame2 ...]

  1. Join frames together to make it: pts= [ P0, P1, P2 ...]

  2. Generate faces using the faces() function described in  faces
    http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html
    :

    f=faces( "chain", nside= len(Fs[0]), nseg= len(Fs)-1 );

  3. And simply, polyhedron( points=pts, faces=f );

So far it seems to work well. Throwing in any random 3D line and it can
produce sweeping nicely without the problem of twisting.

In fact, you can actually apply the twisting of your choice, by modifying
steps of projection.

The following is the "chain" example on my post about  faces
http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html
:

http://forum.openscad.org/file/n12809/demo_chain.png

Or I can generate more examples if interested.


$  Runsun Pan, PhD

$ -- OpenScad_DocTest ( Thingiverse ), faces , Offliner

$ -- hash parameter model: here , here

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

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

About the issue of *twisting during sweeping*: The way I approach this is not to calc points independently, but calc them by projecting points of previous frame onto the plane at the current point. Approaches: 1) Calc angle-bisect Point, *Pb*: For each point i, *P*(i), we have a *pqr*= [ *P*(i-1), *P*(i), *P*(i+1) ] and the angle *A*(i) of *P*(i). Calc the angle bisect point *Pb* using *pqr*, such that line [ *P*(i), *Pb* ] divides *A*(i) equally; 2) Make the projection plane at i: Calc the point *N* such that line [ *P*(i),*N* ] is the normal of [ *P*(i-1), *P*(i), *Pb* ]. The plane, *S*=[ *P*(i), *N*, *Pb* ], the plane that cuts angle *A*(i) in half, will be the target plane to which we project previous frame. 3) Projection: Retrieve points from the previous frame and project them along the line [ *P*(i-1), *P*(i) ] onto *S*. Thus, we will have an array *Fs*= [ frame0, frame1, frame2 ...] 4) Join frames together to make it: *pts*= [ P0, P1, P2 ...] 5) Generate faces using the faces() function described in faces <http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html> : *f*=faces( "chain", nside= len(*Fs*[0]), nseg= len(*Fs*)-1 ); 6) And simply, polyhedron( points=*pts*, faces=*f* ); So far it seems to work well. Throwing in any random 3D line and it can produce sweeping nicely without the problem of twisting. In fact, you can actually apply the twisting of your choice, by modifying steps of projection. The following is the "chain" example on my post about faces <http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html> : <http://forum.openscad.org/file/n12809/demo_chain.png> Or I can generate more examples if interested. ----- $ Runsun Pan, PhD $ -- OpenScad_DocTest ( Thingiverse ), faces , Offliner $ -- hash parameter model: here , here $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/Two-annoyances-tp12935p13110.html Sent from the OpenSCAD mailing list archive at Nabble.com.