View Javadoc

1   /*
2    * @(#) Ball.java Mar 3, 2004
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.tutorial.section44;
11  
12  import java.rmi.RemoteException;
13  
14  import javax.media.j3d.BoundingSphere;
15  import javax.media.j3d.Bounds;
16  import javax.vecmath.Point3d;
17  
18  import nl.tudelft.simulation.dsol.animation.LocatableInterface;
19  import nl.tudelft.simulation.language.d3.DirectedPoint;
20  
21  /***
22   * A Ball <br>
23   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
24   * University of Technology </a>, the Netherlands. <br>
25   * See for project information <a
26   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
27   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
28   * License (GPL) </a>, no warranty <br>
29   * 
30   * @version 1.0 Mar 3, 2004 <br>
31   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
32   *         Jacobs </a>
33   */
34  public abstract class Ball implements LocatableInterface
35  {
36  	/*** the number of created balls */
37  	private static int number = 0;
38  
39  	/*** the radius of the ball */
40  	public static final double RADIUS = 5.0;
41  
42  	/*** the name of the ball */
43  	private String name = "";
44  
45  	/*** the origin */
46  	protected DirectedPoint origin = new DirectedPoint();
47  
48  	/*** the destination */
49  	protected DirectedPoint destination = new DirectedPoint();
50  
51  	/*** the rotation */
52  	protected double rotZ = 0.0;
53  
54  	/***
55  	 * constructs a new Ball
56  	 */
57  	public Ball()
58  	{
59  		super();
60  		this.rotZ = 2 * Math.PI * Math.random();
61  		Ball.number++;
62  		this.name = "" + Ball.number;
63  	}
64  
65  	/***
66  	 * @see nl.tudelft.simulation.dsol.animation.LocatableInterface#getBounds()
67  	 */
68  	public Bounds getBounds() throws RemoteException
69  	{
70  		return new BoundingSphere(new Point3d(0, 0, 0), Ball.RADIUS);
71  	}
72  
73  	/***
74  	 * @see java.lang.Object#toString()
75  	 */
76  	public String toString()
77  	{
78  		return this.name;
79  	}
80  }