Author Topic: Calculating distance between 2 background nebs  (Read 1370 times)

0 Members and 1 Guest are viewing this topic.

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Calculating distance between 2 background nebs
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.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Calculating distance between 2 background nebs
not sure exactly but you might be able to use the dot product between them to figre the angle
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Galemp

  • Actual father of Samus
  • 212
  • Ask me about GORT!
    • Steam
    • User page on the FreeSpace Wiki
Calculating distance between 2 background nebs
Hmm... I don't suppose you've tried Kazan's FS2 MBU?
"Anyone can do any amount of work, provided it isn't the work he's supposed to be doing at that moment." -- Robert Benchley

Members I've personally met: RedStreblo, Goober5000, Sandwich, Splinter, Su-tehp, Hippo, CP5670, Terran Emperor, Karajorma, Dekker, McCall, Admiral Wolf, mxlm, RedSniper, Stealth, Black Wolf...

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Calculating distance between 2 background nebs
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.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

  

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Calculating distance between 2 background nebs
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.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.