• 85.29% Rate
  • 29 Hits
  • 5 Missed
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 10x
  • 1x
  • 9x
  • 6x
  • 8x
  • 8x
  • 16x
  • 16x
  • 8x
  • 2x
  • 2x
  • 2x
  • 2x
  • 6x
  • 8x
  • 16x
  • 8x
  • 8x
  • 1x
  • -------------------------------------------------------------------------------
  • -- Coordinate frame(s) for PUMAS
  • -- Author: Valentin Niess
  • -- License: GNU LGPL-3.0
  • -------------------------------------------------------------------------------
  • local ffi = require('ffi')
  • local clib = require('pumas.clib')
  • local transform = require('pumas.coordinates.transform')
  • local type_ = require('pumas.coordinates.type')
  • local error = require('pumas.error')
  • local metatype = require('pumas.metatype')
  • local frame = {}
  • -------------------------------------------------------------------------------
  • -- Wrapper for local Earth frames
  • -------------------------------------------------------------------------------
  • local pumas_cartesian_point_t = ffi.typeof('struct pumas_cartesian_point')
  • local pumas_geodetic_point_t = ffi.typeof('struct pumas_geodetic_point')
  • function frame.LocalFrame (origin, options)
  • if origin == nil then
  • error.raise{fname = 'LocalFrame', argnum = 'bad', expected = 1, got = 0}
  • end
  • local geodetic
  • if ffi.istype(pumas_geodetic_point_t, origin) then
  • geodetic = origin
  • else
  • geodetic = type_.GeodeticPoint():set(origin)
  • end
  • if (not ffi.istype(pumas_cartesian_point_t, origin)) or
  • (origin.frame ~= nil) then
  • origin = type_.CartesianPoint():set(origin)
  • :transform(nil)
  • end
  • local declination, inclination
  • if options then
  • declination = options.declination or 0
  • if type(declination) ~= 'number' then
  • error.raise{fname = 'LocalFrame', argname = 'declination',
  • expected = 'a number', got = metatype.a(declination)}
  • end
  • inclination = options.inclination or 0
  • if type(inclination) ~= 'number' then
  • error.raise{fname = 'LocalFrame', argname = 'inclination',
  • expected = 'a number', got = metatype.a(inclination)}
  • end
  • else
  • declination, inclination = 0, 0
  • end
  • local self = transform.UnitaryTransformation()
  • clib.pumas_coordinates_frame_initialise_local(
  • self, origin, geodetic, declination, inclination)
  • return self
  • end
  • -------------------------------------------------------------------------------
  • -- Return the package
  • -------------------------------------------------------------------------------
  • return frame