# llGetRot

*LSL function*

```lsl
rotation rotation llGetRot();
```

- Returns: `rotation`
- Energy: 10

Returns a rotation representing the prim's orientation relative to the region's axes.

Returns a [rotation](https://wiki.secondlife.com/wiki/rotation) that is the prim's rotation relative to the [region](https://wiki.secondlife.com/wiki/Viewer_coordinate_frames#region)'s axes.

```lsl title="How to use" frame="terminal"
rotation result = llGetRot();
```

## Caveats

- [llGetRot](/functions/llGetRot/) incorrectly reports the avatars rotation when called from the root of an attached object, use [llGetLocalRot](/functions/llGetLocalRot/) for root prims, instead
- [llGetRot](/functions/llGetRot/) will return an accurate facing for Avatars seated or in mouselook, but only a rough direction otherwise when called from an attached prim.
- When called in an attachment's child prim, the reported rotation will only be visually correct if the object's root is attached to [ATTACH_AVATAR_CENTER](/constants/ATTACH_AVATAR_CENTER/), at [ZERO_ROTATION](/constants/ZERO_ROTATION/). Moving the attachment's root or changing the attachment point will not affect the reported rotation. Avatar animation is invisible to the simulator, so it also does not affect the reported rotation. Also see [Single or Root Prims vs Linked Prims vs Attachments](https://wiki.secondlife.com/wiki/Rotation#single-or-root-prims-vs-linked-prims-vs-attachments).

## Examples

<details open>
<summary>Example 1</summary>

```lsl collapse={1-10}
 //-- rotates an object to face the nearest cardinal direction (N,E,S,W)
 //-- assumes build is aligned to root object facing

default{
  state_entry()
  {
    llSay( 0, "Rotate me in edit, then touch to make me face the nearest compass point" );
  }

  touch_start( integer vIntTouches )
  {
     //-- convert our rotation to x/y/z radians
    vector vRadBase = llRot2Euler( llGetRot() );
     //-- round the z-axis to the nearest 90deg (PI_BY_TWO = 90deg in radians)
    llSetRot( llEuler2Rot( <0.0, 0.0, llRound( vRadBase.z / PI_BY_TWO ) * PI_BY_TWO > ) );
  }
}
```

</details>

## See also

### Functions

- [llGetLocalRot](/functions/llGetLocalRot/)
- [llGetRootRotation](/functions/llGetRootRotation/)
- [llGetPrimitiveParams](/functions/llGetPrimitiveParams/)
- [llSetRot](/functions/llSetRot/)
- [llSetLocalRot](/functions/llSetLocalRot/)
- [llSetLinkPrimitiveParamsFast](/functions/llSetLinkPrimitiveParamsFast/)

---

*Source: [LlGetRot](https://wiki.secondlife.com/wiki/LlGetRot) on the Second Life Wiki. Content from the Second Life Wiki article LlGetRot (revision 1196827, 2015-07-01), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llGetRot/
