• 93.55% Rate
  • 29 Hits
  • 2 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
  • 70
  • 71
  • 72
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 1x
  • 7x
  • 6x
  • 1x
  • 18x
  • 8x
  • 4x
  • 10x
  • 5x
  • 5x
  • 1x
  • 6x
  • 2x
  • 4x
  • 4x
  • 2x
  • 2x
  • 1x
  • 12x
  • 11x
  • 10x
  • 1x
  • -------------------------------------------------------------------------------
  • -- Coordinates systems for PUMAS
  • -- Author: Valentin Niess
  • -- License: GNU LGPL-3.0
  • -------------------------------------------------------------------------------
  • local ffi = require('ffi')
  • local frame = require('pumas.coordinates.frame')
  • local transform = require('pumas.coordinates.transform')
  • local type_ = require('pumas.coordinates.type')
  • local metatype = require('pumas.metatype')
  • local coordinates = {}
  • coordinates.LocalFrame = frame.LocalFrame
  • coordinates.UnitaryTransformation = transform.UnitaryTransformation
  • for k, v in pairs(type_) do
  • coordinates[k] = v
  • end
  • -------------------------------------------------------------------------------
  • -- Wrap setter for double[3]
  • -------------------------------------------------------------------------------
  • function coordinates.set_double3 (self, k, v)
  • if metatype(v) == 'Coordinates' then
  • self[k] = v:get()
  • return true
  • else
  • local ok, msg = pcall(function () self[k] = v end)
  • if ok then
  • return true
  • else
  • return false, msg:match(':%d+: (.+)$')
  • end
  • end
  • end
  • -------------------------------------------------------------------------------
  • -- Wrap conversion to double[3]
  • -------------------------------------------------------------------------------
  • function coordinates.to_double3 (v)
  • if metatype(v) == 'Coordinates' then
  • return true, v:get()
  • else
  • local ok, r = pcall(function ()
  • return ffi.new('double [3]', v) end)
  • if ok then
  • return true, r
  • else
  • return false, r:match(':%d+: (.+)$')
  • end
  • end
  • end
  • -------------------------------------------------------------------------------
  • -- Register the subpackage
  • -------------------------------------------------------------------------------
  • function coordinates.register_to (t)
  • for k, v in pairs(coordinates) do
  • if k ~= 'register_to' then
  • t[k] = v
  • end
  • end
  • end
  • -------------------------------------------------------------------------------
  • -- Return the package
  • -------------------------------------------------------------------------------
  • return coordinates