Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2008

Tip: Looking for answers? Try searching our database.

CubicCurve2D Tracing

Thread view: 
mearvk - 07 Mar 2008 12:53 GMT
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.
Daniel Pitts - 08 Mar 2008 17:29 GMT
> 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#getPathIterator(java
.awt.geom.AffineTransform
)>

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

mearvk - 09 Mar 2008 04:20 GMT
On Mar 8, 12:29 pm, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.net> 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?
[quoted text clipped - 6 lines]
> --
> 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.
Daniel Pitts - 10 Mar 2008 16:01 GMT
> On Mar 8, 12:29 pm, Daniel Pitts
> <newsgroup.spamfil...@virtualinfinity.net> wrote:
[quoted text clipped - 19 lines]
> 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.
Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

mearvk - 11 Mar 2008 11:02 GMT
On Mar 10, 11:01 am, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.net> wrote:
> > On Mar 8, 12:29 pm, Daniel Pitts
> > <newsgroup.spamfil...@virtualinfinity.net> wrote:
[quoted text clipped - 36 lines]
>
> - Show quoted text -

Thank you both.
Thomas A. Russ - 10 Mar 2008 18:56 GMT
Well, you can get some results by Googling "bezier curve length"

One promising approach, with C code, is:

 <http://steve.hollasch.net/cgindex/curves/cbezarclen.html>

Signature

Thomas A. Russ,  USC/Information Sciences Institute



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.