Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Yes, I drew a square using polar coordinates

Name: Anonymous 2020-05-14 22:51

Wow, isn't math amazing? No, it is not amazing.

<html> <canvas width="512" height="512" id="mycanvas"></canvas> <script> mycanvas=document.getElementById("mycanvas"); context=mycanvas.getContext("2d"); function r(th) { return 16/Math.max(Math.abs(Math.cos(th)),Math.abs(Math.sin(th))); } function x(r,th) { return r*Math.cos(th); } function y(r,th) { return r*Math.sin(th); } for (th=0;th<360;th =1){ myth=th/180*Math.PI; myr=r(myth); myx=x(myr,myth); myy=y(myr,myth); myx =mycanvas.width/2; myy =mycanvas.height/2; context.fillStyle = 'black'; context.fillRect(myx,myy,1,1); } </script> </html>

Name: Anonymous 2020-05-14 23:09

Shit, automation fail.
Anyway,
r(th)=1/max(|cos th|,|sin th|)
This will give you a square of side 2.

Name: Anonymous 2020-05-15 1:38

so you squared the circle?

Name: Anonymous 2020-05-16 22:30

This is new attempt

<html> <canvas width="512" height="512" id="mycanvas"></canvas> <script> mycanvas=document.getElementById("mycanvas"); context=mycanvas.getContext("2d"); function r(th) { return 16/Math.max(Math.abs(Math.cos(th)),Math.abs(Math.sin(th))); } function x(r,th) { return r*Math.cos(th); } function y(r,th) { return r*Math.sin(th); } for (th=0;th<360;th+=1){ myth=th/180*Math.PI; myr=r(myth); myx=x(myr,myth); myy=y(myr,myth); myx+=mycanvas.width/2; myy+=mycanvas.height/2; context.fillStyle = 'black'; context.fillRect(myx,myy,1,1); } </script> </html>

Name: Anonymous 2020-05-16 23:49

This is new attempt

<html> <canvas width="512" height="512" id="mycanvas"></canvas> <script> mycanvas=document.getElementById("mycanvas"); context=mycanvas.getContext("2d"); function r(th) { return 16/Math.max(Math.abs(Math.cos(th)),Math.abs(Math.sin(th))); } function x(r,th) { return r*Math.cos(th); } function y(r,th) { return r*Math.sin(th); } for (th=0;th<360;th+=1){ myth=th/180*Math.PI; myr=r(myth); myx=x(myr,myth); myy=y(myr,myth); myx+=mycanvas.width/2; myy+=mycanvas.height/2; context.fillStyle = 'black'; context.fillRect(myx,myy,1,1); } </script> </html>

Name: Anonymous 2020-05-17 0:08

>>3
I don't know0A
This is maybe the last attempt

<html> <canvas width="512" height="512" id="mycanvas"></canvas> <script> mycanvas=document.getElementById("mycanvas"); context=mycanvas.getContext("2d"); function r(th) { return 16/Math.max(Math.abs(Math.cos(th)),Math.abs(Math.sin(th))); } function x(r,th) { return r*Math.cos(th); } function y(r,th) { return r*Math.sin(th); } for (th=0;th<360;th+=1){ myth=th/180*Math.PI; myr=r(myth); myx=x(myr,myth); myy=y(myr,myth); myx+=mycanvas.width/2; myy+=mycanvas.height/2; context.fillStyle = 'black'; context.fillRect(myx,myy,1,1); } </script> </html>

Name: Anonymous 2020-05-17 0:17

Basically the distance from the center to the tangent line is sec(x) aka 1/cos(x), because 1 + tgˆ2 = secˆ2
Simlar case for cotg and their opposites
Thus Max and Abs each make a fork, totalling the four sides you see.

Name: Anonymous 2020-05-17 8:25

Do they have straight lines in polar co-ordinates usually? Or generally just curves and circles?

Name: Anonymous 2020-05-17 15:35

>>8
Polar coordinates are (r, theta) pairs, or radius and angle;
Like in cartesian coordinates you have functions y(x), y given in terms of x
in polar coordinates they are r(theta), radius given in terms of theta/angle;
r(theta)=any constant, gives a regular circle; r(theta)=constant*theta, gives a spiral;
there are also roses of many petals, and many other figures, as I remember from calculus B classes;
but in general they are curvy.
You can convert (r,theta) to (x,y) like so:
x=r*cos(theta);
y=r*sin(theta);
r=sqrt(x^2 + y^2);
theta = atan(y/x);//or atan2(y,x) in most computers

Don't change these.
Name: Email:
Entire Thread Thread List