|
Open Sim Global Calculations BRIGADOON-0011
Provide a php class that provides a series of calculations using global coordinates
|
A Class to do global to local conversion and some global calculations. More...
Public Member Functions | |
| __construct ($Database, $Host, $Username, $Password) | |
| Open the Support Database for Use. | |
| GlobalToLocal ($GlobalArray) | |
| LocalToGlobal ($LocalArray) | |
| Convert a local regional location into a global location. | |
| CourseFromTo ($FromLocalArray, $ToLocalArray) | |
| Find the course and distance from one point to another using local coordinates. | |
| FromCourseTo ($FromLocalArray, $CourseArray) | |
| Routine to Calculate a Destination from an origin and a Course. | |
| __construct ($Database, $Host, $Username, $Password) | |
| GlobalToLocal ($GlobalArray) | |
| LocalToGlobal ($LocalArray) | |
| CourseFromTo ($FromLocalArray, $ToLocalArray) | |
| FromCourseTo ($FromLocalArray, $CourseArray) | |
| RegionBoundsGlobal ($RegionName) | |
| Find the Bottom Left Corner and Top Right Corners in Global Coordinates. | |
| AddGlobal ($FromGlobal, $DeltaGlobal) | |
| DeltaGlobal ($FromGlobal, $ToGlobal) | |
| RegionToDeltaLocal ($FromLocal, $ToLocal) | |
| DeltaLocalToLocal ($DeltaLocal) | |
| Convert a region based Location using global delta off to local coordinates. | |
Public Attributes | |
| $Database | |
| The name of the Database. | |
| $Host | |
| The Host running the Database. | |
| $Username | |
| The Username to access the Database. | |
| $Password | |
| The password to access the Database. | |
A Class to do global to local conversion and some global calculations.
This class uses the Region Table to convert between global and local units for the Open Simulator.
It can also be used to calculate positions using distance and bearing information that spans across any number of regions in the simulator by using global measurements.
Definition at line 32 of file os_global_calcs.php.
| OS_GLOBAL_CALCS::__construct | ( | $Database, | |
| $Host, | |||
| $Username, | |||
| $Password ) |
Open the Support Database for Use.
| $Database | The Name of the Database to Open |
| $Host | The name of the computer use to conenct to the Database |
| $Username | The username to access the Database |
| $Password | The password to access the database. |
If this routine fails, it will case the program to abort because it is assumed that not being able to convert between coordinate system will be fatal.
Definition at line 71 of file os_global_calcs.php.
References $Database, $Host, $Password, $pdo, and $Username.
| OS_GLOBAL_CALCS::__construct | ( | $Database, | |
| $Host, | |||
| $Username, | |||
| $Password ) |
Definition at line 71 of file os_global_calcs_dev.php.
References $Database, $Host, $Password, $pdo, and $Username.
| OS_GLOBAL_CALCS::AddGlobal | ( | $FromGlobal, | |
| $DeltaGlobal ) |
| OS_GLOBAL_CALCS::CourseFromTo | ( | $FromLocalArray, | |
| $ToLocalArray ) |
Find the course and distance from one point to another using local coordinates.
| $FromLocalArray | The region position of the origin point |
| $ToLocalArray | The region position of the desired destination point |
This routine will convert origin & destination into global coordinates, then calculate the delta-X, delta-Y and delta-Z measurements. From those measurements, it first calculates the ground range and the height change. From that the actal distance between the two points is calculated. Then the ground bearing from the Origin to Destination is calculated and finally the elevation angle from the source to the destination is calculated.
If you desire the ground range to be returned, rather the point to point distance, set the Z value to the same value for the source and destination.
See the GlobalToLocal($GlobalArray) documentation for an explanation of the formats of the $GlobalArray and the $LocalArray. The format of the $CourseArray is as follows:
Definition at line 230 of file os_global_calcs.php.
References $result, and LocalToGlobal().
| OS_GLOBAL_CALCS::CourseFromTo | ( | $FromLocalArray, | |
| $ToLocalArray ) |
Definition at line 230 of file os_global_calcs_dev.php.
References $result, and LocalToGlobal().
| OS_GLOBAL_CALCS::DeltaGlobal | ( | $FromGlobal, | |
| $ToGlobal ) |
Definition at line 380 of file os_global_calcs_dev.php.
References $result.
Referenced by RegionToDeltaLocal().
| OS_GLOBAL_CALCS::DeltaLocalToLocal | ( | $DeltaLocal | ) |
Convert a region based Location using global delta off to local coordinates.
$DeltaLocal The Local Format coordinates with locations that can extend outside of the Region
This routine converters the position based on the bottom left corner of the region into true global coordinates and then converts them bacl to local coordinates where hte position is locatied within the limits of the named region.
Definition at line 422 of file os_global_calcs_dev.php.
References GlobalToLocal(), and RegionBoundsGlobal().
| OS_GLOBAL_CALCS::FromCourseTo | ( | $FromLocalArray, | |
| $CourseArray ) |
Routine to Calculate a Destination from an origin and a Course.
| $FromLocalArray | An array holding the local position of the Origin Point |
| $CourseArray | An array holding the information about the Course to follow |
This routine takes an origin location in local coordinates, converts it into global coordinates, changes the location based on the course data, and then converts it back into local coordinates.
NOTE If the destination is not contained within a defined region in the simulation, the result returned will have an empty string as the regions name and the XYZ coordinates will be -1 which also indicates that an error has occured.
Definition at line 259 of file os_global_calcs.php.
References GlobalToLocal(), and LocalToGlobal().
| OS_GLOBAL_CALCS::FromCourseTo | ( | $FromLocalArray, | |
| $CourseArray ) |
Definition at line 259 of file os_global_calcs_dev.php.
References GlobalToLocal(), and LocalToGlobal().
| OS_GLOBAL_CALCS::GlobalToLocal | ( | $GlobalArray | ) |
| $GlobalArray |
The $GlobalArray that is passed to this routines is formatted so that it can be used without change the SQL Query used to convert the global location parameters into the local address. The Global Array has the following keys:
The $LocalArray that is return is also in a format that can directly be used in subsequent SQL statements and has the following format
If the Global location cannot be transformed into a set of Regional coordinates, the routine returns a Local Array where the Region name is blank and the local coordinates are set to -1 since negative number wuold never appear in a real location.
The conversion from global to local coordinates can be done with a single SQL query as the edge of the region has already been calulated in global measurements, making the calculations simple comparisons and subtractions.
Definition at line 130 of file os_global_calcs.php.
Referenced by DeltaLocalToLocal(), and FromCourseTo().
| OS_GLOBAL_CALCS::GlobalToLocal | ( | $GlobalArray | ) |
Definition at line 130 of file os_global_calcs_dev.php.
| OS_GLOBAL_CALCS::LocalToGlobal | ( | $LocalArray | ) |
Convert a local regional location into a global location.
See the GlobalToLocal($GlobalArray) documentation for an explanation of the formats of the $GlobalArray and the $LocalArray
As can be seen the conversion is carried out by a single line SQL because the region table has the edge of the regions precalculated and add that is needed in simple additions and one comparison to find the regions's information.
Definition at line 179 of file os_global_calcs.php.
References $pdo.
Referenced by CourseFromTo(), FromCourseTo(), and RegionToDeltaLocal().
| OS_GLOBAL_CALCS::LocalToGlobal | ( | $LocalArray | ) |
Definition at line 179 of file os_global_calcs_dev.php.
References $pdo.
| OS_GLOBAL_CALCS::RegionBoundsGlobal | ( | $RegionName | ) |
Find the Bottom Left Corner and Top Right Corners in Global Coordinates.
| $RegionName | The name of the requested Region |
This function return the global ccorsinates of the bootom Left and upper right Corners of the requested Region. If the region is found, only the x and y coordinates are are used, and the low_global coordinate is set to 0 to indicate success.
If the query fails, the high_global coordinate are set to -1 to indicate that the query failed.
The results are returned in the following format:
Definition at line 309 of file os_global_calcs_dev.php.
Referenced by DeltaLocalToLocal().
| OS_GLOBAL_CALCS::RegionToDeltaLocal | ( | $FromLocal, | |
| $ToLocal ) |
| $FromLocal | The Origin point using local Coordinates |
| $ToLocal | The Destination Point in Local Coordinates |
This routine converts the Destination ($ToLocal) into global coordinates and get the difference from the Origin point of the Starting region ($FromLocal). These coordinates can be used by by the osTeleportObject() routine to teleport the object to another region.
NOTE: If the $toLocal is outside of the $FromLocal region, the result will use the $FromLocal region and the location will contain at least one value larger than the size of the region.
Definition at line 402 of file os_global_calcs_dev.php.
References $FromLocal, $ToLocal, DeltaGlobal(), and LocalToGlobal().
| OS_GLOBAL_CALCS::$Database |
The name of the Database.
Definition at line 40 of file os_global_calcs.php.
Referenced by __construct().
| OS_GLOBAL_CALCS::$Host |
The Host running the Database.
Definition at line 46 of file os_global_calcs.php.
Referenced by __construct().
| OS_GLOBAL_CALCS::$Password |
The password to access the Database.
Definition at line 58 of file os_global_calcs.php.
Referenced by __construct().
| OS_GLOBAL_CALCS::$Username |
The Username to access the Database.
Definition at line 52 of file os_global_calcs.php.
Referenced by __construct().