# How do you divide the coordinate plane into 3rds??

I want to create 3 equal zones on the (x,z) coordinate plane all starting from (0,0). So I need 3 zone barriers that extend infinitely in 3 directions, one of them can be on the x axis, dividing the entire map into 3 equal sections. The goal is to be able to input a location anywhere on the map, and find out which zone that is in and how far away from the barriers it is. So I guess i would need the equations for these divider lines. If anyone could tell me how to calculate those that would be very helpful!

Give this a shot. It returns which third you’re in and the distance form the origin. I’m just not sure how to check the distance from each division

`````` var distance : float;
var first : boolean = false;
var second : boolean = false;
var third : boolean = false;

function Update ()
{
xAxis = transform.position.x;
zAxis = transform.position.z;

// Calculate the angle from the x and z positions
var angle : float = Mathf.Atan2(xAxis, zAxis) * Mathf.Rad2Deg;

// Cube's distance from 0,0
distance = Mathf.Sqrt(Mathf.Abs((xAxis*xAxis)+(zAxis*zAxis)));

if(angle > -60 && angle <= 60)
{
first = true;
}
else
{
first = false;
}
if(angle > 60 && angle <= 180)
{
second = true;
}
else
{
second = false;
}
if(angle > -180 && angle <= -60)
{
third = true;
}
else
{
third = false;
}

Debug.Log("first: "+first);
Debug.Log("second: "+second);
Debug.Log("third: "+third);

Debug.Log("Distance from origin: "+distance);
}
``````

[1499-newcoordinatesystem.zip|1499]

[1500-screen+shot+2012-07-02+at+5.41.40+pm.png|1500]