nav_algo.coordinates module¶
-
class
nav_algo.coordinates.CoordinateSystem(latititude: float, longitude: float)¶ Bases:
objectA representation of a latitude/longitude coordinate system.
An object of type CoordinateSystem can be used to initialize a vector inside of a coordinate system with origin at LAT_OFFSET and LONG_OFFSET.
- Parameters
latitude (float) – The latitude of the origin of the system.
longitude (float) – The longitude of the origin of the system.
-
LAT_OFFSET¶ The latitude of the origin of the system.
- Type
float
-
LONG_OFFSET¶ The longitude of the origin of the system.
- Type
float
-
EARTH_RADIUS¶ The radius of the Earth (in meters).
- Type
float
-
class
nav_algo.coordinates.Vector(coord_sys=None, latitude=None, longitude=None, angle=None, x=None, y=None)¶ Bases:
objectA representation of 2D vectors with a coordinate system.
To construct a position vector, pass in a CoordinateSystem and a latitude and longitude. To specify only the x and y components, pass in x and y. Alternatively, to construct a unit vector with a given angle, pass in an angle.
- Parameters
coord_sys (CoordinateSystem) – (Optional) The coordinate system in which the vector lies.
latitude (float) – (Optional) The latitude of the position.
longitude (float) – (Optional) The longitude of the position.
angle (float) – (Optional) The angle (in degrees) used to construct a unit vector.
x (float) – (Optional) The x component of the vector.
y (float) – (Optional) The y component of the vector.
-
x¶ The x component of the vector.
- Type
float
-
y¶ The y component of the vector.
- Type
float
-
coordinate_system¶ (Optional) The coordinate system in which the vector lies.
- Type
-
latitude¶ (Optional) The latitude of the position.
- Type
float
-
longitude¶ (Optional) The longitude of the position.
- Type
float
-
angle()¶ Calculates the anglular distance between the vector and the x-axis.
The returned angle is between 0 and 360 degrees.
- Returns
The angle between the vector and North.
- Return type
float
-
dot(other)¶ Calculates the dot product of two vectors.
- Parameters
other (Vector) – The vector to dot with ‘self’.
- Returns
The dot product of ‘self’ and ‘other’.
- Return type
float
-
inverse()¶ Constructs the inverse of a vector.
- Returns
The inverse of the original vector.
- Return type
-
magnitude()¶ Calculates the magnitude of a vector.
- Returns
The magnitude of the vector.
- Return type
float
-
midpoint(other)¶ Calculates the midpoint between two positions.
-
toUnitVector()¶ Converts a vector to a unit vector.
- Returns
A unit vector representation of the input vector.
- Return type
-
vectorSubtract(other)¶ Calculates the vector difference between two vectors.
-
nav_algo.coordinates.degToRad(angle)¶ Converts from degrees to radians.
- Parameters
angle (float) – An angle in degrees.
- Returns
The angle in radians.
- Return type
float
-
nav_algo.coordinates.radToDeg(angle)¶ Converts from radians to degrees.
- Parameters
angle (float) – An angle in radians.
- Returns
The angle in degrees.
- Return type
float
-
nav_algo.coordinates.rangeAngle(angle)¶ Puts an angle with the range of 0 to 360.
- Parameters
angle (float) – An angle in degrees.
- Returns
An angle within the range of 0 to 360.
- Return type
float