• Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

We're also offering banner ads on our site from just \$5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

xDan

Member Since 04 Jun 2005
Offline Last Active Oct 23 2014 03:38 AM

In Topic: getting lat/long of a point on a double poled sphere

30 July 2013 - 09:32 AM

THANKS! That works perfectly. My original stuff was perhaps inspired by the math school of trial and error.

In Topic: getting lat/long of a point on a double poled sphere

29 July 2013 - 03:30 PM

What's an example of a point where using the two atan2s doesn't do what you want? I think that ought to work...

Here's some test code I'm using:

```		worldRadius = 10.0

for i in range(0,10):
# choose a random lat/long point on sphere
latitude = random.uniform(-2*pi, 2*pi) # up/down, y
longitude = random.uniform(-2*pi, 2*pi) # left/right, x

# Find the real world 3D position on the sphere surface
real_x = worldRadius * cos(latitude) * sin(longitude)
real_y = worldRadius * sin(latitude) * cos(longitude)
real_z = worldRadius * cos(latitude) * cos(longitude)

# Now attempt to do that backwards and get the lat/long again from this real world position.
latitudeAgain = atan2(real_y, real_z)
longitudeAgain = atan2(real_x, real_z)

# Put all lat/longs in the range 0 - 2*PI for easy comparison
latitude += 2*pi
longitude += 2*pi
latitudeAgain += 2*pi
longitudeAgain += 2*pi
latitude = fmod(latitude, 2*pi)
longitude = fmod(longitude, 2*pi)
latitudeAgain = fmod(latitudeAgain, 2*pi)
longitudeAgain = fmod(longitudeAgain, 2*pi)

# Also try to get the position once again from the newly got lat/long
other_x = worldRadius * cos(latitudeAgain) * sin(longitudeAgain)
other_y = worldRadius * sin(latitudeAgain) * cos(longitudeAgain)
other_z = worldRadius * cos(latitudeAgain) * cos(longitudeAgain)

print "Lats: ",latitude," - ",latitudeAgain," Diff: ",abs(latitude-latitudeAgain)
print "Lons: ",longitude," - ",longitudeAgain," Diff: ",abs(longitude-longitudeAgain)
print "Pos1: ",real_x,real_y,real_z
print "Pos2: ",other_x,other_y,other_z```

And the test output:

```Lats:  1.57903473033  -  1.57903473033  Diff:  0.0
Lons:  5.10226596478  -  1.96067331119  Diff:  3.14159265359
Pos1:  0.0762007311343 3.80061735995 -0.0313117278778
Pos2:  -0.0762007311343 -3.80061735995 0.0313117278778

Lats:  5.93480811564  -  2.79321546205  Diff:  3.14159265359
Lons:  3.39572137905  -  3.39572137905  Diff:  0.0
Pos1:  -2.36299962085 3.30408958826 -9.0973998891
Pos2:  2.36299962085 -3.30408958826 9.0973998891

Lats:  2.36983896676  -  5.51143162035  Diff:  3.14159265359
Lons:  3.43495760648  -  0.293364952892  Diff:  3.14159265359
Pos1:  2.07248505761 -6.67597897677 6.86069121889
Pos2:  2.07248505761 -6.67597897677 6.86069121889

Lats:  2.71182886148  -  2.71182886148  Diff:  4.4408920985e-16
Lons:  5.72284029962  -  2.58124764603  Diff:  3.14159265359
Pos1:  4.83148051356 3.52937619571 -7.70042639429
Pos2:  -4.83148051356 -3.52937619571 7.70042639429

Lats:  4.41217625779  -  1.2705836042  Diff:  3.14159265359
Lons:  3.85396423175  -  0.712371578164  Diff:  3.14159265359
Pos1:  1.9329383337 7.22964312956 2.23807587188
Pos2:  1.9329383337 7.22964312956 2.23807587188

Lats:  0.135838374462  -  3.27743102805  Diff:  3.14159265359
Lons:  1.64115450181  -  1.64115450181  Diff:  0.0
Pos1:  9.88336821577 -0.0952011605369 -0.696525460481
Pos2:  -9.88336821577 0.0952011605369 0.696525460481

Lats:  5.03750570722  -  5.03750570722  Diff:  0.0
Lons:  1.46803830938  -  1.46803830938  Diff:  0.0
Pos1:  3.17734475072 -0.972036026841 0.327651707624
Pos2:  3.17734475072 -0.972036026841 0.327651707624

Lats:  0.350045505601  -  0.350045505601  Diff:  0.0
Lons:  5.436873812  -  5.436873812  Diff:  0.0
Pos1:  -7.0342906832 2.27283766805 6.22558689914
Pos2:  -7.0342906832 2.27283766805 6.22558689914

Lats:  0.0171541809941  -  0.0171541809941  Diff:  0.0
Lons:  1.13445981395  -  1.13445981395  Diff:  0.0
Pos1:  9.06172667879 0.0724937989497 4.22559887977
Pos2:  9.06172667879 0.0724937989497 4.22559887977

Lats:  1.69526847861  -  4.8368611322  Diff:  3.14159265359
Lons:  2.92736309538  -  6.06895574897  Diff:  3.14159265359
Pos1:  -0.263938369219 -9.69580670745 1.21312953854
Pos2:  -0.263938369219 -9.69580670745 1.21312953854```

As you can see it works in a lot of cases, shown by the "diff" between the original and the newly gotton lat/lon being 0.0 (and Pos1 and Pos2 being equal).

Funnily, when both the lat and long are out by 180 degrees the correct position is also returned.

In the cases of failure, only one of the returned lat or long is out by 180 degrees, and Pos2 is directly opposite (negative) to Pos1.

So it's really just the sign of the represented point that wrong in some cases. The actual absolute values are correct.

In Topic: Please beta test my game!

04 April 2011 - 07:44 AM

Little update.

Now I've added grid based movement:

Windows: PuzzleMoppetTrial.exe
Linux: PuzzleMoppetTrial.tar.gz

The glyph thing on the ground shows the current direction... since at some angles it's not always clear which is "forwards".

If anyone has an opinion on the grid based movement I'd love to hear it. Since I'm not sure whether to enable it by default or not.
(it can be enabled/disabled in the options menu)

Well, anyway, hopefully this is my last update
(well, hopefully, you never know... I'm still not decided whether to have music or not and a few other relatively minor things)

In Topic: Please beta test my game!

17 March 2011 - 04:27 PM

Thanks guys I love the Deus Ex sound track, certainly something like that. I'm looking through musicloops right now. I have been through some stuff there before, but there's such a lot, it's hard sifting through it all.

@SriLumpa,

eeek, thanks for reporting the website thing, I think a recent update broke something... anyway I've fixed that page and it's showing now.

> The camera that repositions itself when you respawn is confusing
hmm.. I could save the camera angle the player had at the time the state is saved. Or alternatively use the angle the player had before hitting undo...

> I would find it good to see what I could have done to get a better rating
the rating is simply the sum of all pushes/elevator moves, undos and deaths. A lower total being better.
Maybe I could have the total sum displayed... and e.g. "Complete in a total of X or less for a perfect score"... (or instead of "perfect", state the amount needed to go one better rating than that the player achieved..)

I agree with all your other points too, I'll look into fixing them. The ".Configuration" thing from before is still sitting on my TODO list as well... Thanks again

In Topic: Please beta test my game!

17 March 2011 - 01:18 PM

Thanks :-)

yeah, I've been looking for some music like that but can't seem to find any royalty free stuff that fits... all stuff I can find is a bit too "epic" if you get what I mean... I need something sedate, somewhere between ambiance and music...

PARTNERS