You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

旋转矩阵变换后点云变形问题(使用单位向量仍畸变)

点云旋转非90度倍数角度出现畸变问题

尝试绕某一轴按指定角度旋转点云以保证形状无畸变,但旋转非90度倍数的角度时,点云出现变形。已确保使用单位向量作为旋转轴,但畸变问题仍存在。

代码实现

import numpy as np
import math
import matplotlib.pyplot as plt

def rotation_matrix(axis, radian):
    ax, ay, az = axis[0], axis[1], axis[2]
    s = math.sin(radian)
    c = math.cos(radian)
    u = 1 - c
    return ( ( ax*ax*u + c,    ax*ay*u - az*s, ax*az*u + ay*s ),
             ( ay*ax*u + az*s, ay*ay*u + c,    ay*az*u - ax*s ),
             ( az*ax*u - ay*s, az*ay*u + ax*s, az*az*u + c    ) )

def get_ax():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    ax.set_xlabel('X')
    ax.set_ylabel('Y')
    ax.set_zlabel('Z')
    ax.set_ylim3d(-5, 5)
    ax.set_xlim3d(-5, 5)
    ax.set_zlim3d(-5, 5)
    return ax

# torus parameters
major_radius = 1.5
minor_radius = 2.9
density = 15
theta = np.linspace(0, 2 * np.pi, density)
phi = np.linspace(0, 2*np.pi, density)
Theta, Phi = np.meshgrid(theta, phi)

# parametric equations for the torus
x = (major_radius + minor_radius * np.cos(Theta)) * np.cos(Phi)
y = (major_radius + minor_radius * np.cos(Theta)) * np.sin(Phi)
z = minor_radius * np.sin(Theta)

# coordinate array
original_points = np.array([x.flatten(), y.flatten(), z.flatten()])

angles = np.array([0, 45, 90])

for angle in angles:

    # get R matrix for unit vec axis and angle
    R = rotation_matrix([0,1,0], np.radians(angle))

    # rotate points by R and plot
    rotated_points = np.dot(R, original_points)
    rotated_x = rotated_points[0]
    rotated_y = rotated_points[1]
    rotated_z = rotated_points[2]
    ax = get_ax()
    ax.scatter(rotated_x, rotated_y, rotated_z, color='black')
    plt.show()

畸变效果

旋转45度时的效果如下,该形状本应对称,倾斜视角更容易观察到畸变:

旋转45度时的点云

内容的提问来源于stack exchange,提问作者satindressedup4

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 17:08:33