Function directx_math::XMStoreFloat4x3[][src]

pub fn XMStoreFloat4x3(pDestination: &mut XMFLOAT4X3, M: FXMMATRIX)

Stores an XMMATRIX in an XMFLOAT4X3.

Parameters

pDestination Address at which to store the data.

M Matrix containing the data to store.

Return value

None.

Remarks

XMFLOAT4X3 is a row-major matrix form. This function cannot be used to write out column-major data since it assumes the last column is 0 0 0 1.

This function takes a matrix and writes the components out to twelve single-precision floating-point values at the given address. The most significant component of the first row vector is written to the first four bytes of the address, followed by the second most significant component of the first row, followed by the third most significant component of the first row. The most significant three components of the second row are then written out in a like manner to memory beginning at byte 12, followed by the third row to memory beginning at byte 24, and finally the fourth row to memory beginning at byte 36.

The following pseudocode demonstrates the operation of the function.

pDestination->_11 = M[0].x; // 4 bytes to address (uint8_t*)pDestination
pDestination->_12 = M[0].y; // 4 bytes to address (uint8_t*)pDestination + 4
pDestination->_13 = M[0].z; // 4 bytes to address (uint8_t*)pDestination + 8

pDestination->_21 = M[1].x; // 4 bytes to address (uint8_t*)pDestination + 12
pDestination->_22 = M[1].y; // 4 bytes to address (uint8_t*)pDestination + 16
pDestination->_23 = M[1].z; // 4 bytes to address (uint8_t*)pDestination + 20

pDestination->_31 = M[2].x; // 4 bytes to address (uint8_t*)pDestination + 24
pDestination->_32 = M[2].y; // 4 bytes to address (uint8_t*)pDestination + 28
pDestination->_33 = M[2].z; // 4 bytes to address (uint8_t*)pDestination + 32

pDestination->_41 = M[3].x; // 4 bytes to address (uint8_t*)pDestination + 36
pDestination->_42 = M[3].y; // 4 bytes to address (uint8_t*)pDestination + 40
pDestination->_43 = M[3].z; // 4 bytes to address (uint8_t*)pDestination + 44

Example

let m = XMMatrix::from(&[
    [10.0, 11.0, 12.0, 0.0],
    [13.0, 14.0, 15.0, 0.0],
    [16.0, 17.0, 18.0, 0.0],
    [19.0, 20.0, 21.0, 1.0],
]);

let mut data = XMFLOAT4X3::default();
XMStoreFloat4x3(&mut data, *m);

let data: &[[f32; 3]; 4] = data.as_ref();
assert_eq!(data, &[
    [10.0, 11.0, 12.0],
    [13.0, 14.0, 15.0],
    [16.0, 17.0, 18.0],
    [19.0, 20.0, 21.0],
]);

Reference

https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-XMStoreFloat4x3