Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F1480
GeoOctocube
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
dereckson
Mar 29 2015, 17:01
2015-03-29 17:01:07 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
GeoOctocube
View Options
/**
* Geo octocube class
*
* An octocube is a cube divided in 8 parts (sliced in two in x, y and z)
*
* Its coordinate (0, 0, 0) is the octocube center.
*/
class GeoOctocube {
/**
* Gets the sector from the (x, y, z) specified coordinates
*
* Sector will be:
* <code>
* // _____ _____
* // / 5 / 6 /|
* // /- - -/- - -/ |
* // /_____/____ /| |
* // | | | |/|
* // | 7 | 8 | / | 2
* // |_____|_____|/| |
* // | | | |/
* // | 3 | 4 | /
* // |_____|_____|/
* </code>
*
* @param int $x the x coordinate
* @param int $y the y coordinate
* @param int $z the z coordinate
* @return int the number of the sector (0 if x = y = z 0 ; otherwise, 1 to 8)
*/
static function get_sector ($x, $y, $z) {
//Cube center
if ($x == 0 && $y == 0 && $z == 0) return 0;
//One of the 8 cubes
$sector = 1;
if ($x >= 0) $sector++; //we're at right
if ($y < 0) $sector += 2; //we're in front
if ($z >= 0) $sector += 4; //we're on the top layer
return $sector;
}
/**
* Gets the sector from the (x, y, z) specified coordinates
* @see get_sector
*
* @param GeoPoint3D $pt the x, y, z coordinates
* @return int the number of the sector (0 if x = y = z 0 ; otherwise, 1 to 8)
*/
static function get_sector_from_point3D ($pt) {
return get_sector($pt->x, $pt->y, $pt->z);
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1463
Default Alt Text
GeoOctocube (1 KB)
Attached To
Mode
P38 GeoOctocube
Attached
Detach File
Event Timeline
Log In to Comment