Rotate object about specified origin and direction (2024)

Rotate object about specified origin and direction

collapse all in page

    Syntax

    rotate(h,direction,angle)

    rotate(h,direction,angle,origin)

    Description

    example

    Note

    hgtransform is recommended over rotate because it provides better performance. Consider using hgtransform unless you need to specify the origin of the axis of rotation.

    rotate(h,direction,angle) rotates the graphics object h in the specified direction by the specified number of degrees. rotate modifies the data of the graphics object, including the values of the Xdata, Ydata, and Zdata properties. This behavior is different from that of view and rotate3d, which modify only the viewpoint.

    example

    rotate(h,direction,angle,origin) specifies the origin of the axis of rotation. The default origin of the axis of rotation is the center of the plot box. This point is not necessarily the origin of the axes.

    Examples

    collapse all

    Rotate Plot Around x-Axis

    Open Live Script

    Create a surface plot of the peaks function and return the surface object.

    s = surf(peaks(20));xlabel("x-axis")ylabel("y-axis")zlabel("z-axis")axis([0 20 0 20 -10 10])

    Rotate the surface plot 25 degrees clockwise around its x-axis.

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

    Rotate object about specified origin and direction (2)

    Rotate Plot Around x-Axis and y-Axis

    Open Live Script

    Create a surface plot of the peaks function and return the surface object.

    s = surf(peaks(20));xlabel("x-axis")ylabel("y-axis")zlabel("z-axis")axis([0 20 0 20 -10 10])

    Rotate object about specified origin and direction (3)

    Rotate the surface plot 25 degrees clockwise around its x-axis and y-axis.

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

    Rotate object about specified origin and direction (4)

    Rotate Plot Around Specified Origin

    Open Live Script

    Create a surface plot of the peaks function and return the surface object.

    s = surf(peaks(20));xlabel("x-axis")ylabel("y-axis")zlabel("z-axis")axis([0 20 0 20 -10 10])

    Rotate object about specified origin and direction (5)

    Rotate the surface plot 30 degrees counterclockwise around its y-axis, and set the origin of rotation to (20, 10, 0).

    s = surf(peaks(20));xlabel("x-axis")ylabel("y-axis")zlabel("z-axis")axis([0 20 0 20 -10 10])direction = [0 -1 0];origin = [20 10 0];rotate(s,direction,30,origin)

    Rotate object about specified origin and direction (6)

    Input Arguments

    collapse all

    hGraphics object
    single object | vector of objects

    Graphics object, specified as a single object or a vector of objects of one of these types:

    • Surface object

    • Patch object

    • Line object

    • Text object

    If h is a vector of objects, all objects must be children of the same axes.

    Note

    Image objects do not support 3-D data. Therefore, any rotation of an image out of the xy-plane is not supported.

    directionDirection of axis of rotation
    two-element vector of spherical coordinates | three-element vector of Cartesian coordinates

    Direction of the axis of rotation, specified as a two-element vector of spherical coordinates ([theta phi]) or a three-element vector of Cartesian coordinates ([x y z]). Specify theta and phi in degrees.

    For more information about specifying direction, see Axis of Rotation.

    Example: rotate(h,[1 0 0],25) rotates the specified object clockwise around the x-axis.

    Example: rotate(h,[90 0],25) rotates the specified object clockwise around the y-axis.

    angleAngle of rotation
    scalar value in degrees

    Angle of rotation, specified as a scalar value in degrees.

    Example: rotate(h,[1 0 0],25) rotates the specified object 25 degrees clockwise around the x-axis.

    originOrigin of axis of rotation
    three-element vector of Cartesian coordinates

    Origin of the axis of rotation, specified as a three-element vector of Cartesian coordinates [x y z].

    The default origin of the axis of rotation is the center of the plot box. This point is not necessarily the origin of the axes.

    More About

    collapse all

    Axis of Rotation

    The axis of rotation is defined by an origin of rotation and a direction vector or point P. For the rotate function, use the direction input argument to specify P as the spherical coordinates [theta phi] or as the Cartesian coordinates [x y z].

    In the two-element form for direction, theta is the angle in the xy-plane counterclockwise from the positive x-axis. phi is the elevation of the direction vector from the xy-plane.

    Rotate object about specified origin and direction (7)

    The three-element form for direction specifies the Cartesian coordinates of point P. The axis of rotation follows the direction vector from the origin of rotation to P.

    Rotate object about specified origin and direction (8)

    Version History

    Introduced before R2006a

    See Also

    hgtransform | view | rotate3d | sph2cart

    MATLAB-Befehl

    Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

     

    Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

    Rotate object about specified origin and direction (9)

    Select a Web Site

    Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

    You can also select a web site from the following list:

    Americas

    • América Latina (Español)
    • Canada (English)
    • United States (English)

    Europe

    • Belgium (English)
    • Denmark (English)
    • Deutschland (Deutsch)
    • España (Español)
    • Finland (English)
    • France (Français)
    • Ireland (English)
    • Italia (Italiano)
    • Luxembourg (English)
    • Netherlands (English)
    • Norway (English)
    • Österreich (Deutsch)
    • Portugal (English)
    • Sweden (English)
    • Switzerland
      • Deutsch
      • English
      • Français
    • United Kingdom (English)

    Asia Pacific

    Contact your local office

    Rotate object about specified origin and direction (2024)
    Top Articles
    Latest Posts
    Article information

    Author: Mr. See Jast

    Last Updated:

    Views: 6052

    Rating: 4.4 / 5 (75 voted)

    Reviews: 82% of readers found this page helpful

    Author information

    Name: Mr. See Jast

    Birthday: 1999-07-30

    Address: 8409 Megan Mountain, New Mathew, MT 44997-8193

    Phone: +5023589614038

    Job: Chief Executive

    Hobby: Leather crafting, Flag Football, Candle making, Flying, Poi, Gunsmithing, Swimming

    Introduction: My name is Mr. See Jast, I am a open, jolly, gorgeous, courageous, inexpensive, friendly, homely person who loves writing and wants to share my knowledge and understanding with you.