How can draw a circle by drawing point?
local x, y = 0, 0
for i = 1, 360 do
drawPoint( (x*i), (y*i) )
end
I'm bad at math.
local x, y = 0, 0
for i = 1, 360 do
drawPoint( math.cos(i)*(10)+x, math.sin(i)*(10)+y )
end
Ok I did it; But I have some questions:
How do I know the appropriate number place number 40 in the a loop?
How do I know width, and radius? Which represents the number 10 in the loop.
Let's say x
and y
is your centre co-ordinate and r
is the radius. Now:
local x, y, r = 0, 0, 1
for i = 1, 360 do
local angle = i * math.pi / 180
local ptx, pty = x + r * math.cos( angle ), y + r * math.sin( angle )
drawPoint( ptx, pty )
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.