MCPcopy Create free account
hub / github.com/Kitware/VTK / CartesianToSpherical

Function CartesianToSpherical

IO/NetCDF/vtkMPASReader.cxx:871–887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

869//------------------------------------------------------------------------------
870
871static int CartesianToSpherical(
872 double x, double y, double z, double* rho, double* phi, double* theta)
873{
874 double trho, ttheta, tphi;
875
876 trho = sqrt((x * x) + (y * y) + (z * z));
877 ttheta = atan2(y, x);
878 tphi = acos(z / (trho));
879 if (vtkMath::IsNan(trho) || vtkMath::IsNan(ttheta) || vtkMath::IsNan(tphi))
880 {
881 return -1;
882 }
883 *rho = trho;
884 *theta = ttheta;
885 *phi = tphi;
886 return 0;
887}
888
889//------------------------------------------------------------------------------
890// Function to convert spherical coordinates to cartesian, for use in

Callers 1

OutputPointsMethod · 0.85

Calls 3

IsNanFunction · 0.85
sqrtFunction · 0.50
acosFunction · 0.50

Tested by

no test coverage detected