rotation 相关问题

旋转是物体围绕旋转中心(或点)的圆周运动。在移动设备上,它表示方向的变化。

用变焦中心(Delphi,FMX)rot旋转图像

我是在窗口上首先尝试此操作。 现在一切正常,除了图像旋转时,特定的变焦中心的缩放不起作用(缩放中心移动)。 旋转= 0时确实可以正常工作。 我可以再次沉迷于数学上以获得正确的图像位置方程,但是首先想在这里询问某人是否以前解决了这个问题。

回答 1 投票 0


matplotlib多边形:旋转后多边形偏斜

import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection import numpy as np # Create a new figure with 3D projection fig = plt.figure() ax = fig.add_subplot(111, projection='3d') def rotate_shape_to_normal(vertices, face_indices, target_normal): """ Rotate vertices so that the face specified by face_indices becomes normal to target_normal. :param vertices: List or numpy array of 3D points defining the shape :param face_indices: Indices of the vertices that form the face to align :param target_normal: The vector to which the face should be normal :return: Rotated vertices """ vertices = np.array(vertices) # Convert to numpy array if it isn't already face_vertices = vertices[face_indices] # Calculate the normal vector of the face v1 = face_vertices[1] - face_vertices[0] v2 = face_vertices[2] - face_vertices[0] face_normal = np.cross(v1, v2) print(face_normal) ax.quiver(*face_vertices[0], *face_normal, color='r', length=2) ax.quiver(*face_vertices[0], *target_normal, color='b', length=2) face_normal = face_normal / np.linalg.norm(face_normal) # Normalize # Normalize target_normal for consistency target_normal = target_normal / np.linalg.norm(target_normal) # Compute the rotation axis (perpendicular to both vectors) rotation_axis = np.cross(face_normal, target_normal) rotation_axis = rotation_axis / np.linalg.norm(rotation_axis)# if np.linalg.norm(rotation_axis) > 0 else np.array([1, 0, 0]) # Default to x-axis if parallel print("rotation_axis", rotation_axis) # Compute the angle between the vectors cos_theta = np.dot(face_normal, target_normal) print("cos_theta", np.degrees(cos_theta)) theta = np.arccos(np.clip(cos_theta, -1.0, 1.0)) # Clip to avoid floating-point issues print("theta", np.degrees(theta)) # Check if vectors are already aligned or opposite if np.isclose(theta, 0) or np.isclose(theta, np.pi): return vertices # No rotation needed # Rodrigues' rotation formula K = np.array([ [0, -rotation_axis[2], rotation_axis[1]], [rotation_axis[2], 0, -rotation_axis[0]], [-rotation_axis[1], rotation_axis[0], 0] ]) rotation_matrix = np.sin(theta) * K + (1 - np.cos(theta)) * np.outer(rotation_axis, rotation_axis) # Apply the rotation to all vertices return np.dot(vertices, rotation_matrix.T) # Define the vertices for a simple satellite model: vertices = np.array([ # Main body (cube) (0, 0, 0), # 0 - Base, front-left (1, 0, 0), # 1 - Base, front-right (1, 1, 0), # 2 - Base, back-right (0, 1, 0), # 3 - Base, back-left (0, 0, 1), # 4 - Top, front-left (1, 0, 1), # 5 - Top, front-right (1, 1, 1), # 6 - Top, back-right (0, 1, 1), # 7 - Top, back-left # Solar panels # Left panel (0.5, .25, -1.5), # 8 (0.5, .75, -1.5), # 9 (0.5, .75, 0), # 10 (0.5, .25, 0), # 11 # Right panel (0.5, .25, 2.5), # 12 (0.5, .75, 2.5), # 13 (0.5, .75, 1), # 14 (0.5, .25, 1) # 15 ]) # Translate spacecraft to origin vertices = [(x - .5, y - .5, z - .5) for x, y, z in vertices] # Original points ax.scatter(vertices[5][0], vertices[5][1],vertices[5][2], color='green', s=25) ax.scatter(vertices[1][0], vertices[1][1],vertices[1][2], color='green', s=25) ax.scatter(vertices[4][0], vertices[4][1],vertices[4][2], color='green', s=25) # Rotate spacecraft to point at specified vector face_to_align = [5, 1, 4] # Indexes of points that define the face I want to be normal to the specified vector (-Y) #vector = np.array([0, 0, 1]) # This rotation doesn't skew anything vector = np.array([0.56167836, 0.76075023, 0.32523301]) # This rotation skews everything vertices = rotate_shape_to_normal(vertices, face_to_align, vector) # Rotated points ax.scatter(vertices[5][0], vertices[5][1],vertices[5][2], color='blue', s=25) ax.scatter(vertices[1][0], vertices[1][1],vertices[1][2], color='blue', s=25) ax.scatter(vertices[4][0], vertices[4][1],vertices[4][2], color='blue', s=25) # Faces for the cube cube_faces = [ [vertices[0], vertices[1], vertices[5], vertices[4]], # (-Y) [vertices[1], vertices[2], vertices[6], vertices[5]], # (+X) [vertices[2], vertices[3], vertices[7], vertices[6]], # (+Y) [vertices[3], vertices[0], vertices[4], vertices[7]], # (-X) [vertices[0], vertices[1], vertices[2], vertices[3]], # (-Z) [vertices[4], vertices[5], vertices[6], vertices[7]], # (+Z) ] # Solar panel faces - note these are just rectangles left_panel = [vertices[8], vertices[9], vertices[10], vertices[11]] right_panel = [vertices[12], vertices[13], vertices[14], vertices[15]] # Combine all faces faces = cube_faces + [left_panel, right_panel] # Create Poly3DCollection poly3d = Poly3DCollection(faces, alpha=0.7) poly3d.set_edgecolor('k') # Set face color for different parts poly3d.set_facecolor([[1, 0, 0], [.7, .7, .7], [.7, .7, .7], [.7, .7, .7], [.7, .7, .7], [.7, .7, .7], [0, 0.5, 1], [0, 0.5, 1]]) ax.add_collection3d(poly3d) # Set the aspect ratio to ensure it looks like a cube ax.set_box_aspect((1, 1, 1)) # Remove axes for a cleaner look #ax.set_axis_off() # Set limits to see everything ax.set_xlim(-1, 2) ax.set_ylim(-1, 2) ax.set_zlim(-1, 2) # Origin ax.scatter(0, 0, 0, color='red', s=25) ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') # Adjust view for better visualization ax.view_init(elev=20., azim=-45) plt.show()

回答 1 投票 0

2d欧几里得矢量旋转

i有一个欧几里得矢量A位于坐标(0,1)。 我想围绕原点旋转90度(顺时针):(0,0)。 如果我对此有适当的了解,那么

回答 5 投票 0


列表中的Rotating值[Python]

我以前知道这个问题已经问过,但是我没有看到任何以某种方式回答的问题,而没有分解列表。 说我有一个清单: num = [1,2,3,4,5,6] 我想创建一个函数: r ...

回答 4 投票 0

使用CSS将所有html元素(整个页面)旋转90度?

我想显示页面中的所有内容一致且独立地旋转90度,我尝试这样做,但结果不准确,每个元素独立旋转。

回答 3 投票 0


旋转对象数组,使具有特定属性的对象成为第一个元素

我有以下数组: $myarray = 数组 ( [1] => stdClass 对象 ( [ID] => 1 [当前] => ) [2] => stdClass 对象 ( [ID] => 2 [当前] => 1 ) [3] =&...

回答 3 投票 0

处理 3D 局部旋转

所以我试图在处理中模拟机械臂,并使其大部分工作。我遇到的问题是最后一个手臂部分(不包括钳子)需要沿着它自己的关系旋转......

回答 1 投票 0

如何将旋转的子图叠加到另一个子图上?

我想发布如图所示的绘图配置: 接下来的参数必须是可变的: 子图原点的位置 子图旋转角度 子尺寸...

回答 1 投票 0

旋转平面数组以从指定元素开始

我有一个像这样的元素数组: $数据 = 数组(1, 2, 3, 4); 例如,如何重新排序,从第二个元素开始得到 2, 3, 4, 1;或者从第三个元素开始得到3,4,1,2?

回答 3 投票 0

将数组的最后一个值旋转为第一个元素,而不旋转键

如何在 php 中旋转数组的值? 例如: array ('比尔'=>'鲍勃','马利'=>'玛丽','杰克'=>'杰克'); 这样它就会旋转值并保留密钥,这样它就会......

回答 3 投票 0

X轴随GD旋转

我尝试从数据库生成一个 JPEG 文件,其中包含位于容器中的元素,其中包含坐标(x,y)、大小(宽/高)、x 轴角度和纹理图像。 我已经安装了 GD 扩展...

回答 1 投票 0

如何正确旋转OBB?

我用OpenGL制作了一个汽车模拟器。对于汽车碰撞盒,我使用了 OBB。问题是当我想旋转碰撞盒时。为此我使用这个函数: std::向量

回答 1 投票 0

立方体在 3D 空间中统一旋转

我喜欢在垂直轴和水平轴上旋转立方体。 为此我有 4 个输入。左/右和上/下旋转。每个轴的输入范围为 -180 至 180 度。 我已经尝试过...

回答 1 投票 0

使用旋转矩阵将 2D 数组旋转一定角度

我想要做的是将 2D numpy 数组旋转给定角度。我采用的方法是使用旋转矩阵。我定义的旋转矩阵为: 角度 = 65。 θ=(角度/180。)* numpy.pi

回答 5 投票 0

每次启动应用程序时轮换日志文件 (Python)

我正在Python中使用日志记录模块,我希望它在每次启动我的应用程序时创建一个新的日志文件。应轮换较旧的日志文件(例如:logfile.txt -> logfile1.txt 等)。 我

回答 6 投票 0

翻转 Excel 文件中的文本

我有一个电子表格(宽 900 个单元格,长 2000 个单元格),其设计需要垂直和水平翻转。 我手动转换了大约 30 个文本框中的文本,然后应用了 3D 旋转...

回答 1 投票 0

有没有办法确保iPad模拟器横向屏幕截图正确旋转?

我开发的大多数iPad应用程序都是在横向模式下使用的。 iPad 模拟器始终以纵向模式启动;使用 ⌘+R 我将其旋转为横向模式。过去(iOS 13.0 或 13.1 之前),

回答 2 投票 0

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.