Re: pack/unpack pos to binary

From eeew, 11 Years ago, written in Lua, viewed 863 times. This paste is a reply to pack/unpack pos to binary from eeew - go back
URL https://paste.godclan.hu/view/66Od5M8-/diff Embed
Viewing differences between pack/unpack pos to binary and Re: pack/unpack pos to binary
function packpos(x, y, z)
    x = 819200+math.floor(x*100) -- -8192 - 8192   3 byte
    y = 819200+math.floor(y*100)
    z = math.floor(1300*65535/(z+100)) -- -100 - 1200   2 byte
    return string.byte(
        x, BitExtract(x, 8, 8), BitExtract(x, 16, 8)
8),
        y, BitExtract(y, 8, 8), BitExtract(x, 16, 8),
        z, BitExtract(z, 8, 8))
end

function unpackpos(string, startindex)
    local x1, x2, x3, y1, y2, y3, z1, z2 = string:byte(startindex, startindex + 7)
    return  ((x1 + x2*256 + x3*65536) - 819200)/100,
            ((y1 + y2*256 + y3*65536) - 819200)/100,
            (z1 + z2*256)/65535*1300 - 100
end

Replies to Re: pack/unpack pos to binary rss

Title Name Language When
Re: Re: pack/unpack pos to binar eeew lua 11 Years ago.

Reply to "Re: pack/unpack pos to binary"

Here you can reply to the paste above