larger number of control points for Bezier

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

larger number of control points for Bezier

jon_bondy
I am toying around with modeling an electric guitar body in OpenSCAD. 
Google "Gibson SG" for an idea about the body shape. In order to create
the shape, I need between 10 and 20 control points (for one side of the
guitar body: the other side is [fortunately] a mirror image).  I found
some code that will handle 4 control points, and some that will handle
8, but nothing that will handle "n" points.  I suppose I could try to do
this with a series of 4-point or 8 point curves, but would prefer to do
it with one curve.

Any insights into this?  My quick perusal of the existing code implies
that one needs "n" hand-coded functions when handling "n" points, which
is why the previous authors went with fixed numbers of 4 and 8.

Jon

--
Sent from my desktop computer.
I do not receive emails while away from my desk,
nor do I receive texts on my main phone number
(which is a land line).
If you know that I am on the road, please text me.
If you know that I am home, please email me.


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

Re: larger number of control points for Bezier

moshel
try dotscad, https://github.com/JustinSDK/dotSCAD
its a really good library, with lots of useful modules. the bezier_curve
(https://openhome.cc/eGossip/OpenSCAD/lib-bezier_curve.html) can probably do
what you want, although you might find it easier to use a few sets of curves
as the curves are a bit harder to control with more than 4 points.



--
Sent from: http://forum.openscad.org/

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

Re: larger number of control points for Bezier

Ronaldo
I don't believe you could get the shape of Gibson SG with one or two Bezier curves, even with 20 control points. One alternative is to use interpolation splines instead of Bezier. See for instance, the library http://www.thingiverse.com/thing:1208001. However, you may find difficult to position the input points to interpolate in order to get the curve you have in mind. A better approach is to use B-splines or even NURBS but I don't know any published OpenSCAD library with them.



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

Re: larger number of control points for Bezier

RobWLakes
I would suggest loading an image into InkScape and using as many Bezier segments (ie one line as you wish) to map it. Then import that into OpenSCAD and either use extrusions of 2D shape to "build" the body or at least use it as a visual check on what choose to do instead of extrusion. Some compromise will be required in this as the guitar body is not a standard OpenSCAD geometric shape, the smooth curves will be reduced to planar segments at some stage. However understanding the resolution of your printer will help you achieve a workable compromise when the spline curves are quantised into segments (ie in Inkscape or OpenSCAD import).

--
Rob
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Rob W
Lake Tyers Beach,
Victoria, Australia
Reply | Threaded
Open this post in threaded view
|

Re: larger number of control points for Bezier

Neon22
I.e. https://www.thingiverse.com/thing:1065500


On 10/24/2017 12:45 PM, Rob Ward wrote:

> I would suggest loading an image into InkScape and using as many
> Bezier segments (ie one line as you wish) to map it. Then import that
> into OpenSCAD and either use extrusions of 2D shape to "build" the
> body or at least use it as a visual check on what choose to do instead
> of extrusion. Some compromise will be required in this as the guitar
> body is not a standard OpenSCAD geometric shape, the smooth curves
> will be reduced to planar segments at some stage. However
> understanding the resolution of your printer will help you achieve a
> workable compromise when the spline curves are quantised into segments
> (ie in Inkscape or OpenSCAD import).
>
> --
> Rob


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

Re: larger number of control points for Bezier

oystein.krog
In reply to this post by jon_bondy
Does it really have to be bezier curves?
I would recommend trying to use cubic natural splines instead, Parkinbot has
a great nSpline function/library that allows you to do what you want.



--
Sent from: http://forum.openscad.org/

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

Re: larger number of control points for Bezier

jon_bondy
I often feel like a child among graduate students with you guys. I
thought what I was trying to do was simple (create a smooth exterior
curve for the guitar body) and all I needed was a "smoothing function"
of some sort.  I do not understand the difference between Bezier and
splines: they both are magic to me. But Bezier appears to work to smooth
a curved line on a plane, while Parkinbot's splines appear to work on a
3D surface.  Is there a way to use Parkinbot's splines for the simpler
line-on-a-plane case?

Sorry for being so clueless.

Jon


On 10/24/2017 4:49 AM, oystein.krog wrote:

> Does it really have to be bezier curves?
> I would recommend trying to use cubic natural splines instead, Parkinbot has
> a great nSpline function/library that allows you to do what you want.
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>

--
Sent from my desktop computer.
I do not receive emails while away from my desk,
nor do I receive texts on my main phone number
(which is a land line).
If you know that I am on the road, please text me.
If you know that I am home, please email me.


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

Re: larger number of control points for Bezier

Ronaldo
If all your "control points" are in a plane, Bezier and splines will be in their plane. I am quite sure (but haven't check it) that Parkinbot's spline library will work with with 2D control points as well. 

Em 24 de out de 2017 09:45, "jon" <[hidden email]> escreveu:
I often feel like a child among graduate students with you guys. I thought what I was trying to do was simple (create a smooth exterior curve for the guitar body) and all I needed was a "smoothing function" of some sort.  I do not understand the difference between Bezier and splines: they both are magic to me. But Bezier appears to work to smooth a curved line on a plane, while Parkinbot's splines appear to work on a 3D surface.  Is there a way to use Parkinbot's splines for the simpler line-on-a-plane case?

Sorry for being so clueless.

Jon


On 10/24/2017 4:49 AM, oystein.krog wrote:
Does it really have to be bezier curves?
I would recommend trying to use cubic natural splines instead, Parkinbot has
a great nSpline function/library that allows you to do what you want.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



--
Sent from my desktop computer.
I do not receive emails while away from my desk,
nor do I receive texts on my main phone number
(which is a land line).
If you know that I am on the road, please text me.
If you know that I am home, please email me.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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

Re: larger number of control points for Bezier

MathLover
In reply to this post by jon_bondy
I would use a 2D CAD program to import a foto or drawing and draw the shape
on top of that. LibreCAD could probably do that. Or Inkscape, as was already
suggested. Then, you can export the (closed!) shape as DXF and import it
into OpenSCAD to extrude it.

Those 2D programs also allow you to draw an inner offset, so you can use a
Minkowski sum to add rounded corners to the body. Off course, the part where
the neck is attached should be taken care of separately.




--
Sent from: http://forum.openscad.org/

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

Re: larger number of control points for Bezier

Gadgetmind
In reply to this post by Ronaldo
On 2017-10-24 13:03, Ronaldo Persiano wrote:
> I am quite sure (but haven't check it) that Parkinbot's spline library
> will work with with 2D control points as well.

I often used with 2D data, and sometimes with 4/5/6 D data!

This is done when I want to move a (say) circle along a path. I have X/Y
data, and also size of disc and its angle, etc. as control points.
NSpline then smooths this data and I can use transformations on circle
points returned from a function to get all the required points to use
finally use skin ().

Most of these teapots that I recently designed and printed for a charity
use this approach in various (slightly hacky!) ways.

https://www.thingiverse.com/thing:2590540


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

Re: larger number of control points for Bezier

Neon22
In reply to this post by jon_bondy
Jon, IMHO the easiest way to consider the difference between beziers and
bsplines is that every knot(control point) on the bezier curve will
effect all of the line. So even making a small adjustment to an end
control point will (minimally) affect the curve a long way away. But
bsplines affect the curve only locally either side of the control point.
This makes it easier to control the curve. Nurbs (non-uniform bsplines)
are bsplines too. there are numerous basis functions for splines but
they have this similar property.

Parkinbots lib is great but many people (myself included) have
difficulty controlling it.
The maker.js and snap.js libs look great (and the other openscad in a
browser variants) if you're doing it all procedurally in a browser or
node.js system.
If you're manually doing it - I still recommend Inkscape, the openscad
export function and some openscad code for the end result.

As usual - YMMV.


On 10/25/2017 12:44 AM, jon wrote:

> I often feel like a child among graduate students with you guys. I
> thought what I was trying to do was simple (create a smooth exterior
> curve for the guitar body) and all I needed was a "smoothing function"
> of some sort.  I do not understand the difference between Bezier and
> splines: they both are magic to me. But Bezier appears to work to
> smooth a curved line on a plane, while Parkinbot's splines appear to
> work on a 3D surface.  Is there a way to use Parkinbot's splines for
> the simpler line-on-a-plane case?
>
> Sorry for being so clueless.
>
> 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: larger number of control points for Bezier

JordanBrown
In reply to this post by jon_bondy
On 10/23/2017 11:39 AM, jon wrote:
I am toying around with modeling an electric guitar body in OpenSCAD.  Google "Gibson SG" for an idea about the body shape. In order to create the shape, I need between 10 and 20 control points (for one side of the guitar body: the other side is [fortunately] a mirror image).  I found some code that will handle 4 control points, and some that will handle 8, but nothing that will handle "n" points.  I suppose I could try to do this with a series of 4-point or 8 point curves, but would prefer to do it with one curve.

Any insights into this?  My quick perusal of the existing code implies that one needs "n" hand-coded functions when handling "n" points, which is why the previous authors went with fixed numbers of 4 and 8.

I grabbed a photo of a Gibson SG from gibson.com and had no trouble at all outlining the body with Bezier curves.  On my first try it took twelve curves, but a second try dropped it to nine, and I suspect I could knock off another one or two depending on how one treated the interface with the neck.

I did it with Corel Draw, because that's what I'm familiar with, but I expect you could do the same with Inkscape.  I would have to read up on SVG, but it looks like it wouldn't be hard to extract the values out of the SVG and turn them into OpenSCAD source, if that's preferable.

This is a 2-D representation of the outline.  A full 3D representation is beyond me.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

gibson-sg.svg (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: larger number of control points for Bezier

JordanBrown
When I did that, I didn't bother keeping it within the bounds of a page, because I was just interested in the shape.  But when the message came back to my mailbox, I see that my mail client displayed only the part on the page, so here's a version that's rotated and scaled to fit onto a page.  Hopefully it will display properly in a mail client.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

gibson-sg.svg (1K) Download Attachment