Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do you make this line into a circle?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
santabruzer




PostPosted: Wed Dec 10, 2003 11:31 pm   Post subject: How do you make this line into a circle?

Hey!
Just wondering.. how you would go about make a line draw a cicle.. as in like
code:
for i : 1 .. 360
drawline (300, 225, i, 100, 7) 
delay (10)
end for

would draw a triangle....
PLease help!
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Wed Dec 10, 2003 11:32 pm   Post subject: (No subject)

equation of a circle, as in x^2 + y^2 = r^2

sub in values for x and find y, then draw it from a center point.
Schaef




PostPosted: Wed Dec 10, 2003 11:34 pm   Post subject: (No subject)

To draw a circle you use

"Drawoval" or "Drawfilloval" then in brackets you put (x coor. of circles center, y coor. of circles center, radius, radius, colour)
santabruzer




PostPosted: Wed Dec 10, 2003 11:37 pm   Post subject: (No subject)

the problem is that i knew that, but have no idea how to do it.... i'll try and figure it out.. hopefully..
Tony




PostPosted: Wed Dec 10, 2003 11:48 pm   Post subject: (No subject)

well you graph circle using y^2 = r^2 - x^2
code:

for i:-50..50
Draw.Dot(i+100,round(sqrt(2500-i*i))+100,red)
delay(10)
end for

for decreasing i:50..-50
Draw.Dot(i+100,-round(sqrt(2500-i*i))+100,red)
delay(10)
end for


and just use those outer coordinates as your second point for the line

code:

for i:-50..50
Draw.Line(100,100,i+100,round(sqrt(2500-i*i))+100,red)
delay(10)
end for

for decreasing i:50..-50
Draw.Line(100,100,i+100,-round(sqrt(2500-i*i))+100,red)
delay(10)
end for


Though it's not a perfect fill Confused

You're better off using Draw.FillArc
code:

for i:1..360
Draw.FillArc(100,100,100,100,i-1,i,black)
delay(10)
end for
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
santabruzer




PostPosted: Wed Dec 10, 2003 11:56 pm   Post subject: (No subject)

Thanx.. Very Happy .. wonder why it ain't a perfect fill... (maybe should've paid attention at math class)
Homer_simpson




PostPosted: Thu Dec 11, 2003 12:11 am   Post subject: (No subject)

how bout this one?
code:
View.Set ("offscreenonly")
var y := 0.0
for decreasing r : 6000 .. 50 by 20
    cls
    for x : -80 .. 80
        if (r ** 2) >= (x ** 2) then
            y := sqrt ((r ** 2) - (x ** 2))
            drawdot (x + 320, round (y) + 200 - r, 12)
            drawdot (x + 320, round (-y) + 200 - r, 12)
        end if
    end for
    View.Update
    delay (10)

end for
santabruzer




PostPosted: Thu Dec 11, 2003 8:49 am   Post subject: (No subject)

nice effect... but i wanted something a lot simpler.. like a line redrawing over and over to form a fill oval... i guess you can't do that..
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: