1
2
3
4
5
6 package nl.tudelft.simulation.language.d3;
7
8 /***
9 * A sphericalpoint as defined in <a href="http://mathworld.wolfram.com/SphericalCoordinates.html">
10 * http://mathworld.wolfram.com/SphericalCoordinates.html </a>.
11 * <p>
12 * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft University of Technology </a>, the
13 * Netherlands.
14 * <p>
15 * See for project information <a
16 * href="http://www.simulation.tudelft.nl/dsol/language">www.simulation.tudelft.nl/language </a> <br>
17 * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser General Public License (LGPL)
18 * </a>, no warranty
19 *
20 * @author <a href="http://www.peter-jacobs.com/index.htm">Peter Jacobs </a>
21 * @version $Revision: 1.7 $ $Date: 2005/07/04 12:21:22 $
22 * @since 1.5
23 */
24 public class SphericalPoint
25 {
26 /*** radius. */
27 private double radius = 0.0;
28
29 /*** phi. */
30 private double phi = 0.0;
31
32 /*** theta. */
33 private double theta = 0.0;
34
35 /***
36 * constructs a new SphericalPoint.
37 *
38 * @param phi
39 * phi
40 * @param radius
41 * radius
42 * @param theta
43 * theta
44 */
45 public SphericalPoint(final double radius, final double phi, final double theta)
46 {
47 super();
48 this.phi = phi;
49 this.radius = radius;
50 this.theta = theta;
51 }
52
53 /***
54 * @return phi
55 */
56 public double getPhi()
57 {
58 return this.phi;
59 }
60
61 /***
62 * @return radius
63 */
64 public double getRadius()
65 {
66 return this.radius;
67 }
68
69 /***
70 * @return theta
71 */
72 public double getTheta()
73 {
74 return this.theta;
75 }
76
77 /***
78 * converts a sphericalpoint to a cartesian point.
79 *
80 * @return the cartesian point
81 */
82 public CartesianPoint toCartesianPoint()
83 {
84 return SphericalPoint.toCartesianPoint(this);
85 }
86
87 /***
88 * converts a sphericalpoint to a cartesian point.
89 *
90 * @param point
91 * the sphericalpoint
92 * @return the cartesian point
93 */
94 public static CartesianPoint toCartesianPoint(final SphericalPoint point)
95 {
96 double x = point.radius * Math.sin(point.phi) * Math.cos(point.theta);
97 double y = point.radius * Math.sin(point.phi) * Math.sin(point.theta);
98 double z = point.radius * Math.cos(point.phi);
99 return new CartesianPoint(x, y, z);
100 }
101 }