Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Playing with code: a circle function using triangle math
#1
Just experimenting with some code for creating circles with "triangle math".

As always, I start with big and ugly code just to understand the pieces before making the code pretty.

Code: (Select All)
' C is the right angle
' c is opposite side
' c squared = a squared + b squared

size = 100
aspect_ratio = 1
screen _newimage(size, size, 12)

root_x = size / 2 : root_y = size / 2
c = size / 2 - 25

for a = C to 0 step - 0.01
b = ( c ^ 2 - a ^ 2 ) ^ (0.5)
pset (root_x + a, root_y - (b/aspect_ratio)), 14
next a

for a = 0 to c step 0.01
b = ( c ^ 2 - a ^ 2 ) ^ (0.5)
pset (root_x - a, root_y - (b/aspect_ratio)), 13
next a

for a = -c to 0 step 0.01
b = ( c ^ 2 - a ^ 2 ) ^ (0.5)
pset (root_x + a, root_y + (b/aspect_ratio)), 12
next a

for a = 0 to c step 0.01
b = ( c ^ 2 - a ^ 2 ) ^ (0.5)
pset (root_x + a, root_y + (b/aspect_ratio)), 11
next a

   
Reply


Messages In This Thread
Playing with code: a circle function using triangle math - by CharlieJV - 09-13-2023, 03:17 AM



Users browsing this thread: 3 Guest(s)