discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Fitting a curve to points

RW
Roger Whiteley
Mon, Jul 28, 2025 8:46 AM

Glenn

Must remember to use that, which I probably tripped over in the past but
forgot all about it.

I have matched a curve using graph paper and map out the coordinates
into a list, example 5 in the attached is a demonstration of various
shapes generated by point arrays

HTH,

Roger.

Glenn Must remember to use that, which I probably tripped over in the past but forgot all about it. I have matched a curve using graph paper and map out the coordinates into a list, example 5 in the attached is a demonstration of various shapes generated by point arrays HTH, Roger.
GB
Glenn Butcher
Mon, Jul 28, 2025 1:44 PM

I got to using profile polygons so much I ended up writing a 'polygon
sketcher' program:

Just click in the window and it adds  points to the list.  It's
OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, so
I can paste it directly into code:

It's available here:

https://github.com/butcherg/wxpolygon

On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote:

Glenn

Must remember to use that, which I probably tripped over in the past
but forgot all about it.

I have matched a curve using graph paper and map out the coordinates
into a list, example 5 in the attached is a demonstration of various
shapes generated by point arrays

HTH,

Roger.

I got to using profile polygons so much I ended up writing a 'polygon sketcher' program: Just click in the window and it adds  points to the list.  It's OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, so I can paste it directly into code: It's available here: https://github.com/butcherg/wxpolygon On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: > Glenn > > Must remember to use that, which I probably tripped over in the past > but forgot all about it. > > I have matched a curve using graph paper and map out the coordinates > into a list, example 5 in the attached is a demonstration of various > shapes generated by point arrays > > > HTH, > > Roger.
JB
Jon Bondy
Mon, Jul 28, 2025 1:51 PM

Excellent!  I did something similar, but not as elegant!

On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote:

I got to using profile polygons so much I ended up writing a 'polygon
sketcher' program:

Just click in the window and it adds  points to the list.  It's
OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list,
so I can paste it directly into code:

It's available here:

https://github.com/butcherg/wxpolygon

On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote:

Glenn

Must remember to use that, which I probably tripped over in the past
but forgot all about it.

I have matched a curve using graph paper and map out the coordinates
into a list, example 5 in the attached is a demonstration of various
shapes generated by point arrays

HTH,

Roger.


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

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Excellent!  I did something similar, but not as elegant! On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote: > > I got to using profile polygons so much I ended up writing a 'polygon > sketcher' program: > > Just click in the window and it adds  points to the list.  It's > OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, > so I can paste it directly into code: > > It's available here: > > https://github.com/butcherg/wxpolygon > > > On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: >> Glenn >> >> Must remember to use that, which I probably tripped over in the past >> but forgot all about it. >> >> I have matched a curve using graph paper and map out the coordinates >> into a list, example 5 in the attached is a demonstration of various >> shapes generated by point arrays >> >> >> HTH, >> >> Roger. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG antivirus software. www.avg.com
GB
Glenn Butcher
Mon, Jul 28, 2025 1:54 PM

Recently though, I've been coding more polygons with variables and
expressions in the tuples, can't posit a pretty tool for that...

On 7/28/2025 7:51 AM, Jon Bondy wrote:

Excellent!  I did something similar, but not as elegant!

On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote:

I got to using profile polygons so much I ended up writing a 'polygon
sketcher' program:

Just click in the window and it adds  points to the list. It's
OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list,
so I can paste it directly into code:

It's available here:

https://github.com/butcherg/wxpolygon

On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote:

Glenn

Must remember to use that, which I probably tripped over in the past
but forgot all about it.

I have matched a curve using graph paper and map out the coordinates
into a list, example 5 in the attached is a demonstration of various
shapes generated by point arrays

HTH,

Roger.


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

Recently though, I've been coding more polygons with variables and expressions in the tuples, can't posit a pretty tool for that... On 7/28/2025 7:51 AM, Jon Bondy wrote: > > Excellent!  I did something similar, but not as elegant! > > > On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote: >> >> I got to using profile polygons so much I ended up writing a 'polygon >> sketcher' program: >> >> Just click in the window and it adds  points to the list. It's >> OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, >> so I can paste it directly into code: >> >> It's available here: >> >> https://github.com/butcherg/wxpolygon >> >> >> On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: >>> Glenn >>> >>> Must remember to use that, which I probably tripped over in the past >>> but forgot all about it. >>> >>> I have matched a curve using graph paper and map out the coordinates >>> into a list, example 5 in the attached is a demonstration of various >>> shapes generated by point arrays >>> >>> >>> HTH, >>> >>> Roger. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email todiscuss-leave@lists.openscad.org > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > Virus-free.www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
JB
Jon Bondy
Mon, Jul 28, 2025 2:03 PM

Glenn:

Ah.  Source code only.  I have a Pascal compiler, but not a C compiler,
so I am out.

If you ever provide a Windows EXE, please let me know.

Jon

On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote:

I got to using profile polygons so much I ended up writing a 'polygon
sketcher' program:

Just click in the window and it adds  points to the list.  It's
OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list,
so I can paste it directly into code:

It's available here:

https://github.com/butcherg/wxpolygon

On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote:

Glenn

Must remember to use that, which I probably tripped over in the past
but forgot all about it.

I have matched a curve using graph paper and map out the coordinates
into a list, example 5 in the attached is a demonstration of various
shapes generated by point arrays

HTH,

Roger.


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

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Glenn: Ah.  Source code only.  I have a Pascal compiler, but not a C compiler, so I am out. If you ever provide a Windows EXE, please let me know. Jon On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote: > > I got to using profile polygons so much I ended up writing a 'polygon > sketcher' program: > > Just click in the window and it adds  points to the list.  It's > OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, > so I can paste it directly into code: > > It's available here: > > https://github.com/butcherg/wxpolygon > > > On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: >> Glenn >> >> Must remember to use that, which I probably tripped over in the past >> but forgot all about it. >> >> I have matched a curve using graph paper and map out the coordinates >> into a list, example 5 in the attached is a demonstration of various >> shapes generated by point arrays >> >> >> HTH, >> >> Roger. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG antivirus software. www.avg.com
MH
Matthieu Hendriks
Mon, Jul 28, 2025 2:14 PM

If you want bezier curves added you can use my interactive tool :
https://digirent.nl/bezier.html  to create the segments.

It's partially in dutch but not very difficult. ("Gebruik dit punt"
means : use this point.)

// example of created segments

segments = [
[[205, 0],    [100,0],  [0, 0]],          // 0 eerste rechte lijn
met de klok mee
[[0, 0],    [0,17.5],  [0, 32]],          // 1 rechte lijn omhoog
op de 0 as
[[0, 32],    [0,41.5],  [8, 42]],        // 2 eerste curve naar
rechts omhoog bollend
[[8, 42],    [100,6],  [170,80]],          // 3 lange curve bolling
naar benedentweede curve
[[170, 80],  [185, 95],  [151, 120]],      // 4 korte curve
[[151,120],  [145, 125],  [160, 151]],    // 5
[[160,151],  [165, 160],  [168, 151]],    // 6
[[168,151],  [165, 130],  [183, 128]],    // 7
[[183,128],  [200, 130],  [197, 151]],    // 8
[[197,151],  [200, 160],  [205, 151]],    // 9
[[205,151],  [232, 120],  [185, 65]],      // 10
[[185,65],  [170, 45],  [201, 22]],        // 11
[[201,22],  [210, 15],  [205, 0]],        // 12
];

curve_points = createBezier(segments, 30);  // cretae all the points for
the desired curve
polygon(points = curve_points);

// library functions to create bezier curves

function createBezier(segments, steps_per_segment=20) =
let(
// Bereken alle punten per segment
segment_points = [
for(segment_idx = [0:len(segments)-1])
let(
segment = segments[segment_idx],
segment_result = bezier2(segment, steps_per_segment)
)
// Skip het laatste punt van elk segment behalve het
laatste (om duplicaten te vermijden)
segment_idx < len(segments) - 1
? [for(i = [0:len(segment_result)-2])
segment_result[i]]
: segment_result
]
)
// Flatten de array van arrays
[for(segment = segment_points, point = segment) point];

// Basis Bezier-functie voor 2D
function bezier2(points, steps) =
let(n = len(points) - 1)
[for(t = [0 : 1/steps : 1])
bezier_point(points, n, t)];

// Functie om een punt op de Bezier-curve te berekenen
function bezier_point(points, n, t) = n == 0 ?  points[0] : (1 - t) *
bezier_point(points, n - 1, t) + t * bezier_point([for(i = [1:n])
points[i]], n - 1, t);
module show_bezier_points(segments) {
for(segment = segments) {
for(p = segment) {
translate(p) color("red") circle(2);
}
// Teken controlelijnen
color("gray", 0.5)
for(i = [0:len(segment)-2]) {
hull() {
translate(segment[i]) circle(0.5);
translate(segment[i+1]) circle(0.5);
}
}
}

}
module polyline(points, radius = 0.5) {
for (i = [0 : len(points) - 2]) {
hull() {
translate(points[i]) circle(r = radius, $fn=20);
translate(points[i + 1]) circle(r = radius, $fn=20);
}
}
}

Met vriendelijke groet,

Matthieu Hendriks


email: mhendriks@digirent.nl

Glenn Butcher via Discuss schreef op 2025-07-28 15:54:

Recently though, I've been coding more polygons with variables and
expressions in the tuples, can't posit a pretty tool for that...

On 7/28/2025 7:51 AM, Jon Bondy wrote:

Excellent!  I did something similar, but not as elegant!

On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote:

I got to using profile polygons so much I ended up writing a 'polygon
sketcher' program:

Just click in the window and it adds  points to the list.  It's
OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list,
so I can paste it directly into code:

It's available here:

https://github.com/butcherg/wxpolygon

On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: Glenn

Must remember to use that, which I probably tripped over in the past
but forgot all about it.

I have matched a curve using graph paper and map out the coordinates
into a list, example 5 in the attached is a demonstration of various
shapes generated by point arrays

HTH,

Roger.


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

	 [1]
	Virus-free.www.avg.com [1]

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

Links:

[1]
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient

If you want bezier curves added you can use my interactive tool : https://digirent.nl/bezier.html to create the segments. It's partially in dutch but not very difficult. ("Gebruik dit punt" means : use this point.) // example of created segments segments = [ [[205, 0], [100,0], [0, 0]], // 0 eerste rechte lijn met de klok mee [[0, 0], [0,17.5], [0, 32]], // 1 rechte lijn omhoog op de 0 as [[0, 32], [0,41.5], [8, 42]], // 2 eerste curve naar rechts omhoog bollend [[8, 42], [100,6], [170,80]], // 3 lange curve bolling naar benedentweede curve [[170, 80], [185, 95], [151, 120]], // 4 korte curve [[151,120], [145, 125], [160, 151]], // 5 [[160,151], [165, 160], [168, 151]], // 6 [[168,151], [165, 130], [183, 128]], // 7 [[183,128], [200, 130], [197, 151]], // 8 [[197,151], [200, 160], [205, 151]], // 9 [[205,151], [232, 120], [185, 65]], // 10 [[185,65], [170, 45], [201, 22]], // 11 [[201,22], [210, 15], [205, 0]], // 12 ]; curve_points = createBezier(segments, 30); // cretae all the points for the desired curve polygon(points = curve_points); // library functions to create bezier curves function createBezier(segments, steps_per_segment=20) = let( // Bereken alle punten per segment segment_points = [ for(segment_idx = [0:len(segments)-1]) let( segment = segments[segment_idx], segment_result = bezier2(segment, steps_per_segment) ) // Skip het laatste punt van elk segment behalve het laatste (om duplicaten te vermijden) segment_idx < len(segments) - 1 ? [for(i = [0:len(segment_result)-2]) segment_result[i]] : segment_result ] ) // Flatten de array van arrays [for(segment = segment_points, point = segment) point]; // Basis Bezier-functie voor 2D function bezier2(points, steps) = let(n = len(points) - 1) [for(t = [0 : 1/steps : 1]) bezier_point(points, n, t)]; // Functie om een punt op de Bezier-curve te berekenen function bezier_point(points, n, t) = n == 0 ? points[0] : (1 - t) * bezier_point(points, n - 1, t) + t * bezier_point([for(i = [1:n]) points[i]], n - 1, t); module show_bezier_points(segments) { for(segment = segments) { for(p = segment) { translate(p) color("red") circle(2); } // Teken controlelijnen color("gray", 0.5) for(i = [0:len(segment)-2]) { hull() { translate(segment[i]) circle(0.5); translate(segment[i+1]) circle(0.5); } } } } module polyline(points, radius = 0.5) { for (i = [0 : len(points) - 2]) { hull() { translate(points[i]) circle(r = radius, $fn=20); translate(points[i + 1]) circle(r = radius, $fn=20); } } } Met vriendelijke groet, Matthieu Hendriks ------------------------- email: mhendriks@digirent.nl Glenn Butcher via Discuss schreef op 2025-07-28 15:54: > Recently though, I've been coding more polygons with variables and > expressions in the tuples, can't posit a pretty tool for that... > > On 7/28/2025 7:51 AM, Jon Bondy wrote: > > Excellent! I did something similar, but not as elegant! > > On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote: > > I got to using profile polygons so much I ended up writing a 'polygon > sketcher' program: > > Just click in the window and it adds points to the list. It's > OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, > so I can paste it directly into code: > > It's available here: > > https://github.com/butcherg/wxpolygon > > On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: Glenn > > Must remember to use that, which I probably tripped over in the past > but forgot all about it. > > I have matched a curve using graph paper and map out the coordinates > into a list, example 5 in the attached is a demonstration of various > shapes generated by point arrays > > HTH, > > Roger. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org [1] Virus-free.www.avg.com [1] _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org Links: ------ [1] http://www.avg.com/email-signature?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient
GB
Glenn Butcher
Mon, Jul 28, 2025 2:17 PM

Jon, there's a Windows installer in the Releases page, look to the right

  • version 1.2.1 is the most current.

On 7/28/2025 8:03 AM, Jon Bondy wrote:

Glenn:

Ah.  Source code only.  I have a Pascal compiler, but not a C
compiler, so I am out.

If you ever provide a Windows EXE, please let me know.

Jon

On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote:

I got to using profile polygons so much I ended up writing a 'polygon
sketcher' program:

Just click in the window and it adds  points to the list. It's
OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list,
so I can paste it directly into code:

It's available here:

https://github.com/butcherg/wxpolygon

On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote:

Glenn

Must remember to use that, which I probably tripped over in the past
but forgot all about it.

I have matched a curve using graph paper and map out the coordinates
into a list, example 5 in the attached is a demonstration of various
shapes generated by point arrays

HTH,

Roger.


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

Jon, there's a Windows installer in the Releases page, look to the right - version 1.2.1 is the most current. On 7/28/2025 8:03 AM, Jon Bondy wrote: > > Glenn: > > Ah.  Source code only.  I have a Pascal compiler, but not a C > compiler, so I am out. > > If you ever provide a Windows EXE, please let me know. > > Jon > > > On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote: >> >> I got to using profile polygons so much I ended up writing a 'polygon >> sketcher' program: >> >> Just click in the window and it adds  points to the list. It's >> OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, >> so I can paste it directly into code: >> >> It's available here: >> >> https://github.com/butcherg/wxpolygon >> >> >> On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: >>> Glenn >>> >>> Must remember to use that, which I probably tripped over in the past >>> but forgot all about it. >>> >>> I have matched a curve using graph paper and map out the coordinates >>> into a list, example 5 in the attached is a demonstration of various >>> shapes generated by point arrays >>> >>> >>> HTH, >>> >>> Roger. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email todiscuss-leave@lists.openscad.org > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > Virus-free.www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
GS
Guenther Sohler
Mon, Jul 28, 2025 2:32 PM

Hey, this is a great  tool!

I am just wondering how to add /remove points from within  one bezier curve
...

On Mon, Jul 28, 2025 at 4:14 PM Matthieu Hendriks via Discuss <
discuss@lists.openscad.org> wrote:

If you want bezier curves added you can use my interactive tool :
https://digirent.nl/bezier.html  to create the segments.

It's partially in dutch but not very difficult. ("Gebruik dit punt"  means
: use this point.)
// example of created segments

segments = [
[[205, 0],    [100,0],  [0, 0]],          // 0 eerste rechte lijn
met de klok mee
[[0, 0],    [0,17.5],  [0, 32]],          // 1 rechte lijn omhoog op
de 0 as
[[0, 32],    [0,41.5],  [8, 42]],        // 2 eerste curve naar
rechts omhoog bollend
[[8, 42],    [100,6],  [170,80]],          // 3 lange curve bolling
naar benedentweede curve
[[170, 80],  [185, 95],  [151, 120]],      // 4 korte curve
[[151,120],  [145, 125],  [160, 151]],    // 5
[[160,151],  [165, 160],  [168, 151]],    // 6
[[168,151],  [165, 130],  [183, 128]],    // 7
[[183,128],  [200, 130],  [197, 151]],    // 8
[[197,151],  [200, 160],  [205, 151]],    // 9
[[205,151],  [232, 120],  [185, 65]],      // 10
[[185,65],  [170, 45],  [201, 22]],        // 11
[[201,22],  [210, 15],  [205, 0]],        // 12
];

curve_points = createBezier(segments, 30);  // cretae all the points for
the desired curve
polygon(points = curve_points);

// library functions to create bezier curves
function createBezier(segments, steps_per_segment=20) =
let(
// Bereken alle punten per segment
segment_points = [
for(segment_idx = [0:len(segments)-1])
let(
segment = segments[segment_idx],
segment_result = bezier2(segment, steps_per_segment)
)
// Skip het laatste punt van elk segment behalve het
laatste (om duplicaten te vermijden)
segment_idx < len(segments) - 1
? [for(i = [0:len(segment_result)-2])
segment_result[i]]
: segment_result
]
)
// Flatten de array van arrays
[for(segment = segment_points, point = segment) point];

// Basis Bezier-functie voor 2D
function bezier2(points, steps) =
let(n = len(points) - 1)
[for(t = [0 : 1/steps : 1])
bezier_point(points, n, t)];

// Functie om een punt op de Bezier-curve te berekenen
function bezier_point(points, n, t) = n == 0 ?  points[0] : (1 - t) *
bezier_point(points, n - 1, t) + t * bezier_point([for(i = [1:n])
points[i]], n - 1, t);
module show_bezier_points(segments) {
for(segment = segments) {
for(p = segment) {
translate(p) color("red") circle(2);
}
// Teken controlelijnen
color("gray", 0.5)
for(i = [0:len(segment)-2]) {
hull() {
translate(segment[i]) circle(0.5);
translate(segment[i+1]) circle(0.5);
}
}
}

}
module polyline(points, radius = 0.5) {
for (i = [0 : len(points) - 2]) {
hull() {
translate(points[i]) circle(r = radius, $fn=20);
translate(points[i + 1]) circle(r = radius, $fn=20);
}
}
}

Met vriendelijke groet,

Matthieu Hendriks


email: mhendriks@digirent.nl

Glenn Butcher via Discuss schreef op 2025-07-28 15:54:

Recently though, I've been coding more polygons with variables and
expressions in the tuples, can't posit a pretty tool for that...
On 7/28/2025 7:51 AM, Jon Bondy wrote:

Excellent!  I did something similar, but not as elegant!

On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote:

I got to using profile polygons so much I ended up writing a 'polygon
sketcher' program:

Just click in the window and it adds  points to the list.  It's
OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, so I
can paste it directly into code:

It's available here:

https://github.com/butcherg/wxpolygon

On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote:

Glenn

Must remember to use that, which I probably tripped over in the past but
forgot all about it.

I have matched a curve using graph paper and map out the coordinates into
a list, example 5 in the attached is a demonstration of various shapes
generated by point arrays

HTH,

Roger.


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

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
Virus-free.www.avg.com
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient


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

Hey, this is a great tool! I am just wondering how to add /remove points from within one bezier curve ... On Mon, Jul 28, 2025 at 4:14 PM Matthieu Hendriks via Discuss < discuss@lists.openscad.org> wrote: > If you want bezier curves added you can use my interactive tool : > https://digirent.nl/bezier.html to create the segments. > > It's partially in dutch but not very difficult. ("Gebruik dit punt" means > : use this point.) > // example of created segments > > segments = [ > [[205, 0], [100,0], [0, 0]], // 0 eerste rechte lijn > met de klok mee > [[0, 0], [0,17.5], [0, 32]], // 1 rechte lijn omhoog op > de 0 as > [[0, 32], [0,41.5], [8, 42]], // 2 eerste curve naar > rechts omhoog bollend > [[8, 42], [100,6], [170,80]], // 3 lange curve bolling > naar benedentweede curve > [[170, 80], [185, 95], [151, 120]], // 4 korte curve > [[151,120], [145, 125], [160, 151]], // 5 > [[160,151], [165, 160], [168, 151]], // 6 > [[168,151], [165, 130], [183, 128]], // 7 > [[183,128], [200, 130], [197, 151]], // 8 > [[197,151], [200, 160], [205, 151]], // 9 > [[205,151], [232, 120], [185, 65]], // 10 > [[185,65], [170, 45], [201, 22]], // 11 > [[201,22], [210, 15], [205, 0]], // 12 > ]; > > curve_points = createBezier(segments, 30); // cretae all the points for > the desired curve > polygon(points = curve_points); > > > // library functions to create bezier curves > function createBezier(segments, steps_per_segment=20) = > let( > // Bereken alle punten per segment > segment_points = [ > for(segment_idx = [0:len(segments)-1]) > let( > segment = segments[segment_idx], > segment_result = bezier2(segment, steps_per_segment) > ) > // Skip het laatste punt van elk segment behalve het > laatste (om duplicaten te vermijden) > segment_idx < len(segments) - 1 > ? [for(i = [0:len(segment_result)-2]) > segment_result[i]] > : segment_result > ] > ) > // Flatten de array van arrays > [for(segment = segment_points, point = segment) point]; > > // Basis Bezier-functie voor 2D > function bezier2(points, steps) = > let(n = len(points) - 1) > [for(t = [0 : 1/steps : 1]) > bezier_point(points, n, t)]; > > // Functie om een punt op de Bezier-curve te berekenen > function bezier_point(points, n, t) = n == 0 ? points[0] : (1 - t) * > bezier_point(points, n - 1, t) + t * bezier_point([for(i = [1:n]) > points[i]], n - 1, t); > module show_bezier_points(segments) { > for(segment = segments) { > for(p = segment) { > translate(p) color("red") circle(2); > } > // Teken controlelijnen > color("gray", 0.5) > for(i = [0:len(segment)-2]) { > hull() { > translate(segment[i]) circle(0.5); > translate(segment[i+1]) circle(0.5); > } > } > } > > } > module polyline(points, radius = 0.5) { > for (i = [0 : len(points) - 2]) { > hull() { > translate(points[i]) circle(r = radius, $fn=20); > translate(points[i + 1]) circle(r = radius, $fn=20); > } > } > } > > Met vriendelijke groet, > > Matthieu Hendriks > > ------------------------------ > email: mhendriks@digirent.nl > > > > Glenn Butcher via Discuss schreef op 2025-07-28 15:54: > > Recently though, I've been coding more polygons with variables and > expressions in the tuples, can't posit a pretty tool for that... > On 7/28/2025 7:51 AM, Jon Bondy wrote: > > Excellent! I did something similar, but not as elegant! > > > On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote: > > I got to using profile polygons so much I ended up writing a 'polygon > sketcher' program: > > Just click in the window and it adds points to the list. It's > OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, so I > can paste it directly into code: > > > > It's available here: > > https://github.com/butcherg/wxpolygon > > > On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: > > Glenn > > Must remember to use that, which I probably tripped over in the past but > forgot all about it. > > I have matched a curve using graph paper and map out the coordinates into > a list, example 5 in the attached is a demonstration of various shapes > generated by point arrays > > > HTH, > > Roger. > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > Virus-free.www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > > > _______________________________________________ > 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 >
MH
Matthieu Hendriks
Mon, Jul 28, 2025 2:42 PM

Just uncheck the box "Gebruik dit punt"  (use this point) or edit the
generated segments array and Apply Changes.

You can also copy paste from scad code the segments array in the text
field and do apply changes if you want to change later.

Met vriendelijke groet,

Matthieu Hendriks


email: mhendriks@digirent.nl

Guenther Sohler via Discuss schreef op 2025-07-28 16:32:

Hey, this is a great  tool!

I am just wondering how to add /remove points from within  one bezier
curve ...

On Mon, Jul 28, 2025 at 4:14 PM Matthieu Hendriks via Discuss
discuss@lists.openscad.org wrote:

If you want bezier curves added you can use my interactive tool :
https://digirent.nl/bezier.html  to create the segments.

It's partially in dutch but not very difficult. ("Gebruik dit punt"
means : use this point.)

// example of created segments

segments = [
[[205, 0],    [100,0],  [0, 0]],          // 0 eerste rechte lijn met
de klok mee
[[0, 0],    [0,17.5],  [0, 32]],          // 1 rechte lijn omhoog op
de 0 as
[[0, 32],    [0,41.5],  [8, 42]],        // 2 eerste curve naar
rechts omhoog bollend
[[8, 42],    [100,6],  [170,80]],          // 3 lange curve bolling
naar benedentweede curve
[[170, 80],  [185, 95],  [151, 120]],      // 4 korte curve
[[151,120],  [145, 125],  [160, 151]],    // 5
[[160,151],  [165, 160],  [168, 151]],    // 6
[[168,151],  [165, 130],  [183, 128]],    // 7
[[183,128],  [200, 130],  [197, 151]],    // 8
[[197,151],  [200, 160],  [205, 151]],    // 9
[[205,151],  [232, 120],  [185, 65]],      // 10
[[185,65],  [170, 45],  [201, 22]],        // 11
[[201,22],  [210, 15],  [205, 0]],        // 12
];

curve_points = createBezier(segments, 30);  // cretae all the points
for the desired curve
polygon(points = curve_points);

// library functions to create bezier curves

function createBezier(segments, steps_per_segment=20) =
let(
// Bereken alle punten per segment
segment_points = [
for(segment_idx = [0:len(segments)-1])
let(
segment = segments[segment_idx],
segment_result = bezier2(segment, steps_per_segment)
)
// Skip het laatste punt van elk segment behalve het laatste (om
duplicaten te vermijden)
segment_idx < len(segments) - 1
? [for(i = [0:len(segment_result)-2]) segment_result[i]]
: segment_result
]
)
// Flatten de array van arrays
[for(segment = segment_points, point = segment) point];

// Basis Bezier-functie voor 2D
function bezier2(points, steps) =
let(n = len(points) - 1)
[for(t = [0 : 1/steps : 1])
bezier_point(points, n, t)];

// Functie om een punt op de Bezier-curve te berekenen
function bezier_point(points, n, t) = n == 0 ?  points[0] : (1 - t) *
bezier_point(points, n - 1, t) + t * bezier_point([for(i = [1:n])
points[i]], n - 1, t);
module show_bezier_points(segments) {
for(segment = segments) {
for(p = segment) {
translate(p) color("red") circle(2);
}
// Teken controlelijnen
color("gray", 0.5)
for(i = [0:len(segment)-2]) {
hull() {
translate(segment[i]) circle(0.5);
translate(segment[i+1]) circle(0.5);
}
}
}

}
module polyline(points, radius = 0.5) {
for (i = [0 : len(points) - 2]) {
hull() {
translate(points[i]) circle(r = radius, $fn=20);
translate(points[i + 1]) circle(r = radius, $fn=20);
}
}
}

Met vriendelijke groet,

Matthieu Hendriks


email: mhendriks@digirent.nl

Glenn Butcher via Discuss schreef op 2025-07-28 15:54:

Recently though, I've been coding more polygons with variables and
expressions in the tuples, can't posit a pretty tool for that...

On 7/28/2025 7:51 AM, Jon Bondy wrote:

Excellent!  I did something similar, but not as elegant!

On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote:

I got to using profile polygons so much I ended up writing a 'polygon
sketcher' program:

Just click in the window and it adds  points to the list.  It's
OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list,
so I can paste it directly into code:

It's available here:

https://github.com/butcherg/wxpolygon

On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: Glenn

Must remember to use that, which I probably tripped over in the past
but forgot all about it.

I have matched a curve using graph paper and map out the coordinates
into a list, example 5 in the attached is a demonstration of various
shapes generated by point arrays

HTH,

Roger.


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

	 [1]
	Virus-free.www.avg.com [1]

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

Links:

[1]
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient

Just uncheck the box "Gebruik dit punt" (use this point) or edit the generated segments array and Apply Changes. You can also copy paste from scad code the segments array in the text field and do apply changes if you want to change later. Met vriendelijke groet, Matthieu Hendriks ------------------------- email: mhendriks@digirent.nl Guenther Sohler via Discuss schreef op 2025-07-28 16:32: > Hey, this is a great tool! > > I am just wondering how to add /remove points from within one bezier > curve ... > > On Mon, Jul 28, 2025 at 4:14 PM Matthieu Hendriks via Discuss > <discuss@lists.openscad.org> wrote: > > If you want bezier curves added you can use my interactive tool : > https://digirent.nl/bezier.html to create the segments. > > It's partially in dutch but not very difficult. ("Gebruik dit punt" > means : use this point.) > > // example of created segments > > segments = [ > [[205, 0], [100,0], [0, 0]], // 0 eerste rechte lijn met > de klok mee > [[0, 0], [0,17.5], [0, 32]], // 1 rechte lijn omhoog op > de 0 as > [[0, 32], [0,41.5], [8, 42]], // 2 eerste curve naar > rechts omhoog bollend > [[8, 42], [100,6], [170,80]], // 3 lange curve bolling > naar benedentweede curve > [[170, 80], [185, 95], [151, 120]], // 4 korte curve > [[151,120], [145, 125], [160, 151]], // 5 > [[160,151], [165, 160], [168, 151]], // 6 > [[168,151], [165, 130], [183, 128]], // 7 > [[183,128], [200, 130], [197, 151]], // 8 > [[197,151], [200, 160], [205, 151]], // 9 > [[205,151], [232, 120], [185, 65]], // 10 > [[185,65], [170, 45], [201, 22]], // 11 > [[201,22], [210, 15], [205, 0]], // 12 > ]; > > curve_points = createBezier(segments, 30); // cretae all the points > for the desired curve > polygon(points = curve_points); > > // library functions to create bezier curves > > function createBezier(segments, steps_per_segment=20) = > let( > // Bereken alle punten per segment > segment_points = [ > for(segment_idx = [0:len(segments)-1]) > let( > segment = segments[segment_idx], > segment_result = bezier2(segment, steps_per_segment) > ) > // Skip het laatste punt van elk segment behalve het laatste (om > duplicaten te vermijden) > segment_idx < len(segments) - 1 > ? [for(i = [0:len(segment_result)-2]) segment_result[i]] > : segment_result > ] > ) > // Flatten de array van arrays > [for(segment = segment_points, point = segment) point]; > > // Basis Bezier-functie voor 2D > function bezier2(points, steps) = > let(n = len(points) - 1) > [for(t = [0 : 1/steps : 1]) > bezier_point(points, n, t)]; > > // Functie om een punt op de Bezier-curve te berekenen > function bezier_point(points, n, t) = n == 0 ? points[0] : (1 - t) * > bezier_point(points, n - 1, t) + t * bezier_point([for(i = [1:n]) > points[i]], n - 1, t); > module show_bezier_points(segments) { > for(segment = segments) { > for(p = segment) { > translate(p) color("red") circle(2); > } > // Teken controlelijnen > color("gray", 0.5) > for(i = [0:len(segment)-2]) { > hull() { > translate(segment[i]) circle(0.5); > translate(segment[i+1]) circle(0.5); > } > } > } > > } > module polyline(points, radius = 0.5) { > for (i = [0 : len(points) - 2]) { > hull() { > translate(points[i]) circle(r = radius, $fn=20); > translate(points[i + 1]) circle(r = radius, $fn=20); > } > } > } > > Met vriendelijke groet, > > Matthieu Hendriks > > ------------------------- > > email: mhendriks@digirent.nl > > Glenn Butcher via Discuss schreef op 2025-07-28 15:54: > > Recently though, I've been coding more polygons with variables and > expressions in the tuples, can't posit a pretty tool for that... > > On 7/28/2025 7:51 AM, Jon Bondy wrote: > > Excellent! I did something similar, but not as elegant! > > On 7/28/2025 9:44 AM, Glenn Butcher via Discuss wrote: > > I got to using profile polygons so much I ended up writing a 'polygon > sketcher' program: > > Just click in the window and it adds points to the list. It's > OpenSCAD-centric, copy-to-clipboard is formatted as an OpenSCAD list, > so I can paste it directly into code: > > It's available here: > > https://github.com/butcherg/wxpolygon > > On 7/28/2025 2:46 AM, Roger Whiteley via Discuss wrote: Glenn > > Must remember to use that, which I probably tripped over in the past > but forgot all about it. > > I have matched a curve using graph paper and map out the coordinates > into a list, example 5 in the attached is a demonstration of various > shapes generated by point arrays > > HTH, > > Roger. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org [1] Virus-free.www.avg.com [1] _______________________________________________ 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 Links: ------ [1] http://www.avg.com/email-signature?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient