Re: [Flashcoders] Curves question for math gurus
Regarding those curve math questions... I truly appreciated everyone's help! Here is the result (clothesline navigation!) http://www.nfb.ca/cannes/ Many thanks! On 5/2/07 5:14 AM, Ivan Dembicki [EMAIL PROTECTED] wrote: Hello, Thank you, I redid my whole thing using your classes! Really super, more flexibility + less code ! Is there any doc online ? http://www.bezier.ru/eng/AS2/ru/bezier/geom/Bezier.html ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Hello, Thank you, I redid my whole thing using your classes! Really super, more flexibility + less code ! Is there any doc online ? http://www.bezier.ru/eng/AS2/ru/bezier/geom/Bezier.html -- iv ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Hello leolea I'm trying to figure out a way to have objects snap to this curved line. I would distribute them over the _x axis, and I need a formula to get their _y position on the curved line. - you need to find an intersections between 2D Bezier curve and vertical lines. Uou can use our geom package for it: http://www.bezier.ru/rus/AS2/sources/ru.bezier.zip good luck! -- iv ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Curves question for math gurus
Hello leolea I'm trying to figure out a way to have objects snap to this curved line. I would distribute them over the _x axis, and I need a formula to get their _y position on the curved line. - you need to find an intersections between 2D Bezier curve and vertical lines. Uou can use our geom package for it: http://www.bezier.ru/rus/AS2/sources/ru.bezier.zip good luck! Be aware, though, that the vertical line might well not give you the closest point on the curve. If you want to find the closest point on the bezier to a given point, that's a slightly different problem (for a quadratic bezier it amounts to solving a cubic equation) Best Danny ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Hello, a little demo: http://www.bezier.ru/tmp/answer_demo/ -- iv ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Thank you very much for this. The function you provided works super fine, but only once! If I call it in an onEnterFrame, here's what happens: http://pages.videotron.com/poubou/flash/cannes01.html Strange... or is it ? On 4/25/07 6:13 PM, Joshua Sera [EMAIL PROTECTED] wrote: Actually, you're right. if your endpoints will never move, you can still use a quadratic bezier. The percentage would be (mc._x - firstpoint.x)/(lastpoint.x - firstpoint.x) Since you're using curveTo, you already have all the points you need for the formula Here's a function for you: import flash.geom.Point; function getPoint(first:Point, last:Point, control:Point, ratio:Number):Point { var pReturn:Point = new Point(); var b:Number = 1-ratio; pReturn.x = (b*b*first.x) + (2*ratio*b*control.x) + (ratio*ratio*last.x); pReturn.y = (b*b*first.y) + (2*ratio*b*control.y) + (ratio*ratio*last.y); return pReturn; } first if the first point in your curve, last is the last, control is the point specified by the first two arguments in the curveTo method. This will give you the closest point on the line to your MC's position. If you only want to snap if the MC is within a certain distance, just check the difference of the ys of your mc's position, and the returned point. --- leolea [EMAIL PROTECTED] wrote: On 4/25/07 5:31 PM, Joshua Sera [EMAIL PROTECTED] wrote: If you know that the two endpoints of the curve are always going to have an equal x or y value, the you can just use the quadratic formula, and get the right Y value. The two endpoints will never move. The middlepoint will be the only one moving. So now I just need the quadratic formula ... I googled quadratic formula and I couldn't figure it out nor translate it to my Flash needs. Like I said, I'm (almost) totally math impaired ! If the endpoints are arbitrary, it's a bit more complicated. Bezier curves take a number from 0 to 1 and give you a point along the curve. Plugging 0 into the formula gives you the first endpoint, 1 gets you the last, and anything else gives you something in between. This means you're going to have to figure out where along the curve your MC is closest to, which involves some vector math. Since I know the _x position of MC, in order to figure out where the MC is along the curve... Can't I use its _x percentage: MC._x / (lastpoint.x - firstpoint.x) Just curious, but I don't think I need this since my two endpoints will not move. If you want, I can draw out the way I'd approach it. Of course I'd be more than happy to see that. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Okay no ... It was the way I calculated my ratio that wasn't good. Works perfectly ! Instead of calculating the ratio on each loop using the actual _x, I use an initx variable... // init var initx:Number = some_random_x; mc._x = initx; //onEnterFrame ratio = (mc.initx - firstpoint.x)/(lastpoint.x - firstpoint.x) Instead of: ratio = (mc._x - firstpoint.x)/(lastpoint.x - firstpoint.x) Many thanks !! On 4/26/07 8:43 AM, leolea [EMAIL PROTECTED] wrote: Thank you very much for this. The function you provided works super fine, but only once! If I call it in an onEnterFrame, here's what happens: http://pages.videotron.com/poubou/flash/cannes01.html Strange... or is it ? On 4/25/07 6:13 PM, Joshua Sera [EMAIL PROTECTED] wrote: Actually, you're right. if your endpoints will never move, you can still use a quadratic bezier. The percentage would be (mc._x - firstpoint.x)/(lastpoint.x - firstpoint.x) Since you're using curveTo, you already have all the points you need for the formula Here's a function for you: import flash.geom.Point; function getPoint(first:Point, last:Point, control:Point, ratio:Number):Point { var pReturn:Point = new Point(); var b:Number = 1-ratio; pReturn.x = (b*b*first.x) + (2*ratio*b*control.x) + (ratio*ratio*last.x); pReturn.y = (b*b*first.y) + (2*ratio*b*control.y) + (ratio*ratio*last.y); return pReturn; } first if the first point in your curve, last is the last, control is the point specified by the first two arguments in the curveTo method. This will give you the closest point on the line to your MC's position. If you only want to snap if the MC is within a certain distance, just check the difference of the ys of your mc's position, and the returned point. --- leolea [EMAIL PROTECTED] wrote: On 4/25/07 5:31 PM, Joshua Sera [EMAIL PROTECTED] wrote: If you know that the two endpoints of the curve are always going to have an equal x or y value, the you can just use the quadratic formula, and get the right Y value. The two endpoints will never move. The middlepoint will be the only one moving. So now I just need the quadratic formula ... I googled quadratic formula and I couldn't figure it out nor translate it to my Flash needs. Like I said, I'm (almost) totally math impaired ! If the endpoints are arbitrary, it's a bit more complicated. Bezier curves take a number from 0 to 1 and give you a point along the curve. Plugging 0 into the formula gives you the first endpoint, 1 gets you the last, and anything else gives you something in between. This means you're going to have to figure out where along the curve your MC is closest to, which involves some vector math. Since I know the _x position of MC, in order to figure out where the MC is along the curve... Can't I use its _x percentage: MC._x / (lastpoint.x - firstpoint.x) Just curious, but I don't think I need this since my two endpoints will not move. If you want, I can draw out the way I'd approach it. Of course I'd be more than happy to see that. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
On 4/26/07 5:50 AM, Danny Kodicek [EMAIL PROTECTED] wrote: Be aware, though, that the vertical line might well not give you the closest point on the curve. If you want to find the closest point on the bezier to a given point, that's a slightly different problem (for a quadratic bezier it amounts to solving a cubic equation) Would that explain why the pins don't always follow the line ? Or could that just be a sync problem ? http://pages.videotron.com/poubou/flash/cannes02.html When you release, it's a tween, and it stays snapped, but when you drag it seems out of sync. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Thank you, I redid my whole thing using your classes! Really super, more flexibility + less code ! Is there any doc online ? On 4/26/07 7:10 AM, Ivan Dembicki [EMAIL PROTECTED] wrote: Hello, a little demo: http://www.bezier.ru/tmp/answer_demo/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Leolea, Is there any doc online ? - now in russian only. translation in progress. -- iv ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Curves question for math gurus
Hi, I have a dynamically drawn curve. It's a simple curve, with 2 end points, and its yfactor will vary. I'm trying to figure out a way to have objects snap to this curved line. I would distribute them over the _x axis, and I need a formula to get their _y position on the curved line. Here is a visual explanation: http://pages.videotron.com/poubou/flash/curve.jpg Now, I guess this requires trigonometry... And I really am a newb when it comes to trig... Any help would be appreciated ! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Hi, Your typical funciton looks something like this in math books: f(x) = A*x + x^2 //just an example Where f(x) is essentially 'y'. So, you just need the equation that defines your curve. The curve in your jpg appears to be a circle. y = sqrt(x^2 + r^2) //where r is the radius That actually yields + or - and you just pick what fits your situation best. So, you pump in an x and get you 2 y's. Pick the best y and use it. Jobe Makar http://www.electrotank.com http://www.electro-server.com phone: 252-627-8026 mobile: 919-609-0408 fax: 919-882-1121 - Original Message - From: leolea [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Wednesday, April 25, 2007 3:34 PM Subject: [Flashcoders] Curves question for math gurus Hi, I have a dynamically drawn curve. It's a simple curve, with 2 end points, and its yfactor will vary. I'm trying to figure out a way to have objects snap to this curved line. I would distribute them over the _x axis, and I need a formula to get their _y position on the curved line. Here is a visual explanation: http://pages.videotron.com/poubou/flash/curve.jpg Now, I guess this requires trigonometry... And I really am a newb when it comes to trig... Any help would be appreciated ! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Hi, thanks for your reply! My curve isn't exactly a circle. Here's what my animated curve would look like: http://pages.videotron.com/poubou/flash/cannes01.html The curve is drawn using the drawing API: example: mc.moveTo(0,0); mc.curveTo(400,900,0,800); So, I know the 3 bezier points that define my curve: startpoint = 0,0 middlepoint = 400,900 endpoint = 800,0 With those values in hand, how can I apply them to your function: f(x) = A*x + x^2 Do I make any sense? On 4/25/07 3:50 PM, Jobe Makar [EMAIL PROTECTED] wrote: Hi, Your typical funciton looks something like this in math books: f(x) = A*x + x^2 //just an example Where f(x) is essentially 'y'. So, you just need the equation that defines your curve. The curve in your jpg appears to be a circle. y = sqrt(x^2 + r^2) //where r is the radius That actually yields + or - and you just pick what fits your situation best. So, you pump in an x and get you 2 y's. Pick the best y and use it. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Hi, The function that I gave you (A*x +x^2) was an arbitrary example. Looks like you'd need to use what ever bezier math is used by the Flash player to represent the line. Not the easiest thing to figure out, but here's a link that might help: http://www.moshplant.com/direct-or/bezier/math.html There might be tricks that we're not thinking of. For instance - take a bitmap snapshot of it in memory. Then use getPixel(x, y) to walk which ever column you're in until you reach a black pixel (or non-alpha if you use getPixel32). That's your y. Another trick is to position the clips on the line where they need to be when the line is at rest. Then displace them vertically based on the amplitude of the center displacement. Good luck. Jobe Makar http://www.electrotank.com http://www.electro-server.com phone: 252-627-8026 mobile: 919-609-0408 fax: 919-882-1121 - Original Message - From: leolea [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Wednesday, April 25, 2007 4:28 PM Subject: Re: [Flashcoders] Curves question for math gurus Hi, thanks for your reply! My curve isn't exactly a circle. Here's what my animated curve would look like: http://pages.videotron.com/poubou/flash/cannes01.html The curve is drawn using the drawing API: example: mc.moveTo(0,0); mc.curveTo(400,900,0,800); So, I know the 3 bezier points that define my curve: startpoint = 0,0 middlepoint = 400,900 endpoint = 800,0 With those values in hand, how can I apply them to your function: f(x) = A*x + x^2 Do I make any sense? On 4/25/07 3:50 PM, Jobe Makar [EMAIL PROTECTED] wrote: Hi, Your typical funciton looks something like this in math books: f(x) = A*x + x^2 //just an example Where f(x) is essentially 'y'. So, you just need the equation that defines your curve. The curve in your jpg appears to be a circle. y = sqrt(x^2 + r^2) //where r is the radius That actually yields + or - and you just pick what fits your situation best. So, you pump in an x and get you 2 y's. Pick the best y and use it. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
On 4/25/07 4:43 PM, Jobe Makar [EMAIL PROTECTED] wrote: Another trick is to position the clips on the line where they need to be when the line is at rest. Then displace them vertically based on the amplitude of the center displacement. I thought about this method... I could go with it. I tried reading your link... Looks like what I was looking for... but all this math/algebra/trigonometry is going to make my head explode. Or implode. Or both. Thank you very much ! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
A bezier curve would be one way to go about it. Flash's curveTo method uses a quadtratic curve though, so using a cubic curve won't give you an accurate curve. If you know that the two endpoints of the curve are always going to have an equal x or y value, the you can just use the quadratic formula, and get the right Y value. If the endpoints are arbitrary, it's a bit more complicated. Bezier curves take a number from 0 to 1 and give you a point along the curve. Plugging 0 into the formula gives you the first endpoint, 1 gets you the last, and anything else gives you something in between. This means you're going to have to figure out where along the curve your MC is closest to, which involves some vector math. If you want, I can draw out the way I'd approach it. --- leolea [EMAIL PROTECTED] wrote: Hi, thanks for your reply! My curve isn't exactly a circle. Here's what my animated curve would look like: http://pages.videotron.com/poubou/flash/cannes01.html The curve is drawn using the drawing API: example: mc.moveTo(0,0); mc.curveTo(400,900,0,800); So, I know the 3 bezier points that define my curve: startpoint = 0,0 middlepoint = 400,900 endpoint = 800,0 With those values in hand, how can I apply them to your function: f(x) = A*x + x^2 Do I make any sense? On 4/25/07 3:50 PM, Jobe Makar [EMAIL PROTECTED] wrote: Hi, Your typical funciton looks something like this in math books: f(x) = A*x + x^2 //just an example Where f(x) is essentially 'y'. So, you just need the equation that defines your curve. The curve in your jpg appears to be a circle. y = sqrt(x^2 + r^2) //where r is the radius That actually yields + or - and you just pick what fits your situation best. So, you pump in an x and get you 2 y's. Pick the best y and use it. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
On 4/25/07 5:31 PM, Joshua Sera [EMAIL PROTECTED] wrote: If you know that the two endpoints of the curve are always going to have an equal x or y value, the you can just use the quadratic formula, and get the right Y value. The two endpoints will never move. The middlepoint will be the only one moving. So now I just need the quadratic formula ... I googled quadratic formula and I couldn't figure it out nor translate it to my Flash needs. Like I said, I'm (almost) totally math impaired ! If the endpoints are arbitrary, it's a bit more complicated. Bezier curves take a number from 0 to 1 and give you a point along the curve. Plugging 0 into the formula gives you the first endpoint, 1 gets you the last, and anything else gives you something in between. This means you're going to have to figure out where along the curve your MC is closest to, which involves some vector math. Since I know the _x position of MC, in order to figure out where the MC is along the curve... Can't I use its _x percentage: MC._x / (lastpoint.x - firstpoint.x) Just curious, but I don't think I need this since my two endpoints will not move. If you want, I can draw out the way I'd approach it. Of course I'd be more than happy to see that. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Curves question for math gurus
Actually, you're right. if your endpoints will never move, you can still use a quadratic bezier. The percentage would be (mc._x - firstpoint.x)/(lastpoint.x - firstpoint.x) Since you're using curveTo, you already have all the points you need for the formula Here's a function for you: import flash.geom.Point; function getPoint(first:Point, last:Point, control:Point, ratio:Number):Point { var pReturn:Point = new Point(); var b:Number = 1-ratio; pReturn.x = (b*b*first.x) + (2*ratio*b*control.x) + (ratio*ratio*last.x); pReturn.y = (b*b*first.y) + (2*ratio*b*control.y) + (ratio*ratio*last.y); return pReturn; } first if the first point in your curve, last is the last, control is the point specified by the first two arguments in the curveTo method. This will give you the closest point on the line to your MC's position. If you only want to snap if the MC is within a certain distance, just check the difference of the ys of your mc's position, and the returned point. --- leolea [EMAIL PROTECTED] wrote: On 4/25/07 5:31 PM, Joshua Sera [EMAIL PROTECTED] wrote: If you know that the two endpoints of the curve are always going to have an equal x or y value, the you can just use the quadratic formula, and get the right Y value. The two endpoints will never move. The middlepoint will be the only one moving. So now I just need the quadratic formula ... I googled quadratic formula and I couldn't figure it out nor translate it to my Flash needs. Like I said, I'm (almost) totally math impaired ! If the endpoints are arbitrary, it's a bit more complicated. Bezier curves take a number from 0 to 1 and give you a point along the curve. Plugging 0 into the formula gives you the first endpoint, 1 gets you the last, and anything else gives you something in between. This means you're going to have to figure out where along the curve your MC is closest to, which involves some vector math. Since I know the _x position of MC, in order to figure out where the MC is along the curve... Can't I use its _x percentage: MC._x / (lastpoint.x - firstpoint.x) Just curious, but I don't think I need this since my two endpoints will not move. If you want, I can draw out the way I'd approach it. Of course I'd be more than happy to see that. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Curves question for math gurus
A quadratic curve is made of 3 points. The first point is beginning of the curve, the second point creates the curve between the first and last point. This will place mc exactly on the middle of the curve mc._x = bezierQuadratic(0.5, point1.x, point2.x, point3.x); mc._y = bezierQuadratic(0.5, point1.x, point2.x, point3.x); function bezierQuadratic(t, a, b, c) { return (1-t)*(1-t)*a+2*(1-t)*t*b+t*t*c; } t being a number between 0 and 1, 0 is the location of the first point, 0.5 is the middle of the curve, 1 is the last point. BLITZ | Patrick Matte - 310-551-0200 x214 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of leolea Sent: Wednesday, April 25, 2007 12:34 PM To: Flashcoders mailing list Subject: [Flashcoders] Curves question for math gurus Hi, I have a dynamically drawn curve. It's a simple curve, with 2 end points, and its yfactor will vary. I'm trying to figure out a way to have objects snap to this curved line. I would distribute them over the _x axis, and I need a formula to get their _y position on the curved line. Here is a visual explanation: http://pages.videotron.com/poubou/flash/curve.jpg Now, I guess this requires trigonometry... And I really am a newb when it comes to trig... Any help would be appreciated ! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Curves question for math gurus
I actually made a little mistake in the code mc._x = bezierQuadratic(0.5, point1.x, point2.x, point3.x); mc._y = bezierQuadratic(0.5, point1.y, point2.y, point3.y); function bezierQuadratic(t, a, b, c) { return (1-t)*(1-t)*a+2*(1-t)*t*b+t*t*c; } BLITZ | Patrick Matte - 310-551-0200 x214 -Original Message- From: Patrick Matte | BLITZ Sent: Wednesday, April 25, 2007 4:04 PM To: 'flashcoders@chattyfig.figleaf.com' Subject: RE: [Flashcoders] Curves question for math gurus A quadratic curve is made of 3 points. The first point is beginning of the curve, the second point creates the curve between the first and last point. This will place mc exactly on the middle of the curve mc._x = bezierQuadratic(0.5, point1.x, point2.x, point3.x); mc._y = bezierQuadratic(0.5, point1.x, point2.x, point3.x); function bezierQuadratic(t, a, b, c) { return (1-t)*(1-t)*a+2*(1-t)*t*b+t*t*c; } t being a number between 0 and 1, 0 is the location of the first point, 0.5 is the middle of the curve, 1 is the last point. BLITZ | Patrick Matte - 310-551-0200 x214 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of leolea Sent: Wednesday, April 25, 2007 12:34 PM To: Flashcoders mailing list Subject: [Flashcoders] Curves question for math gurus Hi, I have a dynamically drawn curve. It's a simple curve, with 2 end points, and its yfactor will vary. I'm trying to figure out a way to have objects snap to this curved line. I would distribute them over the _x axis, and I need a formula to get their _y position on the curved line. Here is a visual explanation: http://pages.videotron.com/poubou/flash/curve.jpg Now, I guess this requires trigonometry... And I really am a newb when it comes to trig... Any help would be appreciated ! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com