按照给定的 4x4 的变换矩阵移动、缩放或旋转一个物件。左边是矩阵变换方式。以下列表显示矩阵变换设置:
rhinoscriptsyntax.TransformObject (object_id, matrix, copy=False)
rhinoscript.object.TransformObject (object_id, matrix, copy=False)
object_id |
必须参数。字符串或 Guid。物件的 ID 。 |
matrix |
必须参数。数字或变换组成的 4x4 的列表。变换矩阵。 |
copy |
可选参数。布尔值。复制物件。如果省略,执行过程中不复制物件(False)。 |
Guid |
执行成功,返回变换得到物件的ID。 |
# Rotate an object by theta degrees about the world Z axis
import math
import rhinoscriptsyntax as rs
degrees = 90.0 # Some angle
radians = math.radians(degrees)
c = math.cos(radians)
s = math.sin(radians)
matrix = []
matrix.append( [c,-s, 0, 0] )
matrix.append( [s,c, 0, 0] )
matrix.append( [0, 0, 1, 0] )
matrix.append( [0, 0, 0, 1] )
obj = rs.GetObject("Select object to rotate")
if obj: rs.TransformObject( obj, matrix )