FANDOM


SobGroup_GetCoordSys(<sSobGroupName>)
Description
Returns a table with 9 values representing a rotation matrix.
Use Matrix3_GetVector3FromCol to convert this matrix into a unit vector pointing in the direction the ship is heading.
Example
SobGroup_GetCoordSys("MothershipGroup")
Arguments
<sSobGroupName>: the name of the sobgroup.
Related Pages
Conversion

Here is some code to convert between the rotation matrix and the Euler angles used in other functions.

	-- Adapted from https://www.geometrictools.com/Documentation/EulerAngles.pdf, section 2.6
	function MatrixToEuler(in_matrix)
		local r00 = in_matrix[9]
		local r01 = in_matrix[8]
		local r02 = in_matrix[7]
		local r10 = in_matrix[6]
		local r11 = in_matrix[5]
		local r12 = in_matrix[4]
		local r20 = in_matrix[3]
		local r21 = in_matrix[2]
		local r22 = in_matrix[1]
		local angleX = 0
		local angleY = 0
		local angleZ = 0
		if (r20 < 1) then
			if (r20 > -1) then
				angleY = asin(-r20)
				angleZ = atan2(r10, r00)
				angleX = atan2(r21, r22)
			else
				angleY = 90
				angleZ = -atan2(-r12, r11)
				angleX = 0
			end
		else
			angleY = -90
			angleZ = atan2(-r12, r11)
			angleX = 0
		end
		if (angleY < 0) then
			angleY = angleY + 360
		end
		if (angleZ < 0) then
			angleZ = angleZ + 360
		end
		if (angleX < 0) then
			angleX = angleX + 360
		end
		return {angleZ, angleY, angleX}
	end

And to convert back again.

	-- Adapted from https://www.geometrictools.com/Documentation/EulerAngles.pdf, section 2.6
	function EulerToMatrix(in_euler)
		local angleX = in_euler[1]
		local angleY = in_euler[2]
		local angleZ = in_euler[3]
		local c1 = cos(angleX)
		local c2 = cos(angleY)
		local c3 = cos(angleZ)
		local s1 = sin(angleX)
		local s2 = sin(angleY)
		local s3 = sin(angleZ)
		local r00 =  c1 * c2
		local r01 =  c1 * s2 * s3 - c3 * s1
		local r02 =  s1 * s3 + c1 * c3 * s2
		local r10 =  c2 * s1
		local r11 =  c1 * c3 + s1 * s2 * s3
		local r12 =  c3 * s1 * s2 - c1 * s3
		local r20 = -s2
		local r21 =  c2 * s3
		local r22 =  c2 * c3
		return {r22,r21,r20,r12,r11,r10,r02,r01,r00}
	end

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.