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.

DarkBASIC Discussion / geometry question

Author
Message
ivan2009
16
Years of Service
User Offline
Joined: 28th Feb 2009
Location: Canada
Posted: 1st Mar 2009 04:27
This is a simple problem, but- how do I get the x,y, and z
coordinates of the surface of a sphere? I know I can get the x, and z coordinates by:

x#=sin(angley#)*radius#
z#=cos(angley#)*radius#

but how do I get the Y coordinate?
help would be appreciated, also, I posted this here because I'm using DB Classic.
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 1st Mar 2009 10:40
Could use the distance formula.

Radius#=sqrt((X#-cX#)^2+(Y#-cY#)^2+(Z#-cZ#)^2)

Where cX#, cY#, and cZ# are the center coordinates of the sphere. To find y#, use algebra to get:

sqrt(radius#^2-(X#-cX#)^2-(z#-cZ#)^2)+cY#=y#

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 1st Mar 2009 12:43
I think you want to use sphere coördinates. It's basically:

RadiusXZ# = cos(ax#) * radius#
y# = sin(ax#) * radius#
x# = cos(ay#) * radiusXZ#
z# = sin(ay#) * radiusXZ#

In short
x# = cos(ay#) * cos(ax#) * radius#
y# = sin(ax#) * radius#
z# = sin(ay#) * cos(ax#) * radius#

Good luck!
Sven B

ivan2009
16
Years of Service
User Offline
Joined: 28th Feb 2009
Location: Canada
Posted: 1st Mar 2009 19:44
ok, I've got it, thank you. by the way, i'm sorry about the xx's post, I wasn't sure if the posts were working.

Login to post a reply

Server time is: 2025-05-16 11:17:21
Your offset time is: 2025-05-16 11:17:21