Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members Related Pages Search
cartesian3dcoord.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <cmath>
00019
00020 #include "cartesian3dcoord.h"
00021 #include "sphericalcoord.h"
00022
00023 Cartesian3DCoord::Cartesian3DCoord(double x, double y, double z) : _x(x), _y(y), _z(z)
00024 {
00025 }
00026
00027 SphericalCoord Cartesian3DCoord::toSphericalCoord()
00028 {
00029 double azimuthal, polar, radial;
00030
00031 azimuthal = atan2(_y,_x);
00032 radial = sqrt(_x*_x+_y*_y+_z*_z);
00033 polar = acos(_z/radial);
00034
00035 return SphericalCoord(azimuthal,polar,radial);
00036 }
|