## org.jscience.physics.nuclear.kinematics.montecarlo Class Direction

```java.lang.Object
org.jscience.physics.nuclear.kinematics.montecarlo.Direction
```
All Implemented Interfaces:
java.lang.Cloneable

`public class Directionextends java.lang.Objectimplements java.lang.Cloneable`

Class which provides an abstraction for a direction in 3-dimensional space.

Constructor Summary
```Direction(double theta, double phi)```
Creates new direction, given theta (angle from z-axis) and phi (azimuthal angle from x axis) in radians.
```Direction(double _x, double _y, double _z)```
Create a new direction by specifying its x, y, and z components.

Method Summary
`protected  java.lang.Object` `clone()`
DOCUMENT ME!
`static double` ```evaluateLegendre(int _l, int _m, double _x)```
Taken from plgndr, section 6.8 in Numerical Recipes in C.
` double[]` `get3vector(double amplitude)`
DOCUMENT ME!
`static Direction` `getBackwardRandomDirection()`
DOCUMENT ME!
`static Direction` `getDirection(Matrix m)`
DOCUMENT ME!
` double` `getPhi()`
DOCUMENT ME!
` double` `getPhiDegrees()`
DOCUMENT ME!
`static Direction` `getRandomDirection()`
DOCUMENT ME!
`static Direction` ```getRandomDirection(double minThetaRad, double maxThetaRad)```
get Random direction between given theta limits
`static Direction` `getRandomDirection(int l)`
Generate a random direction for m=0 using a Legendre polynomial distribution (attenuated by a sin theta solid angle factor).
`static Direction` ```getRandomDirection(int l, Direction d)```
Generate a random direction using a Legendre polynomial distribution (attenuated by a sin theta solid angle factor), relative to a z-axis defined by the given direction.
`static Direction` ```getRandomDirection(int l, int m)```
Generate a random direction using a Spherical Harmonic distribution (attenuated by a sin theta solid angle factor).
` double` `getTheta()`
DOCUMENT ME!
` double` `getThetaDegrees()`
DOCUMENT ME!
` Matrix` `getVector()`
DOCUMENT ME!
` double` `getX()`
DOCUMENT ME!
` double` `getY()`
DOCUMENT ME!
` double` `getZ()`
DOCUMENT ME!
`static void` `main(java.lang.String[] args)`
DOCUMENT ME!
`static double` `normPhi(double _phi)`
DOCUMENT ME!
` Direction` `rotateFrameY(double angRad)`
Return a new Direction object resulting from this object's reference frame being rotated by angRad about the y-axis.
` Direction` `rotateFrameZ(double angRad)`
Return a new Direction object resulting from this object's reference frame being rotated by angRad about the z-axis.
` Direction` `rotateY(double angRad)`
return a new Direction object resulting from this object being rotated by angRad about the y-axis
` java.lang.String` `toString()`
DOCUMENT ME!

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Direction

```public Direction(double theta,
double phi)```
Creates new direction, given theta (angle from z-axis) and phi (azimuthal angle from x axis) in radians.

### Direction

```public Direction(double _x,
double _y,
double _z)```
Create a new direction by specifying its x, y, and z components. These will be renormailized.

Method Detail

### clone

`protected java.lang.Object clone()`
DOCUMENT ME!

Overrides:
`clone` in class `java.lang.Object`
Returns:
DOCUMENT ME!

### rotateY

`public Direction rotateY(double angRad)`
return a new Direction object resulting from this object being rotated by angRad about the y-axis

Parameters:
`angRad` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### rotateFrameY

`public Direction rotateFrameY(double angRad)`
Return a new Direction object resulting from this object's reference frame being rotated by angRad about the y-axis.

Parameters:
`angRad` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### rotateFrameZ

`public Direction rotateFrameZ(double angRad)`
Return a new Direction object resulting from this object's reference frame being rotated by angRad about the z-axis.

Parameters:
`angRad` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### getDirection

`public static Direction getDirection(Matrix m)`
DOCUMENT ME!

Parameters:
`m` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### get3vector

`public double[] get3vector(double amplitude)`
DOCUMENT ME!

Parameters:
`amplitude` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### getPhi

`public double getPhi()`
DOCUMENT ME!

Returns:
phi in radians, guaranteed between -pi and pi

### getTheta

`public double getTheta()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

### getX

`public double getX()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

### getY

`public double getY()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

### getZ

`public double getZ()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

### getVector

`public Matrix getVector()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

### getBackwardRandomDirection

`public static Direction getBackwardRandomDirection()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

### toString

`public java.lang.String toString()`
DOCUMENT ME!

Overrides:
`toString` in class `java.lang.Object`
Returns:
DOCUMENT ME!

### normPhi

`public static double normPhi(double _phi)`
DOCUMENT ME!

Parameters:
`_phi` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### getPhiDegrees

`public double getPhiDegrees()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

`public double getThetaDegrees()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

### evaluateLegendre

```public static double evaluateLegendre(int _l,
int _m,
double _x)
throws java.lang.IllegalArgumentException```
Taken from plgndr, section 6.8 in Numerical Recipes in C. Decays with angular momentum 'l' are distributed as the square of evaluateLegengre(l,0,cos theta). (Modulated of course by the sin(theta) factor of the phase space available.)

Parameters:
`_l` - orbital angular momentum quantum number, 0 or positive
`_m` - substate, can be from 0 to l
`_x` - where to evaluate, from -1 to 1
Returns:
DOCUMENT ME!
Throws:
`java.lang.IllegalArgumentException` - DOCUMENT ME!

### getRandomDirection

```public static Direction getRandomDirection(int l,
int m)```
Generate a random direction using a Spherical Harmonic distribution (attenuated by a sin theta solid angle factor).

Parameters:
`l` - DOCUMENT ME!
`m` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### getRandomDirection

`public static Direction getRandomDirection(int l)`
Generate a random direction for m=0 using a Legendre polynomial distribution (attenuated by a sin theta solid angle factor).

Parameters:
`l` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### getRandomDirection

`public static Direction getRandomDirection()`
DOCUMENT ME!

Returns:
DOCUMENT ME!

### getRandomDirection

```public static Direction getRandomDirection(double minThetaRad,
get Random direction between given theta limits

Parameters:
`minThetaRad` - DOCUMENT ME!
`maxThetaRad` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### getRandomDirection

```public static Direction getRandomDirection(int l,
Direction d)```
Generate a random direction using a Legendre polynomial distribution (attenuated by a sin theta solid angle factor), relative to a z-axis defined by the given direction.

Parameters:
`l` - DOCUMENT ME!
`d` - DOCUMENT ME!
Returns:
DOCUMENT ME!

### main

`public static void main(java.lang.String[] args)`
DOCUMENT ME!

Parameters:
`args` - DOCUMENT ME!