curveTo finding the curve point dynamically
My math knowledge has never been very broad, so this maybe a simple question but I'm not really sure.
Basically I'm using the curveTo function to draw some lines for flight paths, what I'm not sure how to do is dynamically finding the curve points, so for example if you look at the ryan air site: http://www.ryanair.com/en/cheap-flight-destinations all the lines are curved nicely.
current_line.graphics.curveTo(curveX, curveY, map.m开发者_开发百科ouseX, map.mouseY);
I need to find the curveX and curveY
If you need anymore information, leave a comment and I'll answer any questions you have.
Thanks in advance
WillIf I've understood correctly, I could give you one possible answer, though it's very straightforward. I assume you want to find out how to plot a curve automatically between two points, to avoid just getting a straight line between your two points. So you need to calculate the control point's location.
A simple way would be to just use the y position of the start and end point to find the point that is exactly half way between them on the y-axis, then add some arbitrary value to that, and use it as the control point in the curveTo function. You could calculate the value to add by getting a percentage of the length of the line, so that each curve would look similarly curved.
This would make sense for a flight path type app, as all the curves would curve in an upward direction, mimicking how flight paths are drawn for plane routes. If you don't see what I mean let me know, I'll give you a simple example with real numbers. This may not even be what you're asking anyway!
Edit x4:
Seems coding directly into the answer box wasn't a good idea :P Here's the working, correct way to do it:
CS4 Version: http://dl.dropbox.com/u/3987391/AutoCurve.fla
CS3 Version: http://dl.dropbox.com/u/3987391/AutoCurve-CS3.fla
Let me know if you have problems still!
debu
精彩评论