« Return to Thread: Howto sample a curve?

Re: Howto sample a curve?

by Paul deCoursey :: Rate this Message:

Reply to Author | View in Thread

I had written this function a long time ago to calculate points on a  
curve.  t is like the percentage of the curve, so 0.5 would give you  
the midpoint of the curve.

function calculateQuadraticBezierPoint(t:Number, sp:Point, cp:Point,  
ep:Point):Point {
        var result:Point = new Point(10, 10);
       
     var ax:Number = sp.x + ((cp.x - sp.x) * t);
     var ay:Number = sp.y + ((cp.y - sp.y) * t);
        var bx:Number = cp.x + ((ep.x - cp.x) * t);
     var by:Number = cp.y + ((ep.y - cp.y) * t);
        var cx:Number = ax + ((bx - ax) * t);
     var cy:Number = ay + ((by - ay) * t);
       
        result.x = cx;
        result.y = cy;
       
        return result;
}


Hope that helps.


On May 22, 2008, at 2:48 PM, Tim Knip wrote:

> Hi list,
>
> I have a curved line (curveTo)...
>
> How to get straight line-segments following this curve?
> Where start- and endpoints of the segments lie on the curve .
>
> Say I have a circle created from 4 curveTo's. How do I create like 16
> straight line segments?
>
> Thanks!
> Tim
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D@...
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

 « Return to Thread: Howto sample a curve?