Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3254
| From | "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: CubicCurve2D Tracing |
| Message-ID | <47d4dc2d$0$3298$7836cce5@newsrazor.net> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <b8bab04d-5b9f-45b1-a56e-1ebe8c83745f@e60g2000hsh.googlegroups.com> |
| Date | 2011-04-27 15:43 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui mearvk wrote: > On Mar 8, 12:29 pm, Daniel Pitts > <newsgroup.spamfil...@virtualinfinity.net> wrote: >> mearvk wrote: >>> Given an arbitrary CubicCurve2D how can I iterate along it getting >>> both the x and y coordinates of the current point as I go? >>> Thanks. >> Try: calling getPathIterator on it. >> <http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Shape.html#getPathIt...)> >> >> -- >> Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/> > > Looking at the API I think PathIterator's currentSegment() will just > get me the beginning, end and both control points. What I need is a > way to, for instance, find the length of or iterate over, pixel by > pixel, an arbitrary bezier curve. What I am actually doing is trying > to find the shortest path along a pair of bezier curves (think race > track) using a third bezier curve (think finding the apex). But how to > grade the quality of the current best path? Surely the simplest thing > to do would be to ask how long is the line? I was thinking if there > were a way to map the start, end, and both control points onto a > mathematical function, then I could just scale it appropriately and > iterate pixel by pixel, summing as I go, but I'm not sure if this can > be done. This might help: <http://java.sun.com/j2se/1.4.2/docs/api/java/awt/geom/FlatteningPathIterator.html> Also, Bezier curves are well defined mathematically, there is quite likely a formula to find the length given the endpoints and control points. A quick google turned up: <http://www.cit.gu.edu.au/~anthony/info/graphics/bezier.curves> Its actually an integral, so you are going about it in a reasonable way. FlatteningPathIterator is what you want. Just sum the distance between any two endpoints it gives you. -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/> --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
CubicCurve2D Tracing "mearvk" <mearvk@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: CubicCurve2D Tracing "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: CubicCurve2D Tracing "mearvk" <mearvk@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: CubicCurve2D Tracing "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: CubicCurve2D Tracing "mearvk" <mearvk@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: CubicCurve2D Tracing "tar" <tar@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
csiph-web