diff options
Diffstat (limited to 'examples/pybullet/gym/pybullet_utils/math_util.py')
-rw-r--r-- | examples/pybullet/gym/pybullet_utils/math_util.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/pybullet/gym/pybullet_utils/math_util.py b/examples/pybullet/gym/pybullet_utils/math_util.py index d0f333b3f..260a5da36 100644 --- a/examples/pybullet/gym/pybullet_utils/math_util.py +++ b/examples/pybullet/gym/pybullet_utils/math_util.py @@ -4,15 +4,19 @@ RAD_TO_DEG = 57.2957795 DEG_TO_RAD = 1.0 / RAD_TO_DEG INVALID_IDX = -1 + def lerp(x, y, t): - return (1 - t) * x + t * y + return (1 - t) * x + t * y + def log_lerp(x, y, t): - return np.exp(lerp(np.log(x), np.log(y), t)) + return np.exp(lerp(np.log(x), np.log(y), t)) + def flatten(arr_list): - return np.concatenate([np.reshape(a, [-1]) for a in arr_list], axis=0) + return np.concatenate([np.reshape(a, [-1]) for a in arr_list], axis=0) + def flip_coin(p): - rand_num = np.random.binomial(1, p, 1) - return rand_num[0] == 1
\ No newline at end of file + rand_num = np.random.binomial(1, p, 1) + return rand_num[0] == 1 |