# llAxes2Rot

*LSL function*

```lsl
rotation rotation llAxes2Rot(vector fwd, vector left, vector up);
```

- `vector fwd`: Forward/back directional vector of the rotation.
- `vector left`: Left/right directional vector of the rotation.
- `vector up`: Up/down directional vector of the rotation.

- Returns: `rotation`
- Energy: 10

All three vectors must be mutually orthogonal unit vectors.

Returns a [rotation](https://wiki.secondlife.com/wiki/rotation) that is defined by the 3 coordinate axes

```lsl title="How to use" frame="terminal"
rotation result = llAxes2Rot(ZERO_VECTOR, ZERO_VECTOR, ZERO_VECTOR);
```

## Examples

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

```lsl
default
{
    state_entry()
    {
        vector i = < 1.0, 0.0, 0.0>;
        vector j = < 0.0, 1.0, 0.0>;
        vector k = < 0.0, 0.0, 1.0>;

        rotation rot = llAxes2Rot( j, -i, k );

        llSay(0, (string) (llRot2Euler(rot) * RAD_TO_DEG) );
    }
}
```

</details>

This script displays:

Object: `<-0.00000, 0.00000, 90.00000>`

which shows that (**j**, **-i**, **k**) is obtained by rotating (**i**, **j**, **k**) 90 degrees around z direction.

## Notes

Technically, only the first two vectors are needed to define this rotation, which can be done by calling any of these:

```lsl
llAxes2Rot(fwd, left, fwd % left);
llAxes2Rot(left % up, left, up);
llAxes2Rot(fwd, up % fwd, up);
```

## Tests

- [Visual illustration](https://wiki.secondlife.com/wiki/User:Dora_Gustafson/llAxes2Rot_right_and_wrong) — Importance of mutually orthogonal unit vectors

---

*Source: [LlAxes2Rot](https://wiki.secondlife.com/wiki/LlAxes2Rot) on the Second Life Wiki. Content from the Second Life Wiki article LlAxes2Rot (revision 1199673, 2016-03-07), CC BY-SA 3.0.*

---

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