API ReferenceGE Extensionsflowgraphnodesmathquaternion
Direction (Flowgraph Node)
- **Node Name:** `Direction`
Overview
- Node Name:
Direction - Category:
simple - File:
extensions/flowgraph/nodes/math/quaternion/direction.lua
Converts an angle in degrees into a quaternion representing rotation around the Z axis (clockwise).
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
deg | number | Input angle in degrees |
Output Pins
| Pin | Type | Description |
|---|---|---|
value | quat | Quaternion describing the Z-axis rotation |
Internals
| Field | Purpose |
|---|---|
self.oldIn | Cached last input to avoid redundant recalculation |
rot (local) | Reusable quat object for performance |
How It Works
- The node takes a degree value and converts it to radians:
(deg / 180) * π. - A quaternion is set from Euler angles
(0, 0, radians)- rotation around Z only. - The result is cached: the quaternion is only recalculated when the input changes.
- Output is the quaternion as a table via
rot:toTable().
Lua Example
-- Input: deg = 90
-- Output: quaternion representing 90° clockwise rotation around Z
-- Equivalent to: quat():setFromEuler(0, 0, math.pi/2)
-- Use case: Orient a vehicle or camera to face a compass direction
-- 0° = forward, 90° = right, 180° = backward, 270° = leftKey Dependencies
quat/setFromEuler- quaternion math primitives_flowgraph_createNode()- standard flowgraph node registration
Additional Methods
C:init()
Initializes the node, setting up pins and default properties.
C:work()
Main work function called each frame/tick when the node is active.
See Also
- Look At (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide