ambarry@vax1.tcd.ie (01/20/89)
Has anyone got pascal source code, for Bezier curves? I recently recieved the database for a goblet, but the writing of a program to plot the points is beyond me. Thanks, Adrian Barry, TCD, Ireland.
josef@ugun21.UUCP (01/23/89)
ambarry@vax1.UUCP (Adrian Barry) writes: > Has anyone got pascal source code, for Bezier curves? I recently >recieved the database for a goblet, but the writing of a program to plot the >points is beyond me. Well, I don't have any sources but in case nobody else has, take a look at the December 1986 issue of BYTE. On pages 225-230 there is an article Steve Enns Free-Form Curves on Your Micro This article quite nicely describes how to generate Bezier and B-spline curves. If You can't locate the article or if You need any help, feel free to contact me Josef Moellers paper mail: e-mail: c/o Nixdorf Computer AG USA: uunet!linus!nixbur!nixpbe!mollers.pad Abt. EG-3 !USA: mcvax!unido!nixpbe!mollers.pad Unterer Frankfurter Weg D-4790 Paderborn tel.: (+49) 5251 104691 Standard disclaimer: Blablabla opinion blablabla employer blablabla!
jos@idca.tds.PHILIPS.nl (Jos Vos) (01/23/89)
In article <30936@vax1.tcd.ie> ambarry@vax1.tcd.ie writes: > Has anyone got pascal source code, for Bezier curves? I recently >recieved the database for a goblet, but the writing of a program to plot the >points is beyond me. A related question (I think it's just the inverted algorithm...): I'm looking for a program that calculates the so called Bezier cubic control points when giving a number of points that should be placed in the resulting Bezier cubic section. I prefer C code, but any other code is welcome too. [ I want to use it for generating PostScript code for a certain figure, without using packages like Adobe Illustrator. ] -- -- ###### Jos Vos ###### Internet jos@idca.tds.philips.nl ###### -- ###### ###### UUCP ...!mcvax!philapd!jos ######
yuval@taux02.UUCP (Gideon Yuval) (01/25/89)
Both public-domain PostScript clones (Goswell's, and Deutsch's GhostScript) contain (obviously!) the code for Bezier curves. Goswell's code is the standard divide-&-conquer code: IF curve is sufficiently straight drwar straight line ELSE break into 2 smaller Beziers & recurse i THINK Deutsch uses the same algorithm, but am not sure. -- Gideon Yuval, yuval@taux01.nsc.com, +972-2-690992 (home) ,-52-522255(work) Paper-mail: National Semiconductor, 6 Maskit St., Herzliyah, Israel TWX: 33691, fax: +972-52-558322
rcd@ico.ISC.COM (Dick Dunn) (01/26/89)
> > Has anyone got pascal source code, for Bezier curves? I recently > >recieved the database for a goblet, but the writing of a program to plot the > >points is beyond me. I don't have the code written out and tested (well, I do, but it's in C and assembly language for some obscure hardware:-), but it turns out to be quite simple. Call the four control points of the curve A, B, C, and D in order (i.e., A and D are the endpoints). The algorithm requires bisecting segments--if we denote coordinates of points as A=(Ax,Ay), B=(Bx,By) then define Bisect(A,B) = ((Ax+Bx)/2, (Ay+By)/2) To get the points you need to plot, use a recursive algorithm which splits the curve until the segments are small enough or the angle between them is small enough. One step goes like this: First bisect each of the three segments from taking control points in order: P1 = Bisect(A,B) P2 = Bisect(B,C) P3 = Bisect(C,D) Now bisect each of the new segments formed by these: Q1 = Bisect(P1,P2) Q2 = Bisect(P2,P3) Finally, bisect that segment: R = Bisect(Q1,Q2) You now have two Bezier curves, each of which is shorter and flatter than the original. The control points for these curves are A-P1-Q1-R and R-Q2-P3-D. R lies on the curve. You can repeat the algorithm with each of the subcurves, or if you've gotten things down far enough, just draw segments AR and RD. > A related question (I think it's just the inverted algorithm...): > > I'm looking for a program that calculates the so called > Bezier cubic control points when giving a number of points > that should be placed in the resulting Bezier cubic section. This is a rather harder problem. Now, at first blush you might think that if you had the endpoints plus two points on the curve, you should be able to define the curve uniquely--after all, there are four control points, so it seems like the same number of degrees of freedom, but not so. Anyway, if you have a bunch of points, you're probably going to need to do a fit of the curve which minimizes some error criterion. I fiddled around with this for a little while, stumbling over the problem of trying to get a useful error criterion given the parametric representation...and eventually decided that I was too lazy to work it through, but I *would* like to see how it is done. -- Dick Dunn UUCP: {ncar,nbires}!ico!rcd (303)449-2870 ...A friend of the devil is a friend of mine.
ath@helios.prosys.se (Anders Thulin) (01/31/89)
In article <13960@ico.ISC.COM> rcd@ico.ISC.COM (Dick Dunn) writes: > >> A related question (I think it's just the inverted algorithm...): >> >> I'm looking for a program that calculates the so called >> Bezier cubic control points when giving a number of points >> that should be placed in the resulting Bezier cubic section. > > [...] I >decided that I was too lazy to work it through, but I *would* like to see >how it is done. I think that something along these lines is done in MetaFont. Check out Computers and Typesetting, vol IV by Knuth. -- Anders Thulin INET : ath@prosys.se ProgramSystem AB UUCP : ...!{uunet,mcvax}!enea!prosys!ath Teknikringen 2A PHONE: +46 (0)13 21 40 40 S-583 30 Linkoping, Sweden FAX : +46 (0)13 21 36 35