Why is cosine used to calculate the x and sine values ​​of the y value for an arc?

I am trying to understand the math in this demo version of raphael.js:

http://raphaeljs.com/pie.js

Calculate the sector method:

function sector(cx, cy, r, startAngle, endAngle, params) {
    var x1 = cx + r * Math.cos(-startAngle * rad),
        x2 = cx + r * Math.cos(-endAngle * rad),
        y1 = cy + r * Math.sin(-startAngle * rad),
        y2 = cy + r * Math.sin(-endAngle * rad);
    return paper.path(["M", cx, cy, "L", x1, y1, "A", r, r, 0, +(endAngle - startAngle > 180), 0, x2, y2, "z"]).attr(params);
}

This is the actual demo: http://raphaeljs.com/pie.html

My math is a little rusty, and I am trying to understand the function of the sector - given the startAngle and endAngle parameters (each value of the start and end point from 0 to 360, constituting an arc), why does this function work?

+5
source share
4 answers
+9

, cos : alt text

, , cosα x- a sin alpha y.

, . alt text http://i37.tinypic.com/ot3zw8.png

, , .

+14

(cx, cy) R ( cos sin - ):

x = cx + R*cos(a)
y = cy + R*sin(a) for  0 <= a < 2π

, a, .

+2

0 ° , x , 90 ° y, :

cos(0) = 1
sin(0) = 0

cos(90) = 0
sin(90) = 1

x, y, .

+1

All Articles