Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #3078 > unrolled thread
| Started by | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| First post | 2017-05-20 06:28 -0700 |
| Last post | 2017-06-10 03:02 -0700 |
| Articles | 20 — 2 participants |
Back to article view | Back to comp.lang.postscript
Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-20 06:28 -0700
Re: Sin wave with PostScript-style cubic Bézier curves tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2017-05-20 18:34 -0400
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-21 02:39 -0700
Re: Sin wave with PostScript-style cubic Bézier curves tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2017-05-22 01:05 -0400
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-23 12:20 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-23 13:55 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-23 13:57 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-23 13:58 -0700
Re: Sin wave with PostScript-style cubic Bézier curves tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2017-05-24 04:47 -0400
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-25 12:54 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-25 14:42 -0700
Re: Sin wave with PostScript-style cubic Bézier curves tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2017-05-26 02:05 -0400
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-26 13:40 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-26 17:01 -0700
Re: Sin wave with PostScript-style cubic Bézier curves tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2017-05-27 00:46 -0400
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-27 06:27 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-27 11:18 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-05-27 13:56 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-06-03 10:19 -0700
Re: Sin wave with PostScript-style cubic Bézier curves jdaw1 <jdawiseman@gmail.com> - 2017-06-10 03:02 -0700
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-20 06:28 -0700 |
| Subject | Sin wave with PostScript-style cubic Bézier curves |
| Message-ID | <ef19f210-1970-4669-9709-9eb1b4ed572a@googlegroups.com> |
I meant to post this topic here, but erroneously posted in adobe.postscript.programming. Sorry. https://groups.google.com/forum/#!topic/adobe.postscript.programming/3hU2yyoMmaM
[toc] | [next] | [standalone]
| From | tlvp <mPiOsUcB.EtLlLvEp@att.net> |
|---|---|
| Date | 2017-05-20 18:34 -0400 |
| Message-ID | <2lcze91yl45g.141yfaei55yyz.dlg@40tude.net> |
| In reply to | #3078 |
On Sat, 20 May 2017 06:28:08 -0700 (PDT), jdaw1 wrote: > I meant to post this topic here, but erroneously posted in adobe.postscript.programming. Sorry. > > https://groups.google.com/forum/#!topic/adobe.postscript.programming/3hU2yyoMmaM Interesting findings. When I think "Bezier approx to sine wave" I think "cubic poly approx to sine wave", and that leads me to think "cubic fragment of Taylor expansion (of power series) at the origin" for sine wave, which leads me to: : x - (1/6)(x^3) . How accurate an approximation is that, over the interval [-pi/2, +pi/2] ? Can it be much worse than the Bezier approx? Might they have to coincide? (Questions, really, for comp.sci.math :-) .) Cheers, -- tlvp -- Avant de repondre, jeter la poubelle, SVP.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-21 02:39 -0700 |
| Message-ID | <aba96943-cc2f-4c71-bf2a-cc0cd0a2f1ae@googlegroups.com> |
| In reply to | #3079 |
If the x value must be a linear function of t, then y might indeed be Taylor-esque. But both x and y can be cubic in t, which gives much more flexibility. I have Mathematica and Excel files: worth uploading?
[toc] | [prev] | [next] | [standalone]
| From | tlvp <mPiOsUcB.EtLlLvEp@att.net> |
|---|---|
| Date | 2017-05-22 01:05 -0400 |
| Message-ID | <3zdyqlbsj7m1.1oujbut2hqd10.dlg@40tude.net> |
| In reply to | #3081 |
On Sun, 21 May 2017 02:39:39 -0700 (PDT), jdaw1 wrote: > ... But both x and y can be cubic in t ... Oops! That's right. I'd overlooked that. So how were your control-points spread out along the x-axis? At equal intervals one from the next? I think that would force x to be linear in t. Anything else, probably not. Yes, it'd be interesting to learn what closed form expression Mathematica gives for that 2-parameter Bezier curve, if it's not just the Taylor poly. (And yes, I confess (mea culpa), I'm far too lazy to do by hand the matrix reductions calculating the x and y polynomials' coefficients require :-) .) Cheers, -- tlvp -- Avant de repondre, jeter la poubelle, SVP.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-23 12:20 -0700 |
| Message-ID | <00e3f223-1c92-4652-9802-77dd58349e4d@googlegroups.com> |
| In reply to | #3082 |
In the linked thread I wrote: > Let’s try to have a single curve be 180°. Want to go through end-points, with correct tangents, and also want the tangent in the middle to be at a slope of 1:1 = 45°. That defines everything: > y0 = y1 = -1 > y2 = y3 = +1 > x0 = -HalfPi > x1 = HalfPi - 2 > x2 = -x1 > x3 = -x0 > > The largest y error is about one part in 1/1302, which happens at about x ≈ ±1.004 ≈ 32.48°.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-23 13:55 -0700 |
| Message-ID | <12e466a7-c143-4edf-8e90-9f68b5e8dfeb@googlegroups.com> |
| In reply to | #3082 |
http://www.jdawiseman.com/2017/20170523%20_Bezier%20_QuarterSin.nb http://www.jdawiseman.com/2017/20170523%20_Bezier%20_HalfSin.nb
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-23 13:57 -0700 |
| Message-ID | <591fc439-eb3e-4523-8635-d0d133779507@googlegroups.com> |
| In reply to | #3085 |
Dratted Wolfram’s copy-paste inserts spaces. Why? Trying again: http://www.jdawiseman.com/2017/20170523_Bezier_HalfSin.nb http://www.jdawiseman.com/2017/20170523_Bezier_QuarterSin.nb
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-23 13:58 -0700 |
| Message-ID | <b3ebdbe0-5a8f-497b-969c-74798158d608@googlegroups.com> |
| In reply to | #3082 |
http://www.jdawiseman.com/2017/20170523_Bezier_HalfSin.nb http://www.jdawiseman.com/2017/20170523_Bezier_QuarterSin.nb
[toc] | [prev] | [next] | [standalone]
| From | tlvp <mPiOsUcB.EtLlLvEp@att.net> |
|---|---|
| Date | 2017-05-24 04:47 -0400 |
| Message-ID | <zjje0vnuw9i3.tq7pzeonx1mq$.dlg@40tude.net> |
| In reply to | #3087 |
On Tue, 23 May 2017 13:58:12 -0700 (PDT), jdaw1 wrote: > http://www.jdawiseman.com/2017/20170523_Bezier_HalfSin.nb > http://www.jdawiseman.com/2017/20170523_Bezier_QuarterSin.nb Alas, I have nothing here that can open Mathematica NoteBook files, which is, I take it, what these are. Any chance you can convert to Word? or PS? or PDF? or even a bmp file with a couple of handwritten formulae? Thanks, though, for the effort that surely entered into these things. Cheers, -- tlvp -- Avant de repondre, jeter la poubelle, SVP.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-25 12:54 -0700 |
| Message-ID | <e20a0e9e-8433-4c7f-81e2-147b47619873@googlegroups.com> |
| In reply to | #3089 |
On Wednesday, 24 May 2017 09:47:44 UTC+1, tlvp wrote: > Alas, I have nothing here that can open Mathematica NoteBook files http://www.jdawiseman.com/2017/20170523_Bezier_QuarterSin.pdf http://www.jdawiseman.com/2017/20170523_Bezier_HalfSin.pdf
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-25 14:42 -0700 |
| Message-ID | <e25df745-6287-4faa-9796-d5e5de172d96@googlegroups.com> |
| In reply to | #3090 |
… and http://www.jdawiseman.com/2017/20170525_Bezier_QuarterSin.xlsx http://www.jdawiseman.com/2017/20170525_Bezier_HalfSin.xlsx
[toc] | [prev] | [next] | [standalone]
| From | tlvp <mPiOsUcB.EtLlLvEp@att.net> |
|---|---|
| Date | 2017-05-26 02:05 -0400 |
| Message-ID | <p5xri3dd64fo.vsi3rzq10a30$.dlg@40tude.net> |
| In reply to | #3090 |
On Thu, 25 May 2017 12:54:22 -0700 (PDT), jdaw1 wrote: > On Wednesday, 24 May 2017 09:47:44 UTC+1, tlvp wrote: >> Alas, I have nothing here that can open Mathematica NoteBook files > > http://www.jdawiseman.com/2017/20170523_Bezier_QuarterSin.pdf > http://www.jdawiseman.com/2017/20170523_Bezier_HalfSin.pdf Thanks for these. But I have to ask: what are you using as z1 and z2? and have you investigated the difference, not between the sine function and your Bezier approx curve, but between your Bezier curve and the simple sine-power-series cubic approx curve, (x, y) = (t, t - (1/6)(t^3)) ? Thanks! Cheers, -- tlvp -- Avant de repondre, jeter la poubelle, SVP.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-26 13:40 -0700 |
| Message-ID | <04736928-d4f4-45cd-b227-212e787223f5@googlegroups.com> |
| In reply to | #3093 |
On Friday, 26 May 2017 07:05:01 UTC+1, tlvp wrote: > (x, y) = (t, t - (1/6)(t^3)) ? Even if you fix the value at t=1/2, the problem is that it doesn’t have the correct slope. Which means that joining it as repeated pieces leaves a corner at each join: yuck. It might help to describe my general technique. • There are four control points, so eight variables. • Must go through the endpoints. That leaves four variables, the inner control points. • Must have the correct slope at the ends. Which leaves two variables, which can be thought of as the speeds (but not directions) of leaving the ends. • A symmetry condition, speeds at ends equal, can drop another variable. • A requirement about the slope at t=1/2 can remove another variable. • Remaining variables, if any, are removed by minimising ∫(errorY)², wrt to something natural.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-26 17:01 -0700 |
| Message-ID | <e9cc4577-a0bf-4c24-a8ea-0c1b56c50aac@googlegroups.com> |
| In reply to | #3093 |
A worked example might help: a squircle, x⁴+y⁴=1. Let try a 90° piece. • Assume ends at (1,0) and (0,1). • At the ends an actual squircle is perpendicular to the axis, and we want four pieces to join without a corner, so mush have have the tangents correct. • Also want symmetry, so the middle control points must be (1,z) and (z,1), for some z. We have one free parameter, z. Let’s zero ∫(x⁴+y⁴−1)∂t. That happens with 0 = 126z⁴ + 405z³ + 804z² + 1337z - 2331, and z≥0 and z≤1, ⇒ z≈0.923490281758181. The Mathematica file has a plot of this, and it’s a disaster. The ‘radius’ reaches too small by ≈1/63.5, and reaches too big by ≈1/38.5. Even for a small squircle that’s multiple pixels. Obviously changing z won’t help. Increasing z, zooming away faster from the end points, would decrease the maximum negative error, but increase the maximum positive error. And the reverse for slower. But as both too big and too small are too wrong, the won’t help. http://www.jdawiseman.com/2017/20170527_Bezier_Quarter_Squircle.nb http://www.jdawiseman.com/2017/20170527_Bezier_Quarter_Squircle.pdf (FWLIW, it doesn't help to have the ends at x=½^¼, y=±½^¼.) So instead let’s try a 45° piece: a whole squircle requiring eight of these. • One end at (1,0). The other at (½^¼, ½^¼). • No symmetry, so two separate zoom speeds, but the tangents must still be correct so that eight pieces can join without corners. Hence point 1 is at (1,z1), and point 2 is at (½^¼+z2, ½^¼−z2). There are multiple ways to choose z1 and z2, though all sensible ways give very similar answers. Let’s say that the error is ∫(x⁴+y⁴−1)² ∂t, and minimise this error. That happens with z1≈0.3867415472306192 and z2≈0.1682449045330524. The worst error is now one part in 1299.6, which would be optically indistinguishable from perfect. http://www.jdawiseman.com/2017/20170527_Bezier_Eighth_Squircle.nb http://www.jdawiseman.com/2017/20170527_Bezier_Eighth_Squircle.pdf
[toc] | [prev] | [next] | [standalone]
| From | tlvp <mPiOsUcB.EtLlLvEp@att.net> |
|---|---|
| Date | 2017-05-27 00:46 -0400 |
| Message-ID | <1e1ytce3kx9ow$.kslv2ek2pns0$.dlg@40tude.net> |
| In reply to | #3096 |
On Fri, 26 May 2017 17:01:22 -0700 (PDT), jdaw1 wrote: > A worked example might help: a squircle, x⁴+y⁴=1. > > > Let try a 90° piece. > • Assume ends at (1,0) and (0,1). > • At the ends an actual squircle is perpendicular to the axis, and we want four pieces to join without a corner, so mush have have the tangents correct. > • Also want symmetry, so the middle control points must be (1,z) and (z,1), for some z. > > We have one free parameter, z. Let’s zero ∫(x⁴+y⁴−1)∂t. > > That happens with 0 = 126z⁴ + 405z³ + 804z² + 1337z - 2331, and z≥0 and z≤1, ⇒ z≈0.923490281758181. > > The Mathematica file has a plot of this, and it’s a disaster. The ‘radius’ reaches too small by ≈1/63.5, and reaches too big by ≈1/38.5. Even for a small squircle that’s multiple pixels. > > Obviously changing z won’t help. Increasing z, zooming away faster from the end points, would decrease the maximum negative error, but increase the maximum positive error. And the reverse for slower. But as both too big and too small are too wrong, the won’t help. > > http://www.jdawiseman.com/2017/20170527_Bezier_Quarter_Squircle.nb > http://www.jdawiseman.com/2017/20170527_Bezier_Quarter_Squircle.pdf > > (FWLIW, it doesn't help to have the ends at x=½^¼, y=±½^¼.) > > > So instead let’s try a 45° piece: a whole squircle requiring eight of these. > • One end at (1,0). The other at (½^¼, ½^¼). > • No symmetry, so two separate zoom speeds, but the tangents must still be correct so that eight pieces can join without corners. Hence point 1 is at (1,z1), and point 2 is at (½^¼+z2, ½^¼−z2). > > There are multiple ways to choose z1 and z2, though all sensible ways give very similar answers. Let’s say that the error is ∫(x⁴+y⁴−1)² ∂t, and minimise this error. That happens with z1≈0.3867415472306192 and z2≈0.1682449045330524. The worst error is now one part in 1299.6, which would be optically indistinguishable from perfect. > > http://www.jdawiseman.com/2017/20170527_Bezier_Eighth_Squircle.nb > http://www.jdawiseman.com/2017/20170527_Bezier_Eighth_Squircle.pdf Noted; thanks. Digesting ... . More once properly digested. Cheers, -- tlvp -- Avant de repondre, jeter la poubelle, SVP.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-27 06:27 -0700 |
| Message-ID | <8abf8b5a-b1e3-467b-8f94-7887abc8ffe0@googlegroups.com> |
| In reply to | #3097 |
A less mathematical variation. I want to draw a heart, in which each side is a single cubic Bézier curve. Please suggest improvements to http://www.jdawiseman.com/2017/20170527_Bezier_Heart.xlsx
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-27 11:18 -0700 |
| Message-ID | <0c903777-5502-49b3-9904-81c0f0d7d645@googlegroups.com> |
| In reply to | #3098 |
Spreadsheet updated. http://www.jdawiseman.com/2017/20170527_Bezier_Heart.xlsx
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-05-27 13:56 -0700 |
| Message-ID | <b72c6742-023a-4963-ae26-75fe9f61a025@googlegroups.com> |
| In reply to | #3099 |
Spreadsheet updated again. http://www.jdawiseman.com/2017/20170527_Bezier_Heart.xlsx Functionality added to make the spreadsheet, or variants thereof, of more general use. Please use.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-06-03 10:19 -0700 |
| Message-ID | <7a047b0f-b940-4fa9-940c-a16f2a2a10a4@googlegroups.com> |
| In reply to | #3100 |
Re-updated, again.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2017-06-10 03:02 -0700 |
| Message-ID | <d4194a76-fd0c-4783-a295-4a5179ff5aba@googlegroups.com> |
| In reply to | #3103 |
> Re-updated, again. Ditto.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web