Jump to content


Member Since 04 Jun 2005
Offline Last Active Sep 02 2015 04:56 AM

Topics I've Started

getting lat/long of a point on a double poled sphere

29 July 2013 - 01:00 PM


Rather than the normal way of having latitude/longitude, with a north/south pole radiating lines for longitude, and then latitude lines being parallel circles of various radii, I instead have *two* poles, so a north/south pole and an east/west pole both radiate lines. So both sets of lines being like segments of an orange, coming together at the poles.

As in this rough diagram, the two poles shown as red and blue:


blue pole marked x is also the x axis (+ve to the right)
red pole marked y is also the y axis (+ve going upwards)
+z axis is coming out of the screen towards you

Now, I am managing to get a 3D point from a given lat/long, using these equations:

real_x = worldRadius * cos(latitude) * sin(longitude)

real_y = worldRadius * sin(latitude) * cos(longitude)

real_z = worldRadius * cos(latitude) * cos(longitude)

However, I also need to be able to do the reverse, from a given 3D point on the sphere, calculate the lat/long. This is giving me great trouble.

I thought this might work, and it does in *some* situations, however in other cases one or the other (or even both) lat and long are out by 180 degrees (and when put into the previous equations come out to a point directly opposite to what they should be):

lat = atan2(real_y, real_z)

lng = atan2(real_x, real_z)

Any thoughts? Math is really not my strong point.

Please beta test my game!

14 January 2011 - 06:29 AM


Please beta test my game, "Puzzle Moppet". It's a kind of block pushing puzzle game.
Available for Windows and Linux!

Posted Image

Looky here: http://garnetgames.com

Or just use the direct download links-

- 18 levels
- several block types... crates, elevators, ice blocks, exploding blocks, balloons...
- puzzles ranging in difficulty from stupidly easy to rather hard

Any feedback at all is much appreciated, although feature and gameplay wise I probably won't change much at this late stage. Any bug reports are especially appreciated (you can find the game's log files in the executable directory). If shaders don't work you can turn them off with the config app.

Also any opinions on the level difficulty curve would be interesting. It's a hard thing for me to judge since all levels are etched into my brain!

(and is the game at all fun or worth playing!?)


C++ layout manager?

16 September 2010 - 02:38 AM

Anyone know of a open source layout manager for C++? Ideally very lightweight, and not as part of a larger GUI library (unless it can be easily used standalone).

By layout manager, I mean something like this Java stuff here:

euler velocities to angular velocity vector

11 July 2010 - 11:05 PM

How can I convert velocities specified about the x,y,z axes to the conventional way (a vector with magnitude as the speed, as used in physics engines like ODE)?

I want to do this to fit in with the 3d engine I use, which has the convention of using euler angles for most things. Also it's more user friendly to specify angular velocity as euler speeds.

Also, the opposite conversion of the vector-to-euler would be nice too.

Anyone have *code* for this? My maths and understanding of formulas is very bad.

is there a better design for this interface?

25 May 2010 - 11:57 PM

Hi. I'm making an interface for things that are "pausable" in my game. Originally I had this -
class IPausable
	virtual ~IPausable(){}
	virtual void Pause() = 0;
	virtual void Resume() = 0;
	virtual bool IsPaused() = 0;
But now I've realised I need a kind of pause counter system, so that for example if Pause is called twice from different areas of code, then two calls of Resume should be required to un-pause the object. Now I'm thinking about this design -
class IPausable
	u32 pauseCounter;
		pauseCounter = 0;
	virtual ~IPausable(){}
	void Pause()
		if (pauseCounter == 0)
		pauseCounter ++;
	void Resume()
		pauseCounter --;
		if (pauseCounter == 0)
	bool IsPaused()
		return pauseCounter > 0;
	virtual void OnPause() = 0;
	virtual void OnResume() = 0;
So now pause/resume logic in derived classes must be implemented in the OnPause, OnResume methods, and the top level IPausable interface handles the pause counting. However, this approach feels a bit wrong and hackish, to have the implementation code in the interface. I feel that perhaps I should have a separate PauseCounter class, which owns an IPausable class, or something, so pause counting is separated. Having said that, the solution above will work very nicely. Perhaps I am just being silly? :)