The conventions used here are the mathematical ones, i.e. spherical coordinates are related to Cartesian coordinates as follows:
r is the radius, θ is the azimuthal angle in the x-y plane and Φ is the polar (co-latitude) angle. These conventions are different from the conventions used in physics (and in particular in spherical harmonics) where the meanings of θ and Φ are reversed.
This class provides conversion of coordinates and also of gradient and Hessian between spherical and Cartesian coordinates.
| Modifier and Type | Class and Description |
|---|---|
| private static class | SphericalCoordinates.
Internal class used only for serialization. |
| Modifier and Type | Field and Description |
|---|---|
| private double[][] | jacobian
Jacobian of (r, θ Φ). |
| private final double | phi
Polar angle (co-latitude) Φ. |
| private double[][] | phiHessian
Hessian of polar (co-latitude) angle Φ. |
| private final double | r
Radius. |
| private double[][] | rHessian
Hessian of radius. |
| private static final long | serialVersionUID
Serializable UID. |
| private final double | theta
Azimuthal angle in the x-y plane θ. |
| private double[][] | thetaHessian
Hessian of azimuthal angle in the x-y plane θ. |
| private final Vector3D | v
Cartesian coordinates. |
| Access | Constructor and Description |
|---|---|
| public | SphericalCoordinates(final Vector3D
Cartesian coordinates v)Build a spherical coordinates transformer from Cartesian coordinates. |
| public | SphericalCoordinates(final double
radius r, final double azimuthal angle in x-y plane theta, final double polar (co-latitude) angle phi)Build a spherical coordinates transformer from spherical coordinates. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| public Vector3D | |
| public double | |
| public double | |
| public double | |
| public double[] | Returns: gradient with respect to Cartesian coordinates {df/dx, df/dy, df/dz}gradient with respect to spherical coordinates
{df/dr, df/dθ, df/dΦ} sGradient)Convert a gradient with respect to spherical coordinates into a gradient with respect to Cartesian coordinates. |
| public double[][] | Returns: Hessian with respect to Cartesian coordinates {{d2f/dx2, d2f/dxdy, d2f/dxdz}, {d2f/dxdy, d2f/dy2, d2f/dydz}, {d2f/dxdz, d2f/dydz, d2f/dz2}}Hessian with respect to spherical coordinates
{{d2f/dr2, d2f/drdθ, d2f/drdΦ},
{d2f/drdθ, d2f/dθ2, d2f/dθdΦ},
{d2f/drdΦ, d2f/dθdΦ, d2f/dΦ2} sHessian, final double[] gradient with respect to spherical coordinates
{df/dr, df/dθ, df/dΦ} sGradient)Convert a Hessian with respect to spherical coordinates into a Hessian with respect to Cartesian coordinates. |
| private Object | Returns: data transfer object that will be serializedReplace the instance with a data transfer object for serialization. |
| jacobian | back to summary |
|---|---|
| private double[][] jacobian Jacobian of (r, θ &Phi). | |
| phi | back to summary |
|---|---|
| private final double phi Polar angle (co-latitude) Φ. | |
| phiHessian | back to summary |
|---|---|
| private double[][] phiHessian Hessian of polar (co-latitude) angle Φ. | |
| r | back to summary |
|---|---|
| private final double r Radius. | |
| rHessian | back to summary |
|---|---|
| private double[][] rHessian Hessian of radius. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable UID. | |
| theta | back to summary |
|---|---|
| private final double theta Azimuthal angle in the x-y plane θ. | |
| thetaHessian | back to summary |
|---|---|
| private double[][] thetaHessian Hessian of azimuthal angle in the x-y plane θ. | |
| v | back to summary |
|---|---|
| private final Vector3D v Cartesian coordinates. | |
| SphericalCoordinates | back to summary |
|---|---|
| public SphericalCoordinates(final Vector3D v) Build a spherical coordinates transformer from Cartesian coordinates.
| |
| SphericalCoordinates | back to summary |
|---|---|
| public SphericalCoordinates(final double r, final double theta, final double phi) Build a spherical coordinates transformer from spherical coordinates.
| |
| computeHessians | back to summary |
|---|---|
| private void computeHessians() Lazy evaluation of Hessians. | |
| computeJacobian | back to summary |
|---|---|
| private void computeJacobian() Lazy evaluation of (r, θ, φ) Jacobian. | |
| getCartesian | back to summary |
|---|---|
| public Vector3D getCartesian() Get the Cartesian coordinates.
| |
| getPhi | back to summary |
|---|---|
| public double getPhi() Get the polar (co-latitude) angle.
| |
| getR | back to summary |
|---|---|
| public double getR() Get the radius.
| |
| getTheta | back to summary |
|---|---|
| public double getTheta() Get the azimuthal angle in x-y plane. | |
| toCartesianGradient | back to summary |
|---|---|
| public double[] toCartesianGradient(final double[] sGradient) Convert a gradient with respect to spherical coordinates into a gradient with respect to Cartesian coordinates.
| |
| toCartesianHessian | back to summary |
|---|---|
| public double[][] toCartesianHessian(final double[][] sHessian, final double[] sGradient) Convert a Hessian with respect to spherical coordinates into a Hessian with respect to Cartesian coordinates. As Hessian are always symmetric, we use only the lower left part of the provided spherical Hessian, so the upper part may not be initialized. However, we still do fill up the complete array we create, with guaranteed symmetry.
| |
| writeReplace | back to summary |
|---|---|
| private Object writeReplace() Replace the instance with a data transfer object for serialization.
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Serializable UID. |
| private final double | x
Abscissa. |
| private final double | y
Ordinate. |
| private final double | z
Height. |
| Access | Constructor and Description |
|---|---|
| pack-priv | DataTransferObject(final double
abscissa x, final double ordinate y, final double height z)Simple constructor. |
| Modifier and Type | Method and Description |
|---|---|
| private Object | Returns: replacementSphericalCoordinatesReplace the deserialized data transfer object with a |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable UID. | |
| x | back to summary |
|---|---|
| private final double x Abscissa. | |
| y | back to summary |
|---|---|
| private final double y Ordinate. | |
| z | back to summary |
|---|---|
| private final double z Height. | |
| DataTransferObject | back to summary |
|---|---|
| pack-priv DataTransferObject(final double x, final double y, final double z) Simple constructor.
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() Replace the deserialized data transfer object with a
| |