Results 1 to 2 of 2
Thread: Linked Bezier Curves
 11062008, 03:08 PM #1Member
 Join Date
 Oct 2008
 Location
 UK
 Posts
 65
 Rep Power
 0
Linked Bezier Curves
I have a question that isn't specifically Java, but am not sure where to ask. My task is to draw a neck band on a cardigan. I have a cubic Bezier curve, drawn with Path2D.Double and curveTo, but thats maybe not that relevant. The user can manipulate this curve in my program.
The problem is: I want to draw another curve which starts and ends at specific places, which are the same distance (call this d) from the start and end points of the other curve. The points on my new curve are always distance d from one point on my original curve. See the attachment for an illustration (although this is not a cubic curve, its just knocked up in MS Paint :)).
I have started to implement this by the following algorithm:
 Write a function bezierDiff(t), which differentiates the Bezier curve.
 For each point, t, calculate the perpendicular = 1/bezierDiff(t).
 Use Pythagras's theorem to find the location of the two points on the perpendicular, which are d units away.
 Write a function newCurvePoint(t), which returns a Point2D.Double object. It uses the previous calculations to get the two points then chooses the correct one.
 You have to find out the starting and ending values of t, to plug into newCurvePoint. Note that these will not necessarily be 0 and 1 since I want one start point to be directly below the Bezier start, and the other to be directly to the left of it. You have to solve cubic equations to do this.
 Use a simple for loop to construct a series of line segments from the start to the end, this approximates the required curve.
The algebra behind this is really messy and its a complicated approach. Is there an easier way to solve the problem? In particular, can the new curve be constructed as a Bezier curve, and if so, is there any easy way of finding the control points? I have tried various heuristics but none give a consistent distance between the two curves.
Thanks (in anticipation)
Paul
 11152008, 06:12 PM #2
Sergei Bernstein
Okay, it's messy. I have found that it is in general simpler to write someting that is not otherwise available in Java, your posts seem to demonstrate the needed skill level. Try this:
Bezier Demo
and
Bill Casselman
In general, it will be dy/dx at some point and doing some simple trig to get the normal, or more correctly as you posted. I have been working on some deep problems in ai and this sort of advanced problem but readymade and handydandy solutions used in an OO manner tend to not have sophisticated and advanced work acutally done.
I had a friend who was a tanker for the Army, who had a contact in advanced programming. This was that person's advice also. I suggest diggin in, if a mathemetician can provide the correct formulae, coding devolves easily.
{ should be moved to "Programming in General"}Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Similar Threads

Q:Applet with graphicWindow using openGL to draw lines,Curves etc
By gsmurthy30 in forum Java AppletsReplies: 1Last Post: 06302010, 07:12 PM 
Linked List help
By neobie in forum New To JavaReplies: 8Last Post: 12222007, 04:15 AM 
Linked List
By rnavarro9 in forum New To JavaReplies: 0Last Post: 11292007, 04:42 AM 
question about linked lists
By jkurth in forum Advanced JavaReplies: 1Last Post: 11112007, 09:33 AM 
Help with linked list
By trill in forum New To JavaReplies: 1Last Post: 08072007, 07:29 AM
Bookmarks