Author Topic: Square to Circle  (Read 74 times)

Code Hunter

Square to Circle
« on: June 19, 2018, 08:04:18 PM »
Maybe someone can make heads or tails out of this and maybe use it in a an example.

I am trying but all I get is illegal function call errors.

http://squircular.blogspot.com/2015/09/fg-squircle-mapping.html

https://stackoverflow.com/questions/13211595/how-can-i-convert-coordinates-on-a-circle-to-coordinates-on-a-square
« Last Edit: June 19, 2018, 08:28:40 PM by Code Hunter »

bplus

• B = B + geberation
Re: Square to Circle
« Reply #1 on: June 19, 2018, 08:25:42 PM »
Ha! Looking into that this afternoon!

Here is my cosine grid:
Code: [Select]
`_TITLE "Sphere sim by bplus started 2018-06-19"'QB64 version 2017 1106/82 (the day before they switched to version 1.2)CONST xmax = 800CONST ymax = 600DIM SHARED pipi = _PISCREEN _NEWIMAGE(xmax, ymax, 32)_SCREENMOVE 360, 60'divide a quarter circle into 9 equal angles (pi/2) / 9'create a grid with the cos of these anglesDIM cxy(9)i = 0FOR a = 0 TO pi / 2 STEP (pi / 2) / 9    cxy(i) = COS(a)    i = i + 1NEXT' need a radius say 300 half the height of screenr = 300cy = ymax / 2cx = xmax / 2FOR i = 0 TO 9    ln cx - r * cxy(i), 0, cx - r * cxy(i), ymax    ln cx + r * cxy(i), 0, cx + r * cxy(i), ymax    ln 0, cy - r * cxy(i), xmax, cy - r * cxy(i)    ln 0, cy + r * cxy(i), xmax, cy + r * cxy(i)    CIRCLE (cx, cy), r * cxy(i)NEXTSUB ln (x1, y1, x2, y2)    LINE (x1, y1)-(x2, y2)END SUB`
Looking to map rectangle into the circle.
« Last Edit: June 19, 2018, 08:28:49 PM by bplus »
B = B + ...

Code Hunter

Re: Square to Circle
« Reply #2 on: June 19, 2018, 08:30:42 PM »
Syntax error inside the final loop.

Code: [Select]
`    ln cx - r * cxy(i), 0, cx - r * cxy(i), ymax    ln cx + r * cxy(i), 0, cx + r * cxy(i), ymax    ln 0, cy - r * cxy(i), xmax, cy - r * cxy(i)    ln 0, cy + r * cxy(i), xmax, cy + r * cxy(i)`

bplus

• B = B + geberation
Re: Square to Circle
« Reply #3 on: June 19, 2018, 08:31:13 PM »
Fixed forgot ln sub
B = B + ...