org.jscience.physics.waves.optics.elements
Class OpticalElement

java.lang.Object
  extended by org.jscience.physics.waves.optics.elements.OpticalElement
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AntiAperture, Aperture, Aspherical, DeviceSwitcher, Homogeneous, NoOpticalElement, OpticalDevice, Screen, SimpleLens

public abstract class OpticalElement
extends java.lang.Object
implements java.lang.Cloneable

The OpticalElement class is an abstract class which implements the standard behaviour of an optical element. Every element inherits from it.

The standard use of this class is to build a system using OpticalElement subclasses into an OpticalDevice object and to use an OpticalCanvas object to display it.

See Also:
OpticalDevice, OpticalCanvas

Constructor Summary
OpticalElement()
          Default constructor, puts the elements at (0, 0, 0).
OpticalElement(double w)
           
 
Method Summary
 java.lang.Object clone()
           
 void draw(java.awt.Graphics g)
          Draws the element's symbol into a Graphics object.
 int drawRay(java.awt.Graphics g, Ray r, int index)
          Draws a part of a Ray (a RayPoint) going through the element.
abstract  void drawSelf(java.awt.Graphics g)
          Draws the element's symbol into a Graphics object.
 Double3Vector getAxis()
          Gets the y and z coordinates of the optical axis.
 Double3Vector getCenter()
          Gets the center of the element.
 Double3Vector getOffAxis()
          Returns the off axis properties of the element in an Double3Vector.
 double getWidth()
          Gets the width of the element.
 double getX()
          Gets the x coordinate of the element.
 void moveAxis(double y, double z)
          Moves the element's optical axis along the y and z directions.
 void moveOffAxis(double y, double z)
          Moves the element along the y and z directions (NOT the optical axis).
 void moveOnAxis(double x)
          Moves the element along the optical axis, i.e. along the x direction.
 void propagate(Ray r)
          Propagates a Ray through the element.
 RayPoint propagateRayPoint(RayPoint r)
          Called by Propagate.
abstract  void propagateRayPointSelf(RayPoint r)
          This method implements the element's actual behaviour.
 void putAfter(OpticalElement e)
          Aligns the element on the same axis as the element passed as a parameter and moves it on the x direction directly to the right of the element.
 void rearrange()
           
 void setWidth(double width)
          Sets the width of the element.
 void translateOrigin(RayPoint rp)
          Translates the RayPoint in order to put the origin of its coordinates system at the element's center.
 void translateOriginBack(RayPoint rp)
          Translates the RayPoint back in order to restore the origin of its coordinates system.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpticalElement

public OpticalElement()
Default constructor, puts the elements at (0, 0, 0).


OpticalElement

public OpticalElement(double w)
Method Detail

rearrange

public void rearrange()

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

moveAxis

public void moveAxis(double y,
                     double z)
Moves the element's optical axis along the y and z directions. It only has effect if the element is the first one of an OpticalDevice, because each element aligns itself on the previous one.

Parameters:
y - the y coordinate of the optical axis.
z - the z coordinate of the optical axis.

moveOnAxis

public void moveOnAxis(double x)
Moves the element along the optical axis, i.e. along the x direction. It only has effect if the element is the first one of an OpticalDevice, because elements stack next to each other.

Parameters:
x - the x coordinate of the element.

moveOffAxis

public void moveOffAxis(double y,
                        double z)
Moves the element along the y and z directions (NOT the optical axis). It is used to uncenter the element from the optical axis.

Parameters:
y - off-axis displacement along the y axis.
z - off-axis displacement along the z axis.

getX

public double getX()
Gets the x coordinate of the element.

Returns:
the x coordinate of the element on the optical axis.

getAxis

public Double3Vector getAxis()
Gets the y and z coordinates of the optical axis.

Returns:
an Double3Vector with the y and z coordinates of the optical axis. The x coordinate is set to 0.
See Also:
Double3Vector

getOffAxis

public Double3Vector getOffAxis()
Returns the off axis properties of the element in an Double3Vector. Coordinate x is set to 0.

Returns:
an Double3Vector with the y and z coordinates of the element centers relative to the optical axis. The x coordinate is set to 0.
See Also:
Double3Vector

propagate

public void propagate(Ray r)
Propagates a Ray through the element. The last RayPoint of the Ray is sent to PropagateRayPoint and the result is appended to the Ray.

Parameters:
r - the Ray to propagate. If it is not empty, its last RayPoint is propagated through the element and the resulting RayPoint is appended to its end.
See Also:
Ray, RayPoint, propagateRayPoint(org.jscience.physics.waves.optics.rays.RayPoint)

propagateRayPoint

public RayPoint propagateRayPoint(RayPoint r)
Called by Propagate. Prepares the RayPoint before sending it to PropagateRayPointSelf. Its existence validity are tested, and a call to TranslateOrigin is made to adjust the RayPoint to the element's local coordinates system. Then PropagateRayPointSelf is called and eventually TranslateOriginBack to restore the coordinates system.

Note: This method should not be called by the user, nor overridden. One should only call PropagateRay and override PropagateRayPointSelf.

Parameters:
r - the RayPoint to be propagated.
Returns:
the propagated RayPoint, to be added to the end of the Ray.
See Also:
RayPoint, propagate(org.jscience.physics.waves.optics.rays.Ray), propagateRayPointSelf(org.jscience.physics.waves.optics.rays.RayPoint)

translateOrigin

public void translateOrigin(RayPoint rp)
Translates the RayPoint in order to put the origin of its coordinates system at the element's center. The element's center is its center in directions y and z, and its left side in direction x. Calls GetCenter for the center.

Parameters:
rp - the RayPoint to translate.
See Also:
translateOriginBack(org.jscience.physics.waves.optics.rays.RayPoint), getCenter(), RayPoint

translateOriginBack

public void translateOriginBack(RayPoint rp)
Translates the RayPoint back in order to restore the origin of its coordinates system. Calls GetCenter for the center.

Parameters:
rp - the RayPoint to translate.
See Also:
translateOrigin(org.jscience.physics.waves.optics.rays.RayPoint), getCenter(), RayPoint

getCenter

public Double3Vector getCenter()
Gets the center of the element. Called by TranslateOrigin, TranslateOriginBack and Draw. Elements can override this method to set the element's center to a point that is convenient to use as the origin for propagation and/or drawing.

Returns:
an Double3Vector with the coordinates of the center.
See Also:
Double3Vector, translateOrigin(org.jscience.physics.waves.optics.rays.RayPoint), translateOriginBack(org.jscience.physics.waves.optics.rays.RayPoint), draw(java.awt.Graphics)

propagateRayPointSelf

public abstract void propagateRayPointSelf(RayPoint r)
This method implements the element's actual behaviour. Any subclass of OpticalElement must override it. The RayPoint passes as a parameter is non null, valid and a clone of the last RayPoint of the Ray that was passed to Propagate. PropagateRayPointSelf should move the RayPoint to the last location where the element changes the wave vector (k), and set the wave vector accordingly. The RayPoint's position is calculated relative to the element's center, given by the result of the GetCenter method.

Parameters:
r - the RayPoint to propagate.
See Also:
RayPoint, getCenter()

draw

public void draw(java.awt.Graphics g)
Draws the element's symbol into a Graphics object. The Graphics is translated in order to place the element's center at the origin via a call to Graphics.translate, DrawSelf is called, which performs the actual drawing, and another call to Graphics.translate restores the Graphics origin. This method should not be overridden except is special cases like in OpticalDevice. Instead, DrawSelf must be overriden.

Parameters:
g - the Graphics object in which the element must be drawn.
See Also:
getCenter(), drawSelf(java.awt.Graphics), OpticalDevice.draw(java.awt.Graphics)

drawSelf

public abstract void drawSelf(java.awt.Graphics g)
Draws the element's symbol into a Graphics object. The origin is the element's center, as defined by GetCenter. As it is abstract, every subclass of OpticalElement must override this method.

Parameters:
g - the Graphics object in which the element must be drawn.

drawRay

public int drawRay(java.awt.Graphics g,
                   Ray r,
                   int index)
Draws a part of a Ray (a RayPoint) going through the element. The Ray is drawn as a straight line connecting the previous element's Raypoint with the current element's RayPoint in the Ray. Elements that must draw Rays that propagate differently (with multiple direction changes or elements like a index graded optical fiber) should override this method.

Parameters:
g - the Graphics object in which the Ray must be drawn.
r - the Ray to draw.
index - the index of the RayPoint to draw. Used to keep track of the position in the Ray in case of multiple OpticalDevice nesting.
Returns:
the index of the next RayPoint to be drawn by the next element.
See Also:
Ray, RayPoint, OpticalDevice

putAfter

public void putAfter(OpticalElement e)
Aligns the element on the same axis as the element passed as a parameter and moves it on the x direction directly to the right of the element.

Parameters:
e - the element on which to align the current element. The current element will be place to its right.

getWidth

public double getWidth()
Gets the width of the element.

Returns:
the width of the element.

setWidth

public void setWidth(double width)
Sets the width of the element.

Parameters:
width - the new width of the element.