加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
transformers.py 947 Bytes
一键复制 编辑 原始数据 按行查看 历史
import numpy as np
"""
Helper functions to create various matrices
"""
def rotation_3d_from_angles(x_angle, y_angle=0, z_angle=0):
""" Creates a 3D rotation matrix given angles in degrees.
Positive angles rotates anti-clockwise.
:params x_angle, y_angle, z_angle: x, y, z angles between 0 to 360
:returns: 3x3 rotation matrix """
ax = np.deg2rad(x_angle)
ay = np.deg2rad(y_angle)
az = np.deg2rad(z_angle)
# Rotation matrix around x-axis
rx = np.array([
[1, 0, 0],
[0, np.cos(ax), -np.sin(ax)],
[0, np.sin(ax), np.cos(ax)]
])
# Rotation matrix around y-axis
ry = np.array([
[np.cos(ay), 0, np.sin(ay)],
[0, 1, 0],
[-np.sin(ay), 0, np.cos(ay)]
])
# Rotation matrix around z-axis
rz = np.array([
[np.cos(az), -np.sin(az), 0],
[np.sin(az), np.cos(az), 0],
[0, 0, 1]
])
return np.dot(np.dot(rx, ry), rz)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化