wiki.sine.space | sinespace

Difference between revisions of "Scripting/SQuaternion"

From wiki.sine.space
Jump to: navigation, search
(Created page with "The SQuaternion struct contains a simple 4D vector of X, Y, Z and W floats designed to represent rotations with orientation. ==Fields== {{ScriptFunction|float|X|{ get; set; }...")
 
Line 2: Line 2:
  
 
==Fields==
 
==Fields==
{{ScriptFunction|float|X|{ get; set; }|X axis}}
+
{{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>
 +
&nbsp;&nbsp;Space.Log(originalRot.'''x''');<br>
 +
&nbsp;&nbsp;''-- prints the X rotation of this object as a float''<br><br>
 +
&nbsp;&nbsp;originalRot.'''x''' = 0.25;<br>
 +
&nbsp;&nbsp;''-- assigns 0.25 value to the X rotation''<br><br>
 +
&nbsp;&nbsp;obj.LocalRotation = originalRot;<br>
 +
&nbsp;&nbsp;''-- sets the the new rotation''<br>
 +
end<br><br>
 +
obj.OnStart(onStartMethod);}}
 +
 
 
{{ScriptFunction|float|Y|{ get; set; }|Y axis}}
 
{{ScriptFunction|float|Y|{ get; set; }|Y axis}}
 
{{ScriptFunction|float|Z|{ get; set; }|Z axis}}
 
{{ScriptFunction|float|Z|{ get; set; }|Z axis}}

Revision as of 06:00, 24 April 2017

The SQuaternion struct contains a simple 4D vector of X, Y, Z and W floats designed to represent rotations with orientation.

Fields

X

float X { get; set; }

X axis

local obj = Space.Host.ExecutingObject;

local originalRot = obj.LocalRotation;
obj.SubscribeToEvents();

local onStartMethod = function()
  Space.Log(originalRot.x);
  -- prints the X rotation of this object as a float

  originalRot.x = 0.25;
  -- assigns 0.25 value to the X rotation

  obj.LocalRotation = originalRot;
  -- sets the the new rotation
end

obj.OnStart(onStartMethod);


Y

float Y { get; set; }

Y axis

No example provided yet


Z

float Z { get; set; }

Z axis

No example provided yet


W

float W { get; set; }

W axis

No example provided yet


Constructors

__new

SQuaternion __new (float x, float y, float z, float w)

Initialises quaternion from four floats

No example provided yet


__new

SQuaternion __new (float x, float y, float z)

Creates a quaternion from 3 Euler floats (i.e. 3x 0-360' angles)

No example provided yet


__new

SQuaternion __new (SVector angle, float axis)

Creates a quaternion from a Angle / Axis pair

No example provided yet


__new

SQuaternion __new (SVector forward)

Creates a quaternion a forward vector; presuming up is (0,1,0)

No example provided yet


__new

SQuaternion __new (SVector forward, SVector up)

Creates a quaternion a forward and up vector pair

No example provided yet


Members

Note: Add/Scale/Divide are also implemented as operators (e.g. A + B, A += B)

EulerAngles

SVector EulerAngles { get; }

Returns the Euler rotation for this Quaternion

No example provided yet


OVERLOAD

SVector OVERLOAD *(SQuaternion, SVector)

Rotates a vector by a quaternion

No example provided yet


OVERLOAD

SQuaternion OVERLOAD *(SQuaternion, SQuaternion)

Rotates a quaternion by a quaternion

No example provided yet


Angle

float Angle (SQuaternion other);

Returns the angle between two quaternions

No example provided yet


Lerp

SQuaternion Lerp (SQuaternion other, float t);

Linearly interpolates between this and other quaternion, by factor t and returns the result

No example provided yet


Slerp

SQuaternion Slerp (SQuaternion other, float t);

Spherically interpolates between this and other quaternion, by factor t and returns the result

No example provided yet


RotateTowards

SQuaternion RotateTowards (SQuaternion other, float t);

Rotates this towards other, by no more than t degrees

No example provided yet


Dot

float Dot (SQuaternion other);

Returns the dot product of this and another quaternion

No example provided yet


Inverse

SQuaternion Inverse { get; }

Returns the inverse of this quaternion

No example provided yet


Static Members

Identity

SQuaternion Identity { get; }

Equivalent of new SQuaternion(0,0,0,1)

No example provided yet