-
90.16%
Rate
-
55
Hits
-
6
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
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
-
-
-
-
-
- 1x
- 1x
- 1x
- 1x
-
- 1x
-
-
-
-
-
- 1x
- 1x
-
-
- 1x
-
- 2x
- 15x
-
-
-
-
- 30x
- 2x
- 2x
-
-
- 14x
-
- 14x
- 1x
-
-
-
- 26x
- 9x
- 8x
- 3x
-
- 1x
-
-
- 12x
- 12x
- 2x
-
-
- 10x
- 10x
- 10x
- 10x
- 28x
- 18x
- 36x
- 18x
- 18x
- 18x
- 18x
-
-
-
-
-
- 20x
- 10x
-
- 10x
-
-
-
- 1x
- 85x
-
- 85x
- 85x
- 85x
- 42x
- 44x
- 44x
- 44x
-
-
- 85x
-
-
-
- 2x
- 2x
-
- 1x
-
-
- 2x
- 1x
-
-
- 1x
-
-
-
-
-
-
-
-
- 1x
- -------------------------------------------------------------------------------
- -- Coordinates transformations for PUMAS
- -- Author: Valentin Niess
- -- License: GNU LGPL-3.0
- -------------------------------------------------------------------------------
- local ffi = require('ffi')
- local clib = require('pumas.clib')
- local error = require('pumas.error')
- local metatype = require('pumas.metatype')
-
- local transform = {}
-
-
- -------------------------------------------------------------------------------
- -- The transform metatype
- -------------------------------------------------------------------------------
- local UnitaryTransformation = {__index = {}}
- UnitaryTransformation.__index.__metatype = 'UnitaryTransformation'
-
-
- local raise_error = error.ErrorFunction{fname = 'from_euler'}
-
- function UnitaryTransformation.__index:from_euler (axis,...)
- if (self == nil) or (axis == nil) then
- local nargs = (self ~= nil) and 1 or 0
- raise_error{argnum = 'bad', expected = '3 or more', got = nargs}
- end
-
- if metatype(self) ~= 'UnitaryTransformation' then
- raise_error{argnum = 1, expected = 'a UnitaryTransformation cdata',
- got = metatype.a(self)}
- end
-
- if type(axis) ~= 'string' then
- raise_error{argnum = 2, expected = 'a string', got = metatype.a(axis)}
- elseif axis:gsub('[^XYZxyz]', '') ~= axis then
- raise_error{argnum = 2, description = "bad axis '"..axis.."'"}
- end
-
- local intrinsic
- if axis:upper() == axis then
- intrinsic = true
- elseif axis:lower() == axis then
- intrinsic = false
- else
- raise_error{argnum = 2, description = "bad axis '"..axis.."'"}
- end
-
- local angles = {...}
- if #angles ~= #axis then
- raise_error{argnum = 'bad', expected = #axis + 2, got = #angles + 2}
- end
-
- local n = #axis
- local c_axis = ffi.new('int [?]', n)
- local c_angles = ffi.new('double [?]', n)
- local indices = {x = 0, y = 1, z = 2}
- for i = 1, n do
- local tag = axis:sub(i,i)
- local index = indices[tag:lower()]
- if index then
- local ii = intrinsic and i - 1 or n - i
- c_angles[ii] = angles[i]
- c_axis[ii] = index
- else
- raise_error{argnum = 1, expected = 'x, y or z', got = tag}
- end
- end
-
- clib.pumas_coordinates_unitary_transformation_from_euler(
- self, n, c_axis, c_angles)
-
- return self
- end
-
-
- function UnitaryTransformation.__new (ct, ...)
- local self = ffi.new(ct, ...)
-
- local n = select('#', ...)
- local arg1 = select(1, ...)
- if (n == 0) or
- ((n == 1) and (type(arg1) == 'table') and (not arg1.matrix)) then
- self.matrix[0][0] = 1
- self.matrix[1][1] = 1
- self.matrix[2][2] = 1
- end
-
- return self
- end
-
-
- transform.UnitaryTransformation = ffi.metatype(
- 'struct pumas_coordinates_unitary_transformation', UnitaryTransformation)
-
- error.register('UnitaryTransformation', UnitaryTransformation)
-
-
- function UnitaryTransformation.__index:clone ()
- if self then
- return transform.UnitaryTransformation(self)
- else
- error.raise{fname = 'clone', argnum = 1,
- expected = 'a UnitaryTransformation cdata', got = 'nil'}
- end
- end
-
-
- -------------------------------------------------------------------------------
- -- Return the package
- -------------------------------------------------------------------------------
- return transform