[SOLVED][SCRIPTING] Matrix3_GetVector3FromCol


#1

I’m curious as to what the Matrix3_GetVector3FromCol function does. It takes a 9 item rotation matrix generated using SobGroup_GetCoordSys as input, followed by a number (integer?). It outputs a 3 item table. It’s only used once in Homeworld2.big, and the number (integer?) supplied in that instance is 2.

I’ve been comparing the output to a function I wrote myself called MatrixToEuler that I use to convert the 9 item rotation matrix to Euler rotation angles (degrees).

---------------- 0
test1 = {188.8147808906225, 270.371150272706, 171.1851246310184, } 
test2 = {-0.006411552429199219, 4.878733307123184e-006, -0.9999794960021973, } 
test1 = {173.1985523604548, 270.2960752906031, 186.8015422346737, } 
test2 = {-0.005144715309143066, -3.241788363084197e-006, -0.9999868869781494, } 
test1 = {179.427260373988, 78.31424545820225, 179.4832783557769, } 
test2 = {-0.2025351524353027, -0.0007705204770900309, 0.9792746305465698, } 
test1 = {188.8346554121517, 270.3722031845286, 171.1651943826657, } 
test2 = {-0.006417155265808106, 5.88136026635766e-006, -0.9999793767929077, } 
test1 = {180.4450021887515, 275.7783503179156, 179.497589778118, } 
test2 = {-0.1006773710250855, 0.001041422481648624, -0.994918704032898, } 
test1 = {180.4952922548052, 275.3133794663897, 179.4489174624701, } 
test2 = {-0.09259819984436035, 0.001010864973068237, -0.9957029819488525, } 
test1 = {186.9877122039639, 270.4805128025469, 173.1202109150914, } 
test2 = {-0.008342266082763672, -0.00187945319339633, -0.9999635219573975, } 
test1 = {180.2054416826993, 275.9009309577368, 179.7411342783645, } 
test2 = {-0.102807879447937, 0.0009514261037111282, -0.9947007894515991, } 


---------------- 1
test1 = {173.1994064271589, 270.2954136605744, 186.8006706415247, } 
test2 = {-0.0006105884676799178, 0.9999998211860657, 1.958978828042746e-007, } 
test1 = {180.4490215252623, 275.7783159966638, 179.4975898289904, } 
test2 = {0.0008828198770061135, 0.9999992251396179, 0.0008872496546246111, } 
test1 = {180.4952900245038, 275.3133794663897, 179.4489172424623, } 
test2 = {0.0008906642906367779, 0.9999991655349731, 0.0009324386483058333, } 
test1 = {186.4535774251502, 270.4788811305646, 173.5971174804992, } 
test2 = {0.0009328959276899695, 0.9999991655349731, -0.0008885897696018219, } 
test1 = {180.2054426081985, 275.900864438688, 179.7411281065259, } 
test2 = {0.0004645047010853887, 0.999999463558197, 0.0009085778729058802, } 
test1 = {184.9421435833924, 270.3679734482871, 175.057785022165, } 
test2 = {0.0005532993236556649, 0.9999998211860657, -5.147885531187058e-007, } 
test1 = {187.9226324563023, 270.3700943460584, 172.0772756880646, } 
test2 = {0.0008922186680138111, 0.9999995827674866, -1.225474989041686e-006, } 
test1 = {355.5374739138589, 88.68582201047637, 355.6028652603704, } 
test2 = {-0.001758527127094567, 0.9999977946281433, 0.00116139161400497, } 


---------------- 2
test1 = {184.9421002581398, 270.3679734482871, 175.0578275440619, } 
test2 = {0.9999793767929077, -0.0005550594069063664, -0.006419062614440918, } 
test1 = {180.449024801232, 275.7783159966638, 179.497588998159, } 
test2 = {0.9949188828468323, -0.0007890170672908425, -0.1006768941879273, } 
test1 = {180.4952900245038, 275.3133794663897, 179.4489172424623, } 
test2 = {0.9957031011581421, -0.0008004941046237946, -0.09259986877441406, } 
test1 = {186.4538292962583, 270.4792895688102, 173.5968603682616, } 
test2 = {0.9999650120735169, -0.0009417437249794602, -0.00832521915435791, } 
test1 = {180.2054423902984, 275.9008974859, 179.7411284071162, } 
test2 = {0.9947012066841126, -0.0003686363925226033, -0.1028084754943848, } 
test1 = {188.2200769231642, 270.371150272706, 171.7798245782523, } 
test2 = {0.9999790191650391, -0.0009247140260413289, -0.006401181221008301, } 
test1 = {173.1990579248786, 270.2954136605744, 186.8010324287363, } 
test2 = {0.9999867081642151, 0.0006119778845459223, -0.00513148307800293, } 
test1 = {178.4181829147256, 88.25773861595509, 178.4641951958206, } 
test2 = {-0.9995377063751221, 0.000839274434838444, -0.03039205074310303, } 

“test1” is the output of my own custom function. “test2” is the output of Matrix3_GetVector3FromCol. Each block corresponds to a different number supplied as the second parameter to Matrix3_GetVector3FromCol. I tried 0, 1 and 2.

I’ve been looking at the output and don’t see a correlation. I still can’t see what the function does.

[edit]

Maybe the numbers represent unit vectors pointing in the direction the ships are facing? But what is the integer for?


#2

Are there any ways to rotate a ship in the gametype scope? Up until now, I have been spawning ships at one point, and then hyperspacing to another point along the same vector. Are there ways to move ships instantaneously without hyperspace?

[edit]

Never mind. SobGroup_Spawn works for this.


#3

I decided to test SobGroup_SetTransform using the following code.

function TestStuff_03()
	local in_sobgroup = "Player_Ships0"
	local ship_name_sub = "TESTSHIP_"
	local ship_count = SobGroup_Separate(ship_name_sub, in_sobgroup)
	for j = 1, ship_count do
		local ship_name = ship_name_sub .. (j-1)
		local in_coor = SobGroup_GetCoordSys(ship_name)
		for k = 1, getn(in_coor) do
			in_coor[k] = random()
		end
		SobGroup_SetTransform(ship_name, in_coor)
	end
end

It produces some pretty funky results. Not sure exactly what is going on yet though.


Homeworld Remastered Infection Beam Script
(Taiidan Republic Mod) #4

It looks like that script randomly rotates ships, so I would expect funky results :stuck_out_tongue:


#5

If you do

in_coor[k] = random() * 360

then the ships get really huge. So it is possible to scale a ship model physically larger/smaller using a script.


(ajlsunrise) #6

What is the value of getn for in_coor?


#7

The length of the table is 9.