Figure 2-2: The output of a sine representation

decode qrcode for .netUsing Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in .NET applications.

So, the result is a set of dots ( . ) starting at (0,100) and then as x goes from 0,1,2,3,4, . . . 500, y produces cosine values. Since we know from trigonometry that a cosine will always be between 1 and 1, we multiply by 50 to make y a value between 50 and 50. Obviously, the resulting numbers place the points along the path of a curve. These numbers are sample values that result from the x and y parameters. The more we decrease the distance between consecutive i values, the more precise the path is. If we want to shorten the curve in the x direction, then we need to do the following adjustment to the x coordinate:

QR Code JIS X 0510 barcode library on .netusing barcode encoder for visual studio .net control to generate, create qr codes image in visual studio .net applications.

1 2 3 4 5 for(int i=0; i<5000; i++){ int x = i/10; int y = (int)(50. * cos(PI/180.* i) point(x , y+50); }

Visual Studio .NET denso qr bar code scannerin .netUsing Barcode scanner for .NET Control to read, scan read, scan image in .NET applications.

The resulting points will be placed along a full circle when i goes from 0 to 360, so, in our case, 5000 will result in 5000 / 360 = 13.8 full circles. We don t want x to go to 5,000 because the screen is only 400 pixels long and it will be drawn outside of the visible screen. So we divide i by 10, and therefore x will go to only 500, resulting in an image like that shown in Figure 2-3.

scanning barcode on .netUsing Barcode reader for .net framework Control to read, scan read, scan image in .net framework applications.

2

Barcode barcode library for .netusing .net framework crystal toget barcode in asp.net web,windows application

Points, Lines, and Shapes

Control qr data on .net c#to display denso qr bar code and qr-codes data, size, image with visual c#.net barcode sdk

Figure 2-3: The output of a cosine representation

Asp.net Web Forms qr generatoron .netusing web form todevelop qr code on asp.net web,windows application

If we reverse the values of x and y, as is done in the following code, then we can obtain a rotated curve, as shown in Figure 2-4.

.net Vs 2010 qr barcode generationin visual basic.netusing barcode development for .net vs 2010 control to generate, create quick response code image in .net vs 2010 applications.

1 2 3 4 5 for(int i=0; i<5000; i++){ int x = (int)(50. * cos(PI/180.* i) int y = i/10; point(x+50 , y); } );

Insert barcode for .netgenerate, create bar code none with .net projects

Figure 2-4: Reversing the direction of a cosine representation

UPC Symbol barcode library with .netusing visual .net crystal toinclude upc barcodes on asp.net web,windows application

Now, if we combine the two, alternating sine and cosine, as in the following code:

Deploy bar code for .netusing barcode writer for .net framework control to generate, create barcode image in .net framework applications.

1 2 3 4 5 for(int i=0; i<5000; i++){ int x = (int)(50. * cos(PI/180.* i) int y = (int)(50. * sin(PI/180.* i) point(x+50 , y+50); } ); );

.net Vs 2010 code 9/3 generatingfor .netgenerate, create code 93 none for .net projects

this will result in the unexpected (perhaps) output shown in Figure 2-5.

2

Bar Code writer on javause eclipse birt barcode generator toget bar code in java

Points, Lines, and Shapes

39 Barcode generator for visual c#using barcode printer for .net control to generate, create bar code 39 image in .net applications.

Figure 2-5: The output of the combination of a sine and cosine representation

UCC - 12 reader for noneUsing Barcode Control SDK for None Control to generate, create, read, scan barcode image in None applications.

A circle! We will use this technique later on to rotate objects in the screen, because basically what we are doing here is forcing x and y to move on the perimeter of a circle. Or, to be precise, we force x and y to rotate around a center 13.8 times, since the counter goes from 0 to 5,000. If the counter is going from 0 to 180, as shown here:

1 2 3 4 5 for(int i=0; i<180; i++){ int x = (int)(50. * cos(PI/180.* i) int y = (int)(50. * sin(PI/180.* i) point(x+100 , y+100); } ); );

Control ucc ean 128 image in c#.netgenerate, create ucc-128 none for visual c# projects

we would have created a half-circle (see Figure 2-6), because i is the number of degrees of the rotation angle.

QR Code ISO/IEC18004 generation on .net c#using barcode printing for .net for windows forms crystal control to generate, create qr image in .net for windows forms crystal applications.

Figure 2-6: A half-circle

ANSI/AIM Code 128 barcode library for c#using an asp.net form crystal tocompose barcode 128 in asp.net web,windows application

The equations used to construct a circle or portions of it are defined through the following formulas:

x=r*cos(i), y=r*sin(i)

where i is the counter or any parameter that changes in an orderly fashion. Thus, such a set of equations are referred to as parametric, where the parameter

2

Points, Lines, and Shapes

here is i and, consequently, the resulting circle is a parametric one. However, in analytic geometry, the equation for generating a circle is different: x2 + y2 = r2 Such an equation denotes that for every point on a plane, only the points that satisfy the above equation are part of a circle of radius r and center (0,0). The following code generates such a circle (shown on the left in Figure 2-7):

1 2 3 4 for(int x = -50; x<50; x++) for(int y=-50; y<50; y++) if(x*x + y*y == 25*25) point(x+50,y+50);

Line 3 in the above code can be replaced with the following statement:

3 if(x*x + y*y > 25*25 && x*x + y*y < 26*26)

In this case, a circle is produced by selecting a series of points that fit the preceding two inequalities. This circle has a radius that ranges between 25 and 26 (shown on the right in Figure 2-7).