half extents

half extents

blue line is hypotenuse

From there you can simply linearly add Pi/4 to the angle (45 degrees), then use:

newx = cos(newAngle)*dist;
newy = sin(newAngle)*dist;

 

http://gamedev.stackexchange.com/questions/14733/aabb-of-rotated-sprite

posted on 2016-12-22 16:38 jiahuafu 阅读(...) 评论(...) 编辑 收藏

import numpy as np from panda_gym.pybullet import PyBullet from panda_gym.envs.core import Task from panda_gym.utils import distance class MyTask(Task): def __init__(self, sim): super().__init__(sim) # create an cube self.sim.create_box(body_name="object", half_extents=np.array([1, 1, 1]), mass=1.0, position=np.array([0.0, 0.0, 0.0])) def reset(self): # randomly sample a goal position self.goal = np.random.uniform(-10, 10, 3) # reset the position of the object self.sim.set_base_pose("object", position=np.array([0.0, 0.0, 0.0]), orientation=np.array([1.0, 0.0, 0.0, 0.0])) def get_obs(self): # the observation is the position of the object observation = self.sim.get_base_position("object") return observation def get_achieved_goal(self): # the achieved goal is the current position of the object achieved_goal = self.sim.get_base_position("object") return achieved_goal def is_success(self, achieved_goal, desired_goal, info={}): # info is here for consistancy # compute the distance between the goal position and the current object position d = distance(achieved_goal, desired_goal) # return True if the distance is < 1.0, and False otherwise return np.array(d < 1.0, dtype=bool) def compute_reward(self, achieved_goal, desired_goal, info={}): # info is here for consistancy # for this example, reward = 1.0 if the task is successfull, 0.0 otherwise return self.is_success(achieved_goal, desired_goal, info).astype(np.float32) sim = PyBullet(render_mode="human") task = MyTask(sim) task.reset() print(task.get_obs()) print(task.get_achieved_goal()) print(task.is_success(task.get_achieved_goal(), task.get_goal())) print(task.compute_reward(task.get_achieved_goal(), task.get_goal()))
09-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

银狐游戏开发资源2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值