This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-01-06 07:06:30

Stefi_68
New Scratcher
Registered: 2012-12-28
Posts: 3

Circle drawer

Please help me with a small program to draw a circle with given centrer and radius
Thank you

Offline

 

#2 2013-01-06 08:40:31

BLU_Spy
Scratcher
Registered: 2012-01-05
Posts: 1000+

Re: Circle drawer

I guess this is what you're looking for:

amcerbu wrote:

If you take an arbitrary angle that measures the offset from the x-axis (so, imagine angle = 0 is pointing straight right), you can take the sine or the cosine of the angle to give you a value.  This value represents the length along the y (sine) or x (cosine) axis of a line drawn with that angle and a length of 1.  For that reason, sin(angle)^2 + cos(angle)^2 = 1.  Since drawing from (0, 0) to (cos(angle), sin(angle)) will always give you a line of length 1, you can draw a line with a length of 10 by going from the origin to (10 * cos(angle), 10 * sin(angle)).  Does that make sense?

So, to make a circle, all we have to do is start with an angle variable, and increment it so that it moves all the way around a circle. 

One thing to know: the "angle" argument that the sine and cosine functions take is not the same as "Scratch" angles, where 90 is right, 0 is up, etc.  Here, 0 is right, 90 is up, 180 is left, and 270 (or, -90, equivalently).  The sine and cosine functions don't worry about how many rotations you have completed.  sin(270) is the same as sin(630), and even sin(990).

when gf clicked
set [angle v] to [0]
repeat(360)
pen up
go to x: (0) y: (0)
pen down
go to x: ((100) * ([cos v] of (angle))) y: ((100) * ([sin v] of (angle)))
change [angle v] by (1)
end


I HAVE SWITCHED ACCOUNTS! My new username is NoxSpooth.

Offline

 

Board footer