143 Pages

## Introduction Edit

Blockland operates using the Cartesian coordinate system. This is a gridlike system much like the tiles on the floor of a bathroom. This system is ideal for certain things, e.g., straight lines, roads, buildings, tiles. It is not as good for other things, such as spirals. Another system, called the Polar coordinate system based on an angle and the distance from the center of a map, is much better suited for this.

The problem with this is that you need to convert from the Polar system to the Cartesian system, because Blockland operates in the Cartesian system. This is actually easy enough to do, if you have a formula in the Polar system. Let's take the Quadrifolium from Wikipedia. Its polar equation is:

r=math.cos(2*θ)

So, to obtain the values for x and z, we have to multiply r as follows:

x = r * math.cos(θ)
z = r * math.sin(θ)

We now get:

x=math.cos(2*i) * math.cos(θ)
z=math.cos(2*i) * math.sin(θ)

You will see these formulas again in the script below.

## Quadrifolium Edit

```for( %i = 0 ; %i < 250 ; %i++ )
{

%n=2.0;
%d=1.0;

%k=%n/%d;

%posx = mCos(%k*%i)*mCos(%i);
%posz = mCos(%k*%i)*mSin(%i);
%posy = 1;

%temp = new fxDTSBrick()
{
datablock = "brick1x1Data";
position = 10*%posx SPC %posy SPC 10*%posz;
rotation = "0 0 0 0";
colorID = "1";
scale = "1 1 1";
angleID = "0";
colorfxID = "0";
shapefxID = "0";
isPlanted = 1;
};

}
```

## Polar 2 Edit

```for( %i = 0 ; %i < 300 ; %i++ )
{

%n=3.0;
%d=2.0;

%k=%n/%d;

%posx = mCos(%k*%i)*mCos(%i);
%posz = mCos(%k*%i)*mSin(%i);
%posy = 1;

%temp = new fxDTSBrick()
{
datablock = "brick1x1Data";
position = 10*%posx SPC %posy SPC 10*%posz;
rotation = "0 0 0 0";
colorID = "1";
scale = "1 1 1";
angleID = "0";
colorfxID = "0";
shapefxID = "0";
isPlanted = 1;
};

}
```

Other curves can be set by changing the value of k, as seen in the table.

## Archimedean Spiral Edit

This classic mathematical example has a polar formula of:

r=a+b(theta)

Similarly, using the conversion formulas of

x=r*cos(theta) and
y=r*sin(theta)

one arrives at the formulas used in the script below.

```for( %i = 1 ; %i < 500 ; %i++ )
{

%a=1;
%b=1;

%posx = (%a+%b*(%i/10))*mCos(%i/10);
%posz = (%a+%b*(%i/10))*mSin(%i/10);
%posy = 1;

%temp = new fxDTSBrick()
{
datablock = "brick1x1Data";
position = %posx SPC %posy SPC %posz;
rotation = "0 0 0 0";
colorID = "1";
scale = "1 1 1";
angleID = "0";
colorfxID = "0";
shapefxID = "0";
isPlanted = 1;
};

}
```

## 3D Images Edit

Similarly, 3-D images can be created with a system similar to polar equations, called Spherical coordinates. The formula for a sphere in polar is rho = R. Using the formula to convert Spherical coordinates to Cartesian:

x=r*sin(theta)*cos(phi)
y=r*sin(theta)*sin(phi)
z=r*cos(theta)

The formula rho = R is obvious below.

### Sphere Edit

```for( %i = 1 ; %i < 150 ; %i++ )
{
for( %j = 1 ; %j < 150 ; %j++ )
{

%R=6;

%posx = 10*%R*mSin(%i)*mCos(%j);
%posy = 10*%R*mSin(%i)*mSin(%j);
%posz = 10*%R*mCos(%i);

%temp = new fxDTSBrick()
{
datablock = "brick1x1Data";
position = %posx SPC %posy SPC %posz;
rotation = "0 0 0 0";
colorID = "1";
scale = "1 1 1";
angleID = "0";
colorfxID = "0";
shapefxID = "0";
isPlanted = 1;
};

}
}
```

### Ellipsoid Edit

Another example is the ellipsoid, very similar to the sphere above. Really all that's being changed are the radii (a, b, and c).

Spherical formula
x=a*cos(theta)sin(phi)
y=b*sin(theta)sin(phi)
z=cos(phi)

Conversion
x=r*sin(theta)cos(phi)
y=r*sin(theta)sin(phi)
z=r*cos(theta)

Cartesian formula
x=a*math.sin(i)*math.cos(j)
y=b*math.sin(i)*math.sin(j)
z=c*math.cos(i)

```for( %i = 1 ; %i < 100 ; %i++ )
{
for( %j = 1 ; %j < 100 ; %j++ )
{

%a=2;
%b=15;
%c=7;

%posx = 3*%a*mSin(%i)*mCos(%j);
%posy = 3*%b*mSin(%i)*mSin(%j);
%posz = 3*%c*mCos(%i);

%temp = new fxDTSBrick()
{
datablock = "brick1x1Data";
position = %posx SPC %posy SPC %posz;
rotation = "0 0 0 0";
colorID = "1";
scale = "1 1 1";
angleID = "0";
colorfxID = "0";
shapefxID = "0";
isPlanted = 1;
};

}
}
```

By changing the values of a, b, and c, you can come up with different shapes:

```a=b=c: Sphere
a=b>c: Oblate spheroid (disk-shaped)
a=b<c: Prolate spheroid (egg-shaped)
a>b>c: Scalene ellipsoid ("three unequal sides")
```