Converting a 2D Sphere Coordinate Into a 3D Normal.

Started by
11 comments, last by alvaro 16 years, 9 months ago
Quote:Original post by EmptyVoid
Is that better? also I don't know what most of those functions do can you make that with the C++ math library "math.h" as I said not very good with C++ more of a VB person. if not how do I use the code above is it a function? or is it some from of cool data type converter that I had no idea C++ could do? also this is the error I get when I run the code:

------ Build started: Project: nam, Configuration: Debug Win32 ------
Compiling...
nam.cpp
c:\documents and settings\steven batchelor\my documents\visual studio 2005\projects\nam\nam\nam.cpp(16) : error C2061: syntax error : identifier 'SphericalType'
Build log was saved at "file://c:\Documents and Settings\Steven Batchelor\My Documents\Visual Studio 2005\Projects\nam\nam\Debug\BuildLog.htm"
nam - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If you're new to C++ (and/or programming in general), you might have some trouble trying to adapt those functions. Yes, the code is standard C++, but there are some external dependencies, so you won't be able to compile the code as is. What you'll have to do instead, most likely, is examine the functions to see how the conversions are being performed, and then re-write your own code using the same steps.
Advertisement
OK I will try to figure it out thank you.
This is your life, and it's ending one minute at a time. - Fight club
Converting from (latitude, longitude) to (x,y,z) is not hard:

x = cos(latitude) * sin(longitude)
y = sin(latitude)
z = cos(latitude) * cos(longitude)

That's your normal (and also the point itself, if the sphere is centered at (0,0,0) and has radius 1).

This topic is closed to new replies.

Advertisement