Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Any Maths gurus?

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Sep 2003 19:23
Let's say the earth is 600 units in diameter, or 300 in radius, whichever suits.

I want to pick a point at random on the earths surface, between -60 and +60 degrees of the equator. How do I get that point in 3D space?

r = 300
Angle Y = random value between 0 and 360
Angles X & Z = random values between -60 and +60 (I think, could be wrong here)
Distances X,Y and Z = ?

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Watsisname
21
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Wales
Posted: 24th Sep 2003 19:58
You only need two angles to get a point on the earth .

angle 1: lat(latitude) = random number between -60.0 and 60.0
angle 2: long(longitude) = random number between 0 and 360.0

Assuming the planet is centred on 0,0,0, and that at lat = 0, long = 0 is at r,0,0, y is the polar axis, then the co-ordinates are

x = r*cos(long)*cos(lat)
z = r*sin(long)*cos(lat)
y = r*sin(lat)

I think that's right off the top off my head. I'll double check when I get home. You should be able to use wrapvalue commands, but sin and cos should do fine if your just placing points on the earth. Hope that helps
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Sep 2003 20:07
Thanks, it makes more sense, although I'll just have to believe you on the calculations

I think I confused myself even more by calling my angles X,Y and Z.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Sep 2003 02:52 Edited at: 25th Sep 2003 02:52
It's kinda working... I get random angles between -60 and + 60 for the latitude, but longitude is confined to a 90 degree area. Here's the code based on Watsisname's calcs...



BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Watsisname
21
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Wales
Posted: 25th Sep 2003 22:28 Edited at: 25th Sep 2003 22:29
I think it might be that you're using integer values for everything. You can use integers for the angles and object number (300+n), but everything else, r,x,y,z, should be represented by real values. It seemed to work for me with real variables, r#,x#,y#,z#. Try that!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Sep 2003 22:55
You didn't spot the...er...deliberate mistake.

I started with lat and lon
and went to lat and long

Works fantastically well now...thanks.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php

Login to post a reply

Server time is: 2024-09-21 01:04:20
Your offset time is: 2024-09-21 01:04:20