API Panel.Position.RotateTo

From Flowcode Help
Jump to navigationJump to search
Fc9-comp-macro.png RotateTo
Rotates the object to the given rotation 
Fc9-h32-icon.png - HANDLE Handle
The position or component to update 
Fc9-h32-icon.png - HANDLE Pivot
The coordinates of the rotation center, Handle if zero 
Fc9-h32-icon.png - HANDLE Axis
An axis to align the angles to, Handle if zero 
Fc9-f32-icon.png - FLOAT X_Pitch
The absolute local X degrees to update with 
Fc9-f32-icon.png - FLOAT Y_Yaw
The absolute local Y degrees to update with 
Fc9-f32-icon.png - FLOAT Z_Roll
The absolute local Z degrees to update with 
Fc9-void-icon.png - NONE Return


Detailed description

This rotates an object to the exact orientation specified. The orientation is represented as Euler angles. This is typically useful for setting to an exact angle, but is not recommended for incremental changes - Euler angles suffer from gimbal lock and it can be difficult to maintain an absolute values through incremental changes.


For an incremental change, use RotateAlong.


If Pivot or Axis are zero, that parameter is ignored. This is in contrast with most Position calls that treat zero as world-space. It is advised not to use world-space in a component that is exported, use this as the coordinate space instead.


Note that a common mistake is to set the orientation to (0, 0, 0) to reset the Handle back to its original position. Where as this will work for objects that are originally aligned to the specified axis, this will not work for objects whose initial position is off axis. To reliably restore the orientation of an object, the original position should be read and stored with a call to Get and the orientation restored using SetRotation.


Note another common mistake is to set the angle relative to the object being rotated. Specifying the same Axis as Handle will cause the object to be rotated relative to itself, which may have unexpected results.


Examples

Calling in a calculation

  • Add to a calculation icon:
    ::Panel.Position.RotateTo(handle, pivot, axis, x_pitch, y_yaw, z_roll)