-
Senior Member
some explanation please, quadratics
hi there,
i have this code which draws a circle:
Code:
var r:Number = 50;
var x:Number=200
var y:Number=200
var mc = _root.createEmptyMovieClip("line", 0);
mc.lineStyle(1, 0, 100);
mc.moveTo(x+r, y);
a = Math.tan(22.5*Math.PI/180);
for (var angle = 45; angle<=360; angle += 45) {
var endx = r*Math.cos(angle*Math.PI/180);
var endy = r*Math.sin(angle*Math.PI/180);
var cx = endx+r*a*Math.cos((angle-90)*Math.PI/180);
var cy = endy+r*a*Math.sin((angle-90)*Math.PI/180);
mc.curveTo(cx+x, cy+y, endx+x, endy+y);
}
now i know that the curveTo() function used quadratics, but i dont know how,
so what i am asking is:
can someone show me what the quadratic formula that draws this circle looks like and mabye explain it a bit??
i would be very greatfull,
thanks,
Zlatan
Last edited by dudeqwerty; 08-27-2005 at 08:17 PM.
New sig soon
-
You can't actually draw a perfect circle with quadratic curves as drawn with the .curveTo() command. Over short segments they approximate well though.
The way to visualise how the quadratic curveTo() works is to imagine a triangle with its corners at the two anchor points and the control point of the curve. Then, the curve starts and ends tangentially (in line with) the lines from the anchor points to the control point. Try replacing the curveTo in the above code with two lineTo calls that draw to the same points. It'll be much more obvious why it works then.
I have the formula for drawing quadratic curves at home somewhere, but can't remember it off the top of my head. I seem to remember it being fairly unenlightening!
-
Senior Member
hi CMU,
thanks or the reply,
i got this link from someone, you might find it interesting.
link
thanks again,
zlatan
-
That is interesting, but that's not the type of curve drawn by curveTo as it has a separate control point for each anchor. I believe the Flash style of quadratic curve is closer to this:
http://graphics.idav.ucdavis.edu/edu...ier-Curves.pdf
The mathematics in that document get a bit heavy, but you can see how it works in the diagrams near the start.
-
Senior Member
hey thanks, my laptop resently broke and i had to get a new hard disc so i dont have pdf reader!!
is there a html version?
thanks,
zlatan
-
Google makes a bad job of turning the document into HTML sadly:
http://66.102.9.104/search?q=cache:o...rves.pdf&hl=en
Why not just DL the Acrobat reader? It's free from adobe.com
-
Senior Member
hi, cheers,
yeah i just downloaded adobe reader,
thanks again
zlatan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|