I finally cracked the vertical L-Point code! Enjoy.
For the geog program:
void PlaceLpoint(Lpoint_T * data, float percentage)
{
Entity_T * moon;
Entity_T * planet;
double vecx, vecy, vecz, dist, x, y, z, angle;
moon = &geog_array[data->moon_index].entity;
planet = &geog_array[data->center_index].entity;
vecx = moon->x_pos - planet->x_pos;
vecy = moon->y_pos - planet->y_pos;
vecz = moon->z_pos - planet->z_pos;
dist = sqrt(vecx*vecx+vecy*vecy+vecz*vecz);
x = vecx/dist;
y = vecy/dist;
z = vecz/dist;
vecx = x*dist*percentage + planet->x_pos;
vecy = y*dist*percentage + planet->y_pos;
vecz = z*dist*percentage + planet->z_pos;
if ( z == -1 ) // To prevent divide by zero errors if a moon is straight north
{
data->orient1 = (float)0; // North
data->orient2 = (float)sqrt(1/2);
data->orient3 = (float)sqrt(1/2);
}
else
{
angle = acos(z)/2;
data->orient1 = (float)cos(angle);
data->orient2 = (float)(-y*cos(angle)/(z+1));
data->orient3 = (float)(x*cos(angle)/(z+1));
};
data->x_pos = vecx;
data->y_pos = vecy;
data->z_pos = vecz;
}
[center][url=”http://www.torn-stars.com/”][img]http://www.torn-stars.com/images/mdvalleysig.gif[/img][/url][/center]