New*_*Dev 2 java rotation matrix rotational-matrices
我试图用Java逆时针旋转矩阵90度.我找到了如何用2D矩阵做到这一点的答案,但我的矩阵是3D.
以下是我如何进行2D旋转的方法:
static int[][] rotateCW(int[][] mat) {
final int M = mat.length;
final int N = mat[0].length;
int[][] ret = new int[N][M];
for (int r = 0; r < M; r++) {
for (int c = 0; c < N; c++) {
ret[c][M-1-r] = mat[r][c];
}
}
return ret;
}
Run Code Online (Sandbox Code Playgroud)
那我怎么去旋转3D矩阵呢?
通过将矩阵与旋转矩阵相乘
x轴的基本矩阵是:
| 1 0 0 |
Rx(a) = | 0 cos(a) -sin(a) |
| 0 sin(a) cos(a) |
Run Code Online (Sandbox Code Playgroud)
对于90度,只需设置cos(90)= 0和sin(90)= 1,这应该导致:
| 1 0 0 |
Rx(a) = | 0 0 -1 |
| 0 1 0 |
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6961 次 |
| 最近记录: |