Question What's wrong in this positioning

vchamp

Member
Joined
Mar 24, 2008
Messages
221
Reaction score
6
Points
18
Please help me in understanding why is this happening. The angle between objects A, B and C ,which have x and y coordinates as in the screenshot, is 90º. But in Orbiter this angle is clearly bigger. Why?

posAngle1.gif


posAngle2.gif
 
Are those surface base objects or vessels placed by a module? And if it's from a module, then how are their coordinates calculated?
 
Those are vessels (CargoBarrelFuel). In the background is a square as a surface base object.

Coordinates are calculated this way:
Code:
double radSlotLength = slotLengthMeters / cBodyRadius; // slot length in radians
double radSlotWidth = slotWidthMeters / cBodyRadius; // slot width in radians
VECTOR3 rotateAxis = {0, 0, -1};

for (int i = 0; i < toExpose; i++) {

	VESSELSTATUS2 vs;
	memset (&vs, 0, sizeof(vs));
	vs.version = 2;
	vs.status = 1; // landed
	vs.rbody = _cBody;

	// find place
	bool found = false;
	for (UINT x = 0; x < 10; x++) {
		for (UINT y = 0; y < 10; y++) {
			VECTOR3 rpos; // relative position
			rpos.x = x * radSlotWidth;
			rpos.y = -(y * radSlotLength);
			rpos.z = 0.0;
			RotateVector(rpos, rotateAxis, exposition.hdg * RAD);
			VECTOR3 pos;
			pos.x = exposition.lng * RAD; // exposition.lng - longitude of the first object in degrees
			pos.y = exposition.lat * RAD;
			pos.z = cBodyRadius;
			pos += rpos;

			// check if occupied
			
			if (!occupied) {
				vs.surf_lng = pos.x;
				vs.surf_lat = pos.y;
				reservedPositions.push_back(pos);
				found = true;
			}
			if (found) break;
		}
		if (found) break;
	}

	if (found) {
		// create the vessel
	}
}

First I calculate relative position in the local coordinates, then rotate it around z axis.
 
Your rotation is the error, you use Z axis, but also treat the coordinates as relative coordinates, in which Z is pointing into the ecliptic plane.
 
Maybe you are right and I should have used another method of coordinates calculation, but in this code rotation is correct, I think.

I was wrong assuming that longitude degree arc length is the same at each latitude. Adding rpos.x /= cos(exposition.lat * RAD); solved the issue.
 
This works great for me for setting latitude and longitude of a landed vessel relative to another (base) longitude and latitude (R is radius of the planet):
Code:
double d = sqrt (x * x + z * z);
double sindR_d = sin (d / R) / d;
double cosdR = cos (d / R);
double sinlat = sin (base_lat);
double coslat = cos (base_lat);
double lat = asin (sinlat * cosdR - x * coslat * sindR_d);
double lng = base_lng + atan2 (z * sindR_d * coslat, cosdR - sinlat * sin (lat));
 
Back
Top