discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

path extrude

SP
Sanjeev Prabhakar
Sun, Apr 2, 2023 5:12 AM

I was thinking about the path_extrude for a close loop path like below

[image: Screenshot 2023-04-02 at 10.36.49 AM.png]

should the extruded section along the path look like below?

[image: Screenshot 2023-04-02 at 10.32.35 AM.png]

I was thinking about the path_extrude for a close loop path like below [image: Screenshot 2023-04-02 at 10.36.49 AM.png] should the extruded section along the path look like below? [image: Screenshot 2023-04-02 at 10.32.35 AM.png]
GS
Guenther Sohler
Sun, Apr 2, 2023 7:11 AM

Hi sanjeev, IT appears that you have to Twist the path along the was in a
Special was to achieve this.

Sanjeev Prabhakar sprabhakar2006@gmail.com schrieb am So., 2. Apr. 2023,
07:13:

I was thinking about the path_extrude for a close loop path like below

[image: Screenshot 2023-04-02 at 10.36.49 AM.png]

should the extruded section along the path look like below?

[image: Screenshot 2023-04-02 at 10.32.35 AM.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Hi sanjeev, IT appears that you have to Twist the path along the was in a Special was to achieve this. Sanjeev Prabhakar <sprabhakar2006@gmail.com> schrieb am So., 2. Apr. 2023, 07:13: > I was thinking about the path_extrude for a close loop path like below > > [image: Screenshot 2023-04-02 at 10.36.49 AM.png] > > should the extruded section along the path look like below? > > [image: Screenshot 2023-04-02 at 10.32.35 AM.png] > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Sun, Apr 2, 2023 7:25 AM

Hi Guenther,

I added a twist angle to get this.

Earlier version of path extrude did not have this twist.

I was just wondering whether this is correct or not.

Regards

On Sun, 2 Apr, 2023, 12:42 pm Guenther Sohler, guenther.sohler@gmail.com
wrote:

Hi sanjeev, IT appears that you have to Twist the path along the was in a
Special was to achieve this.

Sanjeev Prabhakar sprabhakar2006@gmail.com schrieb am So., 2. Apr.
2023, 07:13:

I was thinking about the path_extrude for a close loop path like below

[image: Screenshot 2023-04-02 at 10.36.49 AM.png]

should the extruded section along the path look like below?

[image: Screenshot 2023-04-02 at 10.32.35 AM.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Hi Guenther, I added a twist angle to get this. Earlier version of path extrude did not have this twist. I was just wondering whether this is correct or not. Regards On Sun, 2 Apr, 2023, 12:42 pm Guenther Sohler, <guenther.sohler@gmail.com> wrote: > Hi sanjeev, IT appears that you have to Twist the path along the was in a > Special was to achieve this. > > Sanjeev Prabhakar <sprabhakar2006@gmail.com> schrieb am So., 2. Apr. > 2023, 07:13: > >> I was thinking about the path_extrude for a close loop path like below >> >> [image: Screenshot 2023-04-02 at 10.36.49 AM.png] >> >> should the extruded section along the path look like below? >> >> [image: Screenshot 2023-04-02 at 10.32.35 AM.png] >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
GS
Guenther Sohler
Sun, Apr 2, 2023 7:50 AM

Hi sanjeev, very interesting.
Apparently you do Not Twist the path linearily along ITS was but  instead
follow a Special concept. How to get IT correctly to See exactly your
result? IS the Twist a piece-wise linear function along the path and you
did Dome trials on the pwl Points to get the result correct?

Sanjeev Prabhakar sprabhakar2006@gmail.com schrieb am So., 2. Apr. 2023,
09:26:

Hi Guenther,

I added a twist angle to get this.

Earlier version of path extrude did not have this twist.

I was just wondering whether this is correct or not.

Regards

On Sun, 2 Apr, 2023, 12:42 pm Guenther Sohler, guenther.sohler@gmail.com
wrote:

Hi sanjeev, IT appears that you have to Twist the path along the was in a
Special was to achieve this.

Sanjeev Prabhakar sprabhakar2006@gmail.com schrieb am So., 2. Apr.
2023, 07:13:

I was thinking about the path_extrude for a close loop path like below

[image: Screenshot 2023-04-02 at 10.36.49 AM.png]

should the extruded section along the path look like below?

[image: Screenshot 2023-04-02 at 10.32.35 AM.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Hi sanjeev, very interesting. Apparently you do Not Twist the path linearily along ITS was but instead follow a Special concept. How to get IT correctly to See exactly your result? IS the Twist a piece-wise linear function along the path and you did Dome trials on the pwl Points to get the result correct? Sanjeev Prabhakar <sprabhakar2006@gmail.com> schrieb am So., 2. Apr. 2023, 09:26: > Hi Guenther, > > I added a twist angle to get this. > > Earlier version of path extrude did not have this twist. > > I was just wondering whether this is correct or not. > > Regards > > On Sun, 2 Apr, 2023, 12:42 pm Guenther Sohler, <guenther.sohler@gmail.com> > wrote: > >> Hi sanjeev, IT appears that you have to Twist the path along the was in a >> Special was to achieve this. >> >> Sanjeev Prabhakar <sprabhakar2006@gmail.com> schrieb am So., 2. Apr. >> 2023, 07:13: >> >>> I was thinking about the path_extrude for a close loop path like below >>> >>> [image: Screenshot 2023-04-02 at 10.36.49 AM.png] >>> >>> should the extruded section along the path look like below? >>> >>> [image: Screenshot 2023-04-02 at 10.32.35 AM.png] >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Sun, Apr 2, 2023 8:19 AM

Initially I wrote a very simple function to align a section to a vector

the function is:

def sec2vector1(v1,sec):
theta_y=ang((v1[0]**2+v1[1]2).5,v1[2])
theta_z=ang(v1[0],v1[1])
return q_rot(['x90','z-90',f'y{-theta_y}',f'z{theta_z}'],sec)

here q_rot is another function which rotates a section w.r.t. x, y, z axis
in any sequence provided

but you cannot define a twist,I feel (since there is no proof as yet)
because with only 1 vector you can not calculate the rate of change of a
curve, which probably would be required to define it.

now when you have a list of points in a curve, tangent at each point can be
calculated, also with the cross product of 2 consecutive tangent vectors, a
perpendicular vector at each point could be calculated.
angle between the vector [0,0,1] and this perpendicular vector would the
twist which needs to be added to the section.

Also the initial alignment of the section at each point is done with the
tangent vector at each point rather than vector at that point.

This is the process I followed to get the above result.

Although I am not 100% sure that this is the correct way to do path
extrude, this should be close enough to get started.

this fails when I give a circular path which is rotated 90 degrees, that is
if the circle is parallel to xz or yz axis, but then you can rotate the
extrude section in xy.

On Sun, 2 Apr 2023 at 13:21, Guenther Sohler guenther.sohler@gmail.com
wrote:

Hi sanjeev, very interesting.
Apparently you do Not Twist the path linearily along ITS was but  instead
follow a Special concept. How to get IT correctly to See exactly your
result? IS the Twist a piece-wise linear function along the path and you
did Dome trials on the pwl Points to get the result correct?

Sanjeev Prabhakar sprabhakar2006@gmail.com schrieb am So., 2. Apr.
2023, 09:26:

Hi Guenther,

I added a twist angle to get this.

Earlier version of path extrude did not have this twist.

I was just wondering whether this is correct or not.

Regards

On Sun, 2 Apr, 2023, 12:42 pm Guenther Sohler, guenther.sohler@gmail.com
wrote:

Hi sanjeev, IT appears that you have to Twist the path along the was in
a Special was to achieve this.

Sanjeev Prabhakar sprabhakar2006@gmail.com schrieb am So., 2. Apr.
2023, 07:13:

I was thinking about the path_extrude for a close loop path like below

[image: Screenshot 2023-04-02 at 10.36.49 AM.png]

should the extruded section along the path look like below?

[image: Screenshot 2023-04-02 at 10.32.35 AM.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Initially I wrote a very simple function to align a section to a vector the function is: def sec2vector1(v1,sec): theta_y=ang((v1[0]**2+v1[1]**2)**.5,v1[2]) theta_z=ang(v1[0],v1[1]) return q_rot(['x90','z-90',f'y{-theta_y}',f'z{theta_z}'],sec) here q_rot is another function which rotates a section w.r.t. x, y, z axis in any sequence provided but you cannot define a twist,I feel (since there is no proof as yet) because with only 1 vector you can not calculate the rate of change of a curve, which probably would be required to define it. now when you have a list of points in a curve, tangent at each point can be calculated, also with the cross product of 2 consecutive tangent vectors, a perpendicular vector at each point could be calculated. angle between the vector [0,0,1] and this perpendicular vector would the twist which needs to be added to the section. Also the initial alignment of the section at each point is done with the tangent vector at each point rather than vector at that point. This is the process I followed to get the above result. Although I am not 100% sure that this is the correct way to do path extrude, this should be close enough to get started. this fails when I give a circular path which is rotated 90 degrees, that is if the circle is parallel to xz or yz axis, but then you can rotate the extrude section in xy. On Sun, 2 Apr 2023 at 13:21, Guenther Sohler <guenther.sohler@gmail.com> wrote: > Hi sanjeev, very interesting. > Apparently you do Not Twist the path linearily along ITS was but instead > follow a Special concept. How to get IT correctly to See exactly your > result? IS the Twist a piece-wise linear function along the path and you > did Dome trials on the pwl Points to get the result correct? > > Sanjeev Prabhakar <sprabhakar2006@gmail.com> schrieb am So., 2. Apr. > 2023, 09:26: > >> Hi Guenther, >> >> I added a twist angle to get this. >> >> Earlier version of path extrude did not have this twist. >> >> I was just wondering whether this is correct or not. >> >> Regards >> >> On Sun, 2 Apr, 2023, 12:42 pm Guenther Sohler, <guenther.sohler@gmail.com> >> wrote: >> >>> Hi sanjeev, IT appears that you have to Twist the path along the was in >>> a Special was to achieve this. >>> >>> Sanjeev Prabhakar <sprabhakar2006@gmail.com> schrieb am So., 2. Apr. >>> 2023, 07:13: >>> >>>> I was thinking about the path_extrude for a close loop path like below >>>> >>>> [image: Screenshot 2023-04-02 at 10.36.49 AM.png] >>>> >>>> should the extruded section along the path look like below? >>>> >>>> [image: Screenshot 2023-04-02 at 10.32.35 AM.png] >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Sun, Apr 2, 2023 1:07 PM

I worked a long time on path_sweep for BOSL2 and found it necessary to
implement several different schemes for controlling the orientation of the
sections.  I do not think there is a single "correct" way.  And there may
be methods I did not think of. The definition of path sweep (extrude) is
that you place the sections so that the section's normal is parallel to the
tangent of the curve.  But this leaves a degree of freedom: the twist.  The
path sweep problem is ill defined because twist is simply not specified.  I
prefer to think of this process as defining a coordinate frame for the
mapped section.  You must map the z axis of the section onto the path's
tangent direction.  And then you pick say the x axis and map that onto the
normal vector at each point in the path.  This is more intuitive than
talking about twist as an angle, at least to me. Then the question is how
did you come up with a normal vector?

Using the frenet frame is presumably the method that would have the best
claim for being "correct".  It doesn't tend to produce odd twist.  But it
can have problems when the curvature of the path is zero at any point, and
you can get abrupt changes in direction of the sections.  And you need to
be able to compute second derivatives.  So there is a class of paths it
doesn't work on.

A different approach is to map the tangent at point i to the tangent at
point i+1 by rotating along the minimal direction.  This will always
produce a result.  But it can introduce unexpected twisting.  With this
method there's no guarantee that a closed figure closes---that is, the
twist may be different at the end than the start.  So if you want to close
a figure you'll potentially have to add some twist to get the ends to
align.

Note that none of the method I have implemented seemed to give the answer
you wanted for your folding problem.

Using cross products to define the normal I get this, which has bad joins
along the straight sections, because there is twist, but no refinement to
represent it.

[image: image.png]

But if I subsample the straight sections, the cross product is zero there
because the consecutive segments are parallel.  I do not understand what
approach you used for defining the twist in your example above.  It looks
like you subdivided the straight section.  Did you interpolate the cross
product across that region where it is zero?

On Sun, Apr 2, 2023 at 4:20 AM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

Initially I wrote a very simple function to align a section to a vector

the function is:

def sec2vector1(v1,sec):
theta_y=ang((v1[0]**2+v1[1]2).5,v1[2])
theta_z=ang(v1[0],v1[1])
return q_rot(['x90','z-90',f'y{-theta_y}',f'z{theta_z}'],sec)

here q_rot is another function which rotates a section w.r.t. x, y, z axis
in any sequence provided

but you cannot define a twist,I feel (since there is no proof as yet)
because with only 1 vector you can not calculate the rate of change of a
curve, which probably would be required to define it.

now when you have a list of points in a curve, tangent at each point can
be calculated, also with the cross product of 2 consecutive tangent
vectors, a perpendicular vector at each point could be calculated.
angle between the vector [0,0,1] and this perpendicular vector would the
twist which needs to be added to the section.

Also the initial alignment of the section at each point is done with the
tangent vector at each point rather than vector at that point.

This is the process I followed to get the above result.

Although I am not 100% sure that this is the correct way to do path
extrude, this should be close enough to get started.

this fails when I give a circular path which is rotated 90 degrees, that
is if the circle is parallel to xz or yz axis, but then you can rotate the
extrude section in xy.

On Sun, 2 Apr 2023 at 13:21, Guenther Sohler guenther.sohler@gmail.com
wrote:

Hi sanjeev, very interesting.
Apparently you do Not Twist the path linearily along ITS was but  instead
follow a Special concept. How to get IT correctly to See exactly your
result? IS the Twist a piece-wise linear function along the path and you
did Dome trials on the pwl Points to get the result correct?

Sanjeev Prabhakar sprabhakar2006@gmail.com schrieb am So., 2. Apr.
2023, 09:26:

Hi Guenther,

I added a twist angle to get this.

Earlier version of path extrude did not have this twist.

I was just wondering whether this is correct or not.

Regards

On Sun, 2 Apr, 2023, 12:42 pm Guenther Sohler, <
guenther.sohler@gmail.com> wrote:

Hi sanjeev, IT appears that you have to Twist the path along the was in
a Special was to achieve this.

Sanjeev Prabhakar sprabhakar2006@gmail.com schrieb am So., 2. Apr.
2023, 07:13:

I was thinking about the path_extrude for a close loop path like below

[image: Screenshot 2023-04-02 at 10.36.49 AM.png]

should the extruded section along the path look like below?

[image: Screenshot 2023-04-02 at 10.32.35 AM.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I worked a long time on path_sweep for BOSL2 and found it necessary to implement several different schemes for controlling the orientation of the sections. I do not think there is a single "correct" way. And there may be methods I did not think of. The definition of path sweep (extrude) is that you place the sections so that the section's normal is parallel to the tangent of the curve. But this leaves a degree of freedom: the twist. The path sweep problem is ill defined because twist is simply not specified. I prefer to think of this process as defining a coordinate frame for the mapped section. You must map the z axis of the section onto the path's tangent direction. And then you pick say the x axis and map that onto the normal vector at each point in the path. This is more intuitive than talking about twist as an angle, at least to me. Then the question is how did you come up with a normal vector? Using the frenet frame is presumably the method that would have the best claim for being "correct". It doesn't tend to produce odd twist. But it can have problems when the curvature of the path is zero at any point, and you can get abrupt changes in direction of the sections. And you need to be able to compute second derivatives. So there is a class of paths it doesn't work on. A different approach is to map the tangent at point i to the tangent at point i+1 by rotating along the minimal direction. This will always produce a result. But it can introduce unexpected twisting. With this method there's no guarantee that a closed figure closes---that is, the twist may be different at the end than the start. So if you want to close a figure you'll potentially have to add some twist to get the ends to align. Note that none of the method I have implemented seemed to give the answer you wanted for your folding problem. Using cross products to define the normal I get this, which has bad joins along the straight sections, because there is twist, but no refinement to represent it. [image: image.png] But if I subsample the straight sections, the cross product is zero there because the consecutive segments are parallel. I do not understand what approach you used for defining the twist in your example above. It looks like you subdivided the straight section. Did you interpolate the cross product across that region where it is zero? On Sun, Apr 2, 2023 at 4:20 AM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > Initially I wrote a very simple function to align a section to a vector > > the function is: > > def sec2vector1(v1,sec): > theta_y=ang((v1[0]**2+v1[1]**2)**.5,v1[2]) > theta_z=ang(v1[0],v1[1]) > return q_rot(['x90','z-90',f'y{-theta_y}',f'z{theta_z}'],sec) > > here q_rot is another function which rotates a section w.r.t. x, y, z axis > in any sequence provided > > but you cannot define a twist,I feel (since there is no proof as yet) > because with only 1 vector you can not calculate the rate of change of a > curve, which probably would be required to define it. > > now when you have a list of points in a curve, tangent at each point can > be calculated, also with the cross product of 2 consecutive tangent > vectors, a perpendicular vector at each point could be calculated. > angle between the vector [0,0,1] and this perpendicular vector would the > twist which needs to be added to the section. > > Also the initial alignment of the section at each point is done with the > tangent vector at each point rather than vector at that point. > > This is the process I followed to get the above result. > > Although I am not 100% sure that this is the correct way to do path > extrude, this should be close enough to get started. > > this fails when I give a circular path which is rotated 90 degrees, that > is if the circle is parallel to xz or yz axis, but then you can rotate the > extrude section in xy. > > > > > > > On Sun, 2 Apr 2023 at 13:21, Guenther Sohler <guenther.sohler@gmail.com> > wrote: > >> Hi sanjeev, very interesting. >> Apparently you do Not Twist the path linearily along ITS was but instead >> follow a Special concept. How to get IT correctly to See exactly your >> result? IS the Twist a piece-wise linear function along the path and you >> did Dome trials on the pwl Points to get the result correct? >> >> Sanjeev Prabhakar <sprabhakar2006@gmail.com> schrieb am So., 2. Apr. >> 2023, 09:26: >> >>> Hi Guenther, >>> >>> I added a twist angle to get this. >>> >>> Earlier version of path extrude did not have this twist. >>> >>> I was just wondering whether this is correct or not. >>> >>> Regards >>> >>> On Sun, 2 Apr, 2023, 12:42 pm Guenther Sohler, < >>> guenther.sohler@gmail.com> wrote: >>> >>>> Hi sanjeev, IT appears that you have to Twist the path along the was in >>>> a Special was to achieve this. >>>> >>>> Sanjeev Prabhakar <sprabhakar2006@gmail.com> schrieb am So., 2. Apr. >>>> 2023, 07:13: >>>> >>>>> I was thinking about the path_extrude for a close loop path like below >>>>> >>>>> [image: Screenshot 2023-04-02 at 10.36.49 AM.png] >>>>> >>>>> should the extruded section along the path look like below? >>>>> >>>>> [image: Screenshot 2023-04-02 at 10.32.35 AM.png] >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Sun, Apr 2, 2023 4:19 PM

So first of all, the curve has to be differentiable at each point,
otherwise it will not work and the regular path extrude is to be used. you
can say, points in straight line or nearly straight line needs to be
removed

This could be useful in a few cases  I suppose, which anyway needs to be
checked.

I calculated tangent at each point as simply the average of 2 vectors at
each point (1 incoming and 1 outgoing). I need to read the frenet method
for details.

the image posted by you looks similar to the way I was doing it.

I have added slices to make this look better.

for a point "i" , p[i-1],p[i], p[i+1] makes a plane and a normal can be
drawn to that plane.
angle this normal makes with the z-axis is taken as twist. axis used for
rotating is the cross product of normal with z-axis.

So first of all, the curve has to be differentiable at each point, otherwise it will not work and the regular path extrude is to be used. you can say, points in straight line or nearly straight line needs to be removed This could be useful in a few cases I suppose, which anyway needs to be checked. I calculated tangent at each point as simply the average of 2 vectors at each point (1 incoming and 1 outgoing). I need to read the frenet method for details. the image posted by you looks similar to the way I was doing it. I have added slices to make this look better. for a point "i" , p[i-1],p[i], p[i+1] makes a plane and a normal can be drawn to that plane. angle this normal makes with the z-axis is taken as twist. axis used for rotating is the cross product of normal with z-axis.
SP
Sanjeev Prabhakar
Sun, Apr 2, 2023 4:30 PM

another way i found effective in few cases like below is to align the
sections after the normal path extrude without twist.

path=cr_3d([[0,0,0,3],[15,0,0,4],[5,3,15,3],[0,10,0,3],[-5,3,-15,4],[-15,0,0,3]],10)
sec=pts([[-1.5,-1.25],[3,0],[-1.5,2.5]])
sol=path_extrudec(sec,path)

sol=slice_sol(sol,2)

sol=align_sol(sol,1)

sol=slice_sol(sol,10)

[image: Screenshot 2023-04-02 at 9.58.56 PM.png]

On Sun, 2 Apr 2023 at 21:49, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

So first of all, the curve has to be differentiable at each point,
otherwise it will not work and the regular path extrude is to be used. you
can say, points in straight line or nearly straight line needs to be
removed

This could be useful in a few cases  I suppose, which anyway needs to be
checked.

I calculated tangent at each point as simply the average of 2 vectors at
each point (1 incoming and 1 outgoing). I need to read the frenet method
for details.

the image posted by you looks similar to the way I was doing it.

I have added slices to make this look better.

for a point "i" , p[i-1],p[i], p[i+1] makes a plane and a normal can be
drawn to that plane.
angle this normal makes with the z-axis is taken as twist. axis used for
rotating is the cross product of normal with z-axis.

another way i found effective in few cases like below is to align the sections after the normal path extrude without twist. path=cr_3d([[0,0,0,3],[15,0,0,4],[5,3,15,3],[0,10,0,3],[-5,3,-15,4],[-15,0,0,3]],10) sec=pts([[-1.5,-1.25],[3,0],[-1.5,2.5]]) sol=path_extrudec(sec,path) # sol=slice_sol(sol,2) sol=align_sol(sol,1) sol=slice_sol(sol,10) [image: Screenshot 2023-04-02 at 9.58.56 PM.png] On Sun, 2 Apr 2023 at 21:49, Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > > So first of all, the curve has to be differentiable at each point, > otherwise it will not work and the regular path extrude is to be used. you > can say, points in straight line or nearly straight line needs to be > removed > > This could be useful in a few cases I suppose, which anyway needs to be > checked. > > I calculated tangent at each point as simply the average of 2 vectors at > each point (1 incoming and 1 outgoing). I need to read the frenet method > for details. > > the image posted by you looks similar to the way I was doing it. > > I have added slices to make this look better. > > for a point "i" , p[i-1],p[i], p[i+1] makes a plane and a normal can be > drawn to that plane. > angle this normal makes with the z-axis is taken as twist. axis used for > rotating is the cross product of normal with z-axis. > > > > > >
AM
Adrian Mariano
Sun, Apr 2, 2023 4:43 PM

In the example I posted above where I used cross product to define the
normal direction, I am not able to add slices, because then the slices have
a zero normal, so I don't have a way to align slices along the straight
section of the curve.

I get a good result with my incremental approach.  It's just not what you
were looking for, as shown below.  The frenet approach produces a good
result, maybe really the best possible result, if the curve has a defined
and nonzero second derivative at every point.  But in other cases,
including this one, the result isn't great.  Again, you wish you could add
more slices, but you can't because it creates zero second (and first)
derivative.

[image: image.png]

Also with this incremental approach, you can change the result by just
changing the first normal, so for example this:

[image: image.png]

On Sun, Apr 2, 2023 at 12:20 PM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

So first of all, the curve has to be differentiable at each point,
otherwise it will not work and the regular path extrude is to be used. you
can say, points in straight line or nearly straight line needs to be
removed

This could be useful in a few cases  I suppose, which anyway needs to be
checked.

I calculated tangent at each point as simply the average of 2 vectors at
each point (1 incoming and 1 outgoing). I need to read the frenet method
for details.

the image posted by you looks similar to the way I was doing it.

I have added slices to make this look better.

for a point "i" , p[i-1],p[i], p[i+1] makes a plane and a normal can be
drawn to that plane.
angle this normal makes with the z-axis is taken as twist. axis used for
rotating is the cross product of normal with z-axis.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

In the example I posted above where I used cross product to define the normal direction, I am not able to add slices, because then the slices have a zero normal, so I don't have a way to align slices along the straight section of the curve. I get a good result with my incremental approach. It's just not what you were looking for, as shown below. The frenet approach produces a good result, maybe really the best possible result, if the curve has a defined and nonzero second derivative at every point. But in other cases, including this one, the result isn't great. Again, you wish you could add more slices, but you can't because it creates zero second (and first) derivative. [image: image.png] Also with this incremental approach, you can change the result by just changing the first normal, so for example this: [image: image.png] On Sun, Apr 2, 2023 at 12:20 PM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > > So first of all, the curve has to be differentiable at each point, > otherwise it will not work and the regular path extrude is to be used. you > can say, points in straight line or nearly straight line needs to be > removed > > This could be useful in a few cases I suppose, which anyway needs to be > checked. > > I calculated tangent at each point as simply the average of 2 vectors at > each point (1 incoming and 1 outgoing). I need to read the frenet method > for details. > > the image posted by you looks similar to the way I was doing it. > > I have added slices to make this look better. > > for a point "i" , p[i-1],p[i], p[i+1] makes a plane and a normal can be > drawn to that plane. > angle this normal makes with the z-axis is taken as twist. axis used for > rotating is the cross product of normal with z-axis. > > > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Sun, Apr 2, 2023 4:51 PM

Note that there is no such thing as "without twist".  This notion assumes
that there is some kind of defined "true" answer.  But there is not.  So I
don't know what you mean by "without twist".  You also said something in
the previous message about using "the regular path_extrude" in the case of
non-differentiable paths.  I have no idea what the "regular" path extrude
is.  You can always compute a "tangent" at a point on the path.  If the
path is a square you presumably will get a 45 degree angle "tangent"
vector, which is reasonable.

I can't try your example because you gave code with dependencies you don't
supply.  I suggest just give final point lists with no dependencies that I
can cut and paste into my code if you want me to be able to see what my
code does with them.

On Sun, Apr 2, 2023 at 12:31 PM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

another way i found effective in few cases like below is to align the
sections after the normal path extrude without twist.

path=cr_3d([[0,0,0,3],[15,0,0,4],[5,3,15,3],[0,10,0,3],[-5,3,-15,4],[-15,0,0,3]],10)
sec=pts([[-1.5,-1.25],[3,0],[-1.5,2.5]])
sol=path_extrudec(sec,path)

sol=slice_sol(sol,2)

sol=align_sol(sol,1)

sol=slice_sol(sol,10)

[image: Screenshot 2023-04-02 at 9.58.56 PM.png]

On Sun, 2 Apr 2023 at 21:49, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

So first of all, the curve has to be differentiable at each point,
otherwise it will not work and the regular path extrude is to be used. you
can say, points in straight line or nearly straight line needs to be
removed

This could be useful in a few cases  I suppose, which anyway needs to be
checked.

I calculated tangent at each point as simply the average of 2 vectors at
each point (1 incoming and 1 outgoing). I need to read the frenet method
for details.

the image posted by you looks similar to the way I was doing it.

I have added slices to make this look better.

for a point "i" , p[i-1],p[i], p[i+1] makes a plane and a normal can be
drawn to that plane.
angle this normal makes with the z-axis is taken as twist. axis used for
rotating is the cross product of normal with z-axis.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Note that there is no such thing as "without twist". This notion assumes that there is some kind of defined "true" answer. But there is not. So I don't know what you mean by "without twist". You also said something in the previous message about using "the regular path_extrude" in the case of non-differentiable paths. I have no idea what the "regular" path extrude is. You can always compute a "tangent" at a point on the path. If the path is a square you presumably will get a 45 degree angle "tangent" vector, which is reasonable. I can't try your example because you gave code with dependencies you don't supply. I suggest just give final point lists with no dependencies that I can cut and paste into my code if you want me to be able to see what my code does with them. On Sun, Apr 2, 2023 at 12:31 PM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > another way i found effective in few cases like below is to align the > sections after the normal path extrude without twist. > > > path=cr_3d([[0,0,0,3],[15,0,0,4],[5,3,15,3],[0,10,0,3],[-5,3,-15,4],[-15,0,0,3]],10) > sec=pts([[-1.5,-1.25],[3,0],[-1.5,2.5]]) > sol=path_extrudec(sec,path) > # sol=slice_sol(sol,2) > sol=align_sol(sol,1) > > sol=slice_sol(sol,10) > > [image: Screenshot 2023-04-02 at 9.58.56 PM.png] > > On Sun, 2 Apr 2023 at 21:49, Sanjeev Prabhakar <sprabhakar2006@gmail.com> > wrote: > >> >> So first of all, the curve has to be differentiable at each point, >> otherwise it will not work and the regular path extrude is to be used. you >> can say, points in straight line or nearly straight line needs to be >> removed >> >> This could be useful in a few cases I suppose, which anyway needs to be >> checked. >> >> I calculated tangent at each point as simply the average of 2 vectors at >> each point (1 incoming and 1 outgoing). I need to read the frenet method >> for details. >> >> the image posted by you looks similar to the way I was doing it. >> >> I have added slices to make this look better. >> >> for a point "i" , p[i-1],p[i], p[i+1] makes a plane and a normal can be >> drawn to that plane. >> angle this normal makes with the z-axis is taken as twist. axis used for >> rotating is the cross product of normal with z-axis. >> >> >> >> >> >> _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >