Advanced Question Inertia of combined vessels

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
Hi all,

this is a question probably mostly for Martin but a lot of people here sure can give their point on this.

I know from here: https://www.orbiter-forum.com/showthread.php?t=38762 how Orbiter computes the PMI for a superstructure made of multiple docked vessels.
I think I understand the procedure quite well, so that's quite clear.

Now, since I am in the middle of development of a similar thing I was wondering if I can use this other method (which seems much simpler to me). Since I know the original PMI of each vessel, I (think) can simply use the Huygens-Steiner theorem and calculate the value of each PMI relative to the combined COG. Once I have all of them there I can simply add them up.
So the procedure would be:
1) find the COG of the combined vesse structure
2) for each vessel "translate" the PMI relevant to the new combined COG by making for example Ix = Ix0 + y^2 + z^2 where Ix0 is the x component of the original PMI of the vessel.
3) once I have all the Ix, the Iy and the Iz add them up.

is it something reasonable or is it crazyness?

Thanks in advance
:cheers:
Fred

PS: I made a test with the integration of shipedit and the result from the integration is almost identical to what I calculated with the above method
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
Since I know the original PMI of each vessel, I (think) can simply use the Huygens-Steiner theorem and calculate the value of each PMI relative to the combined COG. Once I have all of them there I can simply add them up.

I think the extra step of modeling the point masses is due to the potential rotational difference between the docked vessels.
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
If the results are correct, it's hard to argue against it :lol:. It may well be that your solution is more correct and/or elegant than mine. But echoing what Face said, in case you are not doing so already, you need to make sure you rotate the inertia tensors of the component vessels to the correct orientation before translating them to their supervessel-relative position.

Also obviously you need to multiply the Orbiter-supplied mass-normalised PMI tensors with the vessel mass before adding them up (and then divide the result by the supervessel mass if you want to convert it back to the mass-normalised PMI Orbiter convention.)
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
Also obviously you need to multiply the Orbiter-supplied mass-normalised PMI tensors with the vessel mass before adding them up (and then divide the result by the supervessel mass if you want to convert it back to the mass-normalised PMI Orbiter convention.)

Yep, relevant to this I am doing it and it seems to work quite well. I oversimplified in the equation mentioned but the mass ratio is fundamental.

But echoing what Face said, in case you are not doing so already, you need to make sure you rotate the inertia tensors of the component vessels to the correct orientation before translating them to their supervessel-relative position.

I have been trying for the time being with aligned vessels (stages) but this is absolutely necessary to do to have a universal system. I am thinking on how to do this :hmm: should I multiply the inertia tensor by the rotation matrix defined by the relative rotation of the vessel against the reference vessel? If so, can I get the rotation matrix of both vessels and then find the relative rotation matrix by making operations among them? It's been a while since I studied matrixes at university, I need to have a refresh on how to make operations bigger than simple multiplications...
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
should I multiply the inertia tensor by the rotation matrix defined by the relative rotation of the vessel against the reference vessel? If so, can I get the rotation matrix of both vessels and then find the relative rotation matrix by making operations among them? It's been a while since I studied matrixes at university, I need to have a refresh on how to make operations bigger than simple multiplications...

You could construct the relative rotation matrix given the orientations of the involved docking ports. Or, if it is enough to do the calculation after the supervessel has been assembled, you can get the relative rotation from the world rotation matrices of the two vessels: R_rel = R_1^T R_2. Of course the absolute rotation depends on how the orientation of the supervessel is defined.

Also remember that the inertia tensor is a tensor (hence the name :lol:) not a matrix. To rotate it, you need to apply the rotation matrix from the left and the right. See for example Eq. 15 and following here: https://ocw.mit.edu/courses/aeronautics-and-astronautics/16-07-dynamics-fall-2009/lecture-notes/MIT16_07F09_Lec26.pdf
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
So, thanks to martins' suggestions :)hailprobe:)I made this working and it seems to me it's working fine. So for future reference of anyone interested I post here the code.

Before the code some preliminar input:
- The sistem is a connection system between vessels which works with an hierarchy like attachments but with proper physics and status computations
- Each link has a master-child structure. A master can have infinite children, a child can have just one master.
- Each supervessel using links in the sym is called SuperStructure, and all the OBJHANDLEs of each SuperStructure are stored in a 2d vector where the position [0][0] is the master of all the other masters, so the reference vehicle.
- Just for explanation the 2d vector is structured in layers (rows of the vector) and each row contains the masters of the next row and so on.
- Forces are computed for each vessels and transferred to the relevant master starting from last child getting back to the master of masters. The process goes row by row so no force can get lost during transfer.
- PMI is computed so Torque can be stored and then the calculation of rotational acceleration of the SuperVessel can be performed and then applied to the overall master.

This process up here is giving me quite the smile since it works quite well up to now...

So in order to compute PMI of the SuperStructure here's my code:
Code:
VECTOR3 LinkManager::GetSuperStructurePMI(vector< vector <OBJHANDLE> > SuperStruct) { 
	VECTOR3 PMI = _V(0, 0, 0);
	VECTOR3 COG = GetSuperStructureCOG(SuperStruct); //SuperStructure COG in local coordinates relative to the master vessel

	for (UINT i = 0; i < SuperStruct.size(); i++) {
		for (UINT j = 0; j < SuperStruct[i].size(); j++) {
			if (oapiIsVessel(SuperStruct[i][j])) { //just to be sure...
				VESSEL* v;
				v = oapiGetVesselInterface(SuperStruct[i][j]);			//Participating Vessel Item Interface
				VESSEL *vmaster;
				vmaster = oapiGetVesselInterface(SuperStruct[0][0]);	//Master Vessel Interface

				VECTOR3 g_rpos = _V(0, 0, 0);
				VECTOR3 l_rpos = _V(0, 0, 0);
				v->GetGlobalPos(g_rpos);								//Global pos of the participating Vessel
				vmaster->Global2Local(g_rpos, l_rpos);					//Coordinates of the participating vessel relative to the master

				VECTOR3 r_cog_pos = l_rpos - COG;						//Cooordinates of the Participating Vessel relative to the superstructure COG
				VECTOR3 PMI_0;
				v->GetPMI(PMI_0);										//Initial PMIs of the participating vessel

				MATRIX3 rot_rel,rot_v,rot_master;
				vmaster->GetRotationMatrix(rot_master);					//Rotation Matrix of the master vessel
				v->GetRotationMatrix(rot_v);							//Rotation Matrix of the participating vessel
				rot_rel = mul(Transpose(rot_v), rot_master);			//Relative Rotation Matrix

				//Creating The Inertia Tensor of the participating vessel to be rotated
				MATRIX3 Tensor0;
				Tensor0.m11 = PMI_0.x;
				Tensor0.m22 = PMI_0.y;
				Tensor0.m33 = PMI_0.z;
				Tensor0.m12 = 0;
				Tensor0.m13 = 0;
				Tensor0.m21 = 0;
				Tensor0.m23 = 0;
				Tensor0.m31 = 0;
				Tensor0.m32 = 0;

				MATRIX3 Tensor_Rotated = mul(rot_rel, mul(Tensor0, Transpose(rot_rel))); //Rotation of the Inertia Tensor of the participating vessel rot_rel * Tensor0 * rot_rel^T

				VECTOR3 PMI_0r = _V(Tensor_Rotated.m11, Tensor_Rotated.m22, Tensor_Rotated.m33); //Vector of PMI rotated of the participating vessel

				//Each componente of the PMI of the SuperStructure gets summed and multiplied by the participating vessel mass

					PMI.x += (PMI_0r.x + r_cog_pos.y*r_cog_pos.y + r_cog_pos.z*r_cog_pos.z)*v->GetMass();
					PMI.y += (PMI_0r.y + r_cog_pos.x*r_cog_pos.x + r_cog_pos.z*r_cog_pos.z)*v->GetMass();
					PMI.z += (PMI_0r.z + r_cog_pos.x*r_cog_pos.x + r_cog_pos.y*r_cog_pos.y)*v->GetMass();
				
				

				

			}
		}
	}
	PMI /= GetSuperstructureMass(SuperStruct); // Dividing by the total superstructure Mass to have the proper mass normalised PMI vector

	if (length(PMI) == 0) { PMI = _V(1, 1, 1); } // if anything goes wrong, don't give me 0 PMI or my SuperVessel will rotate like crazy...
	
	

	return PMI;
}

I hope it can be useful to someone.

Cheers guys
:cheers:

Fred
 
Top