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.

function MatrixToEuler(in_matrix)
	-- https://www.geometrictools.com/Documentation/EulerAngles.pdf
	local r00 = in_matrix[1]
	local r01 = in_matrix[2]
	local r02 = in_matrix[3]
	local r10 = in_matrix[4]
	local r11 = in_matrix[5]
	local r12 = in_matrix[6]
	local r20 = in_matrix[7]
	local r21 = in_matrix[8]
	local r22 = in_matrix[9]
	local thetaY = 0
	local thetaX = 0
	local thetaZ = 0
	if (r02 < 1) then
		if (r02 > -1) then
			thetaY = asin(r02)
			thetaX = atan2(-r12, r22)
			thetaZ = atan2(-r01, r00)
		else -- r02 = -1
			-- Not a unique solution: thetaZ − thetaX = atan2(r10, r11)
			thetaY = -90
			thetaX = -atan2(r10, r11)
			thetaZ = 0
		end
	else -- r02 = 1
		-- Not a unique solution: thetaZ + thetaX = atan2(r10, r11)
		thetaY = 90
		thetaX = atan2(r10, r11)
		thetaZ = 0
	end
	thetaX = thetaX * -1
	thetaY = thetaY * -1
	thetaZ = thetaZ * -1
	thetaX = mod(thetaX, 360)
	thetaY = mod(thetaY, 360)
	thetaZ = mod(thetaZ, 360)
	if (thetaX < 0) then
		thetaX = thetaX + 360
	end
	if (thetaY < 0) then
		thetaY = thetaY + 360
	end
	if (thetaZ < 0) then
		thetaZ = thetaZ + 360
	end
	return {thetaX, thetaY, thetaZ}
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.