Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: IPAndrews on June 10, 2003, 09:50:11 am

Title: Calculating distance between 2 background nebs
Post by: IPAndrews on June 10, 2003, 09:50:11 am
How do I calculate the distance in radians between two background nebulae given the FRED2 Pitch, Bearing, and Heading for each nebula in radians?

The purpose of this is to allow the random generation of background nebula positions whilst checking to see that 2 nebulae haven't been positioned too close together.
Title: Calculating distance between 2 background nebs
Post by: Bobboau on June 10, 2003, 12:04:21 pm
not sure exactly but you might be able to use the dot product between them to figre the angle
Title: Calculating distance between 2 background nebs
Post by: Galemp on June 11, 2003, 06:22:23 pm
Hmm... I don't suppose you've tried Kazan's FS2 MBU?
Title: Calculating distance between 2 background nebs
Post by: IPAndrews on June 12, 2003, 03:10:45 am
Yes. It's better than nothing but unfortunately it has a tendancy to concentrate nebs in particular areas and pile them one on top of another. Which looks kinda funky.

Writing a program to generate random nebula placement is easy. All you're doing is generating osme text with a few random numbers. Checking to see if one neb is close to another is not as easy.

I believe FRED uses Euler angles to position the nebs. Where pitch = elivation and heading = azimuth. I think it's doing the elivation rotation 1st about the x axis and the azimuth rotation 2nd around the y axis.  Bearing does not seem to effect the positioning of a neb on the sky sphere. A way to do a distance check might possibly be to simulate a neb starting at (x=0, y=0, z=1), set up a rotation matrix to do the rotations, and apply it to the pretend neb. Thus generating a position in 3d space which could be compared against that of other nebs using the same technique.

Haven't got a clue how to do the math though as I plainly suck at 3d math.
Title: Calculating distance between 2 background nebs
Post by: IPAndrews on June 16, 2003, 09:21:02 am
Well for the record I've done this now. I have a program which can generate random neb positions whilst enforcing a minimum distance each neb must be from every other. If anyone wants the source code they can have it. It's just a couple of rotation matrices and a 3d distance function.