execute store result score x motion_calc run data get entity @s Pos[0] 1000
execute store result score y motion_calc run data get entity @s Pos[1] 1000
execute store result score z motion_calc run data get entity @s Pos[2] 1000

tp @s ^ ^ ^.1

execute store result score dx motion_calc run data get entity @s Pos[0] 1000
execute store result score dy motion_calc run data get entity @s Pos[1] 1000
execute store result score dz motion_calc run data get entity @s Pos[2] 1000

scoreboard players operation dx motion_calc -= x motion_calc
scoreboard players operation dy motion_calc -= y motion_calc
scoreboard players operation dz motion_calc -= z motion_calc

scoreboard players set min rng 1
scoreboard players set max rng 4
function rng:interval
scoreboard players operation dx motion_calc *= out rng
scoreboard players operation dy motion_calc *= out rng
scoreboard players operation dz motion_calc *= out rng


execute store result entity @s Motion[0] double 0.002 run scoreboard players get dx motion_calc
execute store result entity @s Motion[1] double 0.001 run scoreboard players get dy motion_calc
execute store result entity @s Motion[2] double 0.002 run scoreboard players get dz motion_calc
