package nl.tudelft.simulation.language.d3; /** * A sphericalpoint as defined in * http://mathworld.wolfram.com/SphericalCoordinates.html . *

* Copyright (c) 2002-2009 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights * reserved. *

* See for project information www.simulation.tudelft.nl. *

* The DSOL project is distributed under the following BSD-style license:
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * following conditions are met: *

* This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, * including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are * disclaimed. In no event shall the copyright holder or contributors be liable for any direct, indirect, incidental, * special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or * services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, * whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use * of this software, even if advised of the possibility of such damage. * @author Peter Jacobs * @version $Revision: 1.2 $ $Date: 2009/10/21 07:32:42 $ * @since 1.5 */ public class SphericalPoint { /** radius. */ private double radius = 0.0; /** phi. */ private double phi = 0.0; /** theta. */ private double theta = 0.0; /** * constructs a new SphericalPoint. * @param phi phi * @param radius radius * @param theta theta */ public SphericalPoint(final double radius, final double phi, final double theta) { super(); this.phi = phi; this.radius = radius; this.theta = theta; } /** * @return phi */ public double getPhi() { return this.phi; } /** * @return radius */ public double getRadius() { return this.radius; } /** * @return theta */ public double getTheta() { return this.theta; } /** * converts a sphericalpoint to a cartesian point. * @return the cartesian point */ public CartesianPoint toCartesianPoint() { return SphericalPoint.toCartesianPoint(this); } /** * converts a sphericalpoint to a cartesian point. * @param point the sphericalpoint * @return the cartesian point */ public static CartesianPoint toCartesianPoint(final SphericalPoint point) { double x = point.radius * Math.sin(point.phi) * Math.cos(point.theta); double y = point.radius * Math.sin(point.phi) * Math.sin(point.theta); double z = point.radius * Math.cos(point.phi); return new CartesianPoint(x, y, z); } }