|
|
(26 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
− | The SQuaternion struct contains a simple 4D vector of X, Y, Z and W floats designed to represent rotations with orientation.
| + | This page has moved to: https://docs.sine.space/v/scripting/client-scripting/types/squaternion |
− | | + | |
− | ==Fields==
| + | |
− | {{ScriptFunction|float|X|{ get; set; }|X axis|5=
| + | |
− | local obj = Space.Host.ExecutingObject;<br>
| + | |
− | local originalRot = obj.LocalRotation;<br>
| + | |
− | obj.SubscribeToEvents();<br><br>
| + | |
− | local onStartMethod = function()<br>
| + | |
− | Space.Log(originalRot.'''x''');<br>
| + | |
− | ''-- prints the X component of this object as a float''<br><br>
| + | |
− | originalRot.'''x''' = 0.25;<br>
| + | |
− | ''-- assigns 0.25 value to the X component''<br><br>
| + | |
− | obj.LocalRotation = originalRot;<br>
| + | |
− | ''-- sets the the new rotation''<br>
| + | |
− | end<br><br>
| + | |
− | obj.OnStart(onStartMethod);}}
| + | |
− | | + | |
− | {{ScriptFunction|float|Y|{ get; set; }|Y axis|5=
| + | |
− | local obj = Space.Host.ExecutingObject;<br>
| + | |
− | local originalRot = obj.LocalRotation;<br>
| + | |
− | obj.SubscribeToEvents();<br><br>
| + | |
− | local onStartMethod = function()<br>
| + | |
− | Space.Log(originalRot.'''y''');<br>
| + | |
− | ''-- prints the Y component of this object as a float''<br><br>
| + | |
− | originalRot.'''y''' = 0.25;<br>
| + | |
− | ''-- assigns 0.25 value to the Y component''<br><br>
| + | |
− | obj.LocalRotation = originalRot;<br>
| + | |
− | ''-- sets the the new rotation''<br>
| + | |
− | end<br><br>
| + | |
− | obj.OnStart(onStartMethod);}}
| + | |
− | | + | |
− | {{ScriptFunction|float|Z|{ get; set; }|Z axis|5=
| + | |
− | local obj = Space.Host.ExecutingObject;<br>
| + | |
− | local originalRot = obj.LocalRotation;<br>
| + | |
− | obj.SubscribeToEvents();<br><br>
| + | |
− | local onStartMethod = function()<br>
| + | |
− | Space.Log(originalRot.'''z''');<br>
| + | |
− | ''-- prints the Z component of this object as a float''<br><br>
| + | |
− | originalRot.'''z''' = 0.25;<br>
| + | |
− | ''-- assigns 0.25 value to the Z component''<br><br>
| + | |
− | obj.LocalRotation = originalRot;<br>
| + | |
− | ''-- sets the the new rotation''<br>
| + | |
− | end<br><br>
| + | |
− | obj.OnStart(onStartMethod);}}
| + | |
− | | + | |
− | {{ScriptFunction|float|W|{ get; set; }|W axis|5=
| + | |
− | local obj = Space.Host.ExecutingObject;<br>
| + | |
− | local originalRot = obj.LocalRotation;<br>
| + | |
− | obj.SubscribeToEvents();<br><br>
| + | |
− | local onStartMethod = function()<br>
| + | |
− | Space.Log(originalRot.'''w''');<br>
| + | |
− | ''-- prints the W component of this object as a float''<br><br>
| + | |
− | originalRot.'''w''' = 0.25;<br>
| + | |
− | ''-- assigns 0.25 value to the W component''<br><br>
| + | |
− | obj.LocalRotation = originalRot;<br>
| + | |
− | ''-- sets the the new rotation''<br>
| + | |
− | end<br><br>
| + | |
− | obj.OnStart(onStartMethod);}}
| + | |
− | | + | |
− | ==Constructors==
| + | |
− | {{ScriptFunction|SQuaternion|__new|(float x, float y, float z, float w)|Initialises quaternion from four floats|5=
| + | |
− | local q = '''Quaternion.New'''(0.0, 0.707, 0.0, 0.707);<br>
| + | |
− | ''-- creates a new quaternion with value [0.0, 0.707, 0.0, 0.707]''<br>
| + | |
− | ''-- which is [0, 90.0, 0.0] Euler angles''}}
| + | |
− | | + | |
− | {{ScriptFunction|SQuaternion|__new|(float x, float y, float z)|Creates a quaternion from 3 Euler floats (i.e. 3x 0-360' angles)}}
| + | |
− | {{ScriptFunction|SQuaternion|__new|(SVector angle, float axis)|Creates a quaternion from a Angle / Axis pair}}
| + | |
− | {{ScriptFunction|SQuaternion|__new|(SVector forward)|Creates a quaternion a forward vector; presuming up is (0,1,0)}}
| + | |
− | {{ScriptFunction|SQuaternion|__new|(SVector forward, SVector up)|Creates a quaternion a forward and up vector pair}}
| + | |
− | | + | |
− | ==Members==
| + | |
− | Note: Add/Scale/Divide are also implemented as operators (e.g. A + B, A += B)
| + | |
− | | + | |
− | {{ScriptFunction|SVector|EulerAngles|{ get; }|Returns the Euler rotation for this Quaternion}}
| + | |
− | {{ScriptFunction|SVector|OVERLOAD|*(SQuaternion, SVector)|Rotates a vector by a quaternion}}
| + | |
− | {{ScriptFunction|SQuaternion|OVERLOAD|*(SQuaternion, SQuaternion)|Rotates a quaternion by a quaternion}}
| + | |
− | {{ScriptFunction|float|Angle|(SQuaternion other);|Returns the angle between two quaternions}}
| + | |
− | {{ScriptFunction|SQuaternion|Lerp|(SQuaternion other, float t);|Linearly interpolates between this and other quaternion, by factor t and returns the result}}
| + | |
− | {{ScriptFunction|SQuaternion|Slerp|(SQuaternion other, float t);|Spherically interpolates between this and other quaternion, by factor t and returns the result}}
| + | |
− | {{ScriptFunction|SQuaternion|RotateTowards|(SQuaternion other, float t);|Rotates this towards other, by no more than t degrees}}
| + | |
− | {{ScriptFunction|float|Dot|(SQuaternion other);|Returns the dot product of this and another quaternion}}
| + | |
− | {{ScriptFunction|SQuaternion|Inverse|{ get; }|Returns the inverse of this quaternion}}
| + | |
− | | + | |
− | ==Static Members==
| + | |
− | {{ScriptFunction|SQuaternion|Identity|{ get; }|Equivalent of new SQuaternion(0,0,0,1)}}
| + | |
− | | + | |
− | {{Scripting Navbox}}
| + | |