WEBVTT

00:00:05.040 --> 00:00:10.320
So far we have used a very traditional coordinate 
system to position our elements with the x  

00:00:10.320 --> 00:00:15.840
and the y axis. But there are other kinds of 
coordinate systems and one of my favorites  

00:00:15.840 --> 00:00:21.040
is the so-called polar coordinate system. 
In this coordinate system we don't define  

00:00:21.040 --> 00:00:30.160
our points by x and y, but instead by the radius 
of a circle and the angle. So we define points  

00:00:30.720 --> 00:00:38.160
on a circle line. And we have a formula that 
helps us convert angle plus radius into x and y  

00:00:38.160 --> 00:00:44.000
coordinates. So that we can actually position them 
in our more traditional x/y coordinate system.  

00:00:44.000 --> 00:00:49.360
The formula is quite straightforward. I've added 
it to the website you can see it below the video.  

00:00:50.320 --> 00:00:56.960
To get the x axis, we simply multiply 
the radius times the cosine of Math.PI,  

00:00:57.520 --> 00:01:02.000
again this is radians not angles so we need 
this little formula that we used in one of the  

00:01:02.000 --> 00:01:10.560
previous videos. So 2 times PI is 360 degrees 
so to make it more usable, we simply divide PI  

00:01:10.560 --> 00:01:17.360
by 180 and multiply it times the angle, times 
the degrees we actually want on our circle.  

00:01:18.560 --> 00:01:23.680
And for the y axis we simply do the same what 
we used for the x axis, but sine instead of the  

00:01:23.680 --> 00:01:32.960
cosine. To give you a very simple example what we 
could use this for, we simply will create a loop  

00:01:34.800 --> 00:01:44.320
and we will draw a couple of points on our circle 
line. We use the angle to increase the angle  

00:01:45.520 --> 00:01:52.480
every time the loop runs and the whole 
thing should run as long as our angle is  

00:01:52.480 --> 00:02:02.000
smaller 360. so it should run for one full 
circle and we add 15 degrees after every loop.

00:02:07.440 --> 00:02:11.680
and now we simply need to 
define our angle, our radius

00:02:15.040 --> 00:02:21.840
and then we only need to add our vertices

00:02:24.000 --> 00:02:32.960
and then we have our points on a circle line 
positioned. and because the zero, the center  

00:02:32.960 --> 00:02:40.400
of our circle, is at zero, so it's in the upper 
left corner of our sketch, we simply need to add  

00:02:40.400 --> 00:02:47.680
the half of the width of our canvas and the half 
of the height, to position it in the center. And  

00:02:47.680 --> 00:02:53.280
now you can see all the little segments. We can 
increase the angles that are added after each  

00:02:53.280 --> 00:02:59.600
loop, so you can now even see more clearly how 
there are multiple points along the circle line  

00:03:00.480 --> 00:03:06.800
positioned. As we defined through the angle here. 
But of course we can do a lot more things with  

00:03:06.800 --> 00:03:12.800
this. For example we could also say okay we don't 
give it a fixed radius but for example we use  

00:03:12.800 --> 00:03:21.840
a random radius so every time a point is drawn 
we generate a new radius for example 125 to 150  

00:03:23.360 --> 00:03:29.120
so now we have like a little jiggling circle 
we could of course also add a noLoop() here  

00:03:31.120 --> 00:03:37.520
and now you can see how there is a certain 
randomness in the radius or we could also  

00:03:37.520 --> 00:03:45.840
for example increase the radius at each point and 
thereby create like something like a little shell

00:03:48.400 --> 00:03:59.840
so we start with one and then we simply increase 
the radius by one and let's make it 15 again

00:04:03.440 --> 00:04:04.720
and remove the close

00:04:07.200 --> 00:04:08.160
whoops oh

00:04:10.640 --> 00:04:15.840
so now we get a very little spiral and to 
make it a bit more of a spiral we could simply  

00:04:16.640 --> 00:04:21.040
run it two times so now we get 
this nice little spiral here

00:04:23.280 --> 00:04:29.920
and of course we could also make it a 
bit bigger and so the polar coordinate  

00:04:29.920 --> 00:04:35.440
system is quite easy to use but gives you very 
interesting use cases to create round objects to  

00:04:36.000 --> 00:04:40.080
align things on the center around 
the central point so there's a lot of  

00:04:40.080 --> 00:04:49.440
different applications how you can use this 
in your designs and your generative objects