row-major-order

why does pyrr.Matrix44 translation appear to be column-major, and rotation row-major?

我与影子孤独终老i 提交于 2020-04-30 09:12:29
问题 consider the following: >>>Matrix44.from_translation( np.array([1,2,3])) Matrix44([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [1, 2, 3, 1]]) >>> Matrix44.from_x_rotation(0.5 * np.pi) Matrix44([[ 1.0, 0.0, 0.0, 0.0], [ 0.0, 0.0, -1.0, 0.0], [ 0.0, 1.0, 0.0, 0.0], [ 0.0, 0.0, 0.0, 1.0]]) The translation matrix shows that the layout of the matrix is column-major, but the rotation matrix, confusingly, suggests that it is row-major, if you consider that the standard right-hand 3x3 rotation matrix

why does pyrr.Matrix44 translation appear to be column-major, and rotation row-major?

只愿长相守 提交于 2020-04-30 09:07:27
问题 consider the following: >>>Matrix44.from_translation( np.array([1,2,3])) Matrix44([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [1, 2, 3, 1]]) >>> Matrix44.from_x_rotation(0.5 * np.pi) Matrix44([[ 1.0, 0.0, 0.0, 0.0], [ 0.0, 0.0, -1.0, 0.0], [ 0.0, 1.0, 0.0, 0.0], [ 0.0, 0.0, 0.0, 1.0]]) The translation matrix shows that the layout of the matrix is column-major, but the rotation matrix, confusingly, suggests that it is row-major, if you consider that the standard right-hand 3x3 rotation matrix

Python row major to column major order vector

こ雲淡風輕ζ 提交于 2019-12-17 20:27:32
问题 Having a matrix like ma = [[0.343, 0.351, 0.306], [0.145, 0.368, 0.487]] I want to get a vector like: [0.343, 0.145, 0.351, 0.368, 0.306, 0.487] To try to get it, I am using numpy and reshape but it is not working. a = np.array(ma) >>> print a.shape (2, 3) But I am getting: c = a.reshape(3, 2, order='F') >>> print c array([[ 0.343, 0.368], [ 0.145, 0.306], [ 0.351, 0.487]]) What would be the best way to do it for any matrix size? I mean, for example, if matrix is not squared like: [[0.404, 0

what causes different in array sum along axis for C versus F ordered arrays in numpy

纵然是瞬间 提交于 2019-12-01 10:18:59
问题 I am curious if anyone can explain what exactly leads to the discrepancy in this particular handling of C versus Fortran ordered arrays in numpy . See the code below: system: Ubuntu 18.10 Miniconda python 3.7.1 numpy 1.15.4 def test_array_sum_function(arr): idx=0 val1 = arr[idx, :].sum() val2 = arr.sum(axis=(1))[idx] print('axis sums:', val1) print(' ', val2) print(' equal:', val1 == val2) print('total sum:', arr.sum()) n = 2_000_000 np.random.seed(42) rnd = np.random.random(n) print('Fortran

Python row major to column major order vector

本小妞迷上赌 提交于 2019-11-28 12:38:27
Having a matrix like ma = [[0.343, 0.351, 0.306], [0.145, 0.368, 0.487]] I want to get a vector like: [0.343, 0.145, 0.351, 0.368, 0.306, 0.487] To try to get it, I am using numpy and reshape but it is not working. a = np.array(ma) >>> print a.shape (2, 3) But I am getting: c = a.reshape(3, 2, order='F') >>> print c array([[ 0.343, 0.368], [ 0.145, 0.306], [ 0.351, 0.487]]) What would be the best way to do it for any matrix size? I mean, for example, if matrix is not squared like: [[0.404, 0.571, 0.025], [0.076, 0.694, 0.230], [0.606, 0.333, 0.061], [0.595, 0.267, 0.138]] I would like to get: