VR-Forces 5.1 Lua Function Documentation

Location3D

(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)

This module contains functions for creating and operating on a 3D point object.

Function List

Location3D (latitude, longitude, altitude) The constructor for Location3D.
addVector3D (vector) Adds a 3D vector to a location to produce a new location.
addVectorGeoc3D (vector) Adds a 3D vector to a location to produce a new location.
distanceToLocation3D (location) Gets the distance from this location to the given one.
getAlt () Altitude of location in meters above sea level
getGeocentric () Gets this location in geocentric coordinates.
getLat () Latitude of location in radians
getLon () Longitude of location in radians
isInsidePolygon (polyPoints) Determines if this point is inside the given polygon.
isLeftOfLine (loc1, loc2) Determines whether this point is left of the line defined by the two locations.
isNearLocation3D (location, error) Determines whether the given location is within a given distance threshold of this location.
makeCopy () Makes a copy of the given location object.
setAlt (altitude) Sets the altitude component of this location.
setGeocentric (x, y, z) Sets this location using geocentric coordinates.
setLat (latitude) Sets the latitude component of this location.
setLon (longitude) Sets the longitude component of this location.
vectorGeocToLoc3D (location) Computes and returns a 3D vector from this location to the given location.
vectorToLoc3D (location) Computes and returns a 3D vector from this location to the given location.


Functions

Location3D (latitude, longitude, altitude)
The constructor for Location3D.

Parameters:

  • latitude: (double) In radians.
  • longitude: (double) In radians. West longitude is negative.
  • altitude: (double) Altitude above sea level, in meters.

Usage:

    location = Location3D(latitude, longitude, altitude)

Return value:

    A Location3D object.
addVector3D (vector)
Adds a 3D vector to a location to produce a new location. Because the vector is a Vector3D:
- a long vector will wrap around the curve of the earth.
- a vector with no Down component will produce a location at the *same altitude* as this location, at a new latitude and longitude.
- a vector with a given compass heading will generate a new location at that *same heading* from this location, no matter where on earth this location is.

Parameters:

  • vector: A Vector3D.

Return value:

    A Location3D
addVectorGeoc3D (vector)
Adds a 3D vector to a location to produce a new location.

Parameters:

  • vector: A VectorGeoc3D.

Return value:

    A Location3D.
distanceToLocation3D (location)
Gets the distance from this location to the given one. Follows the vector3D from point to point, i.e. follows the curve of the earth. Thus the distance between points on opposite sides of the earth is half the circumference of the earth, not the diameter.

Parameters:

  • location: (Location3D) A Location3D.

Return value:

    A number giving the distance in meters.
getAlt ()
Altitude of location in meters above sea level

Return value:

    The altitude of the location, in meters above sea level.
getGeocentric ()
Gets this location in geocentric coordinates.

Return value:

    x, y, z values of the geocentric position.
getLat ()
Latitude of location in radians

Return value:

    The latitude of the location, in radians.
getLon ()
Longitude of location in radians

Return value:

    The longitude of the location, in radians.
isInsidePolygon (polyPoints)
Determines if this point is inside the given polygon. Both this point and the polygon are projected onto the earth at altitude 0. The polygon is defined by polyPoints, which is a table of Location3Ds. The polygon can be concave. The points can be in clockwise or counter clockwise order.

Parameters:

  • polyPoints: A table of Location3Ds describing the polygon.

Return value:

    A boolean that is true if this point is inside the polygon.
isLeftOfLine (loc1, loc2)
Determines whether this point is left of the line defined by the two locations. "Left" is from the point of view of an upright observer on the earth at loc1.

Parameters:

  • loc1: Location3D of the first point defining the line.
  • loc2: Location3D of the second point defining the line.

Return value:

    Boolean, true if this point is to the left of the line.
isNearLocation3D (location, error)
Determines whether the given location is within a given distance threshold of this location.

Parameters:

  • location: A Location3D.
  • error: A number representing the distance threshold.

Return value:

    Boolean that is true if the location is within the error distance.
makeCopy ()
Makes a copy of the given location object.

Return value:

    Location3D that is a copy of this object.
setAlt (altitude)
Sets the altitude component of this location.

Parameters:

  • altitude: (double) The altitude of the location, in meters above sea level.
setGeocentric (x, y, z)
Sets this location using geocentric coordinates.

Parameters:

  • x:
  • y:
  • z:
setLat (latitude)
Sets the latitude component of this location.

Parameters:

  • latitude: (double) The latitude of the location, in radians.
setLon (longitude)
Sets the longitude component of this location.

Parameters:

  • longitude: (double) The longitude of the location, in radians.
vectorGeocToLoc3D (location)
Computes and returns a 3D vector from this location to the given location. Because the result is a VectorGeoc3D, the length of the vector will be the straight-line distance between locations.

Parameters:

  • location: A Location3D.

Return value:

    A VectorGeoc3D representing the straight-line offset between locations.
vectorToLoc3D (location)
Computes and returns a 3D vector from this location to the given location. Because the result is a Vector3D, the heading of this vector is the heading of a great circle route to the given location, and the length of the vector is the distance around the earth to the given location.

Parameters:

  • location: A Location3D.

Return value:

    A Vector3D representing the around-the-earth offset between locations.

Copyright© 2024 MAK Technologies, Inc. All rights reserved.