Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

rotate

以指定原点和方向旋转对象

语法

rotate(h,direction,alpha)
rotate(...,origin)

说明

rotate 函数在三维空间中旋转图形对象。

rotate(h,direction,alpha) 将图形对象 h 旋转 alpha 度。指定 h 为曲面、补片、线条、文本或图像对象。direction 是一个二元素或三元素向量,它与旋转轴原点共同确定旋转轴。旋转轴的默认原点是图框中心。该点未必是坐标区的原点。

alpha 定义围绕方向向量从旋转原点伸展的右旋角度。

如果 h 为句柄数组,则所有对象必须为相同坐标区的子级。

rotate(...,origin) 将旋转轴的原点指定为三元素向量 [x0,y0,z0]

注意

图像对象不支持三维数据。因此,不支持将图像旋转至 x-y 平面之外。

示例

全部折叠

创建 peaks 函数的曲面图并返回曲面对象。

s = surf(peaks(20));
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')

Figure contains an axes object. The axes object with xlabel x-axis, ylabel y-axis contains an object of type surface.

将曲面图绕其 x 轴旋转 25 度。

direction = [1 0 0];
rotate(s,direction,25)

Figure contains an axes object. The axes object with xlabel x-axis, ylabel y-axis contains an object of type surface.

创建 peaks 函数的曲面图并返回曲面对象。

s = surf(peaks(20));
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')

Figure contains an axes object. The axes object with xlabel x-axis, ylabel y-axis contains an object of type surface.

将曲面图绕其 y 轴旋转 25 度。

direction = [0 1 0];
rotate(s,direction,25)

Figure contains an axes object. The axes object with xlabel x-axis, ylabel y-axis contains an object of type surface.

创建 peaks 函数的曲面图并返回曲面对象。

s = surf(peaks(20));
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')

Figure contains an axes object. The axes object with xlabel x-axis, ylabel y-axis contains an object of type surface.

将曲面图绕其 x 轴和 y 轴旋转 25 度。

direction = [1 1 0];
rotate(s,direction,25)

Figure contains an axes object. The axes object with xlabel x-axis, ylabel y-axis contains an object of type surface.

提示

旋转变换会修改对象的数据。此方法不同于 viewrotate3d(仅修改视点)使用的方法。

旋转轴由旋转原点和点 P 定义。将 P 指定为球面坐标 [theta phi] 或笛卡尔坐标 [xp,yp,zp]

Cartesian axes displaying the axis of rotation relative to an origin of rotation and point P

direction 的二元素形式中,thetax 的正轴在 x-y 平面中的逆时针角度。phi 是方向向量在 x-y 平面中的仰角。

Cartesian axes displaying the location of point P relative to theta and phi

三元素形式的 direction 指定使用笛卡尔坐标的轴方向。方向向量是从旋转原点到 P 的向量。

提示

rotate 更改 XdataYdataZdata 属性的值以旋转图形对象。

版本历史记录

在 R2006a 之前推出

另请参阅

| |