org.gicentre.utils.network.traer.physics

## Class Gravity

- java.lang.Object
- - org.gicentre.utils.network.traer.physics.Function<Particle,Particle>
  - - org.gicentre.utils.network.traer.physics.Gravity

-     public class Gravity
      extends Function<Particle,Particle>

  Represents a gravity function which may be applied to particles.
  Version:
    3.4, 5th February, 2016.
  Author:
    Carl Pearson with minor modifications by Jo Wood.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static float` | `DEFAULT_GRAVITY` Default gravity value (0)

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Gravity()` Creates a zero-gravitational function.
    `Gravity(float grav)` Creates a gravity function with the given gravity value applied in the 'y' direction.
    `Gravity(float gx, float gy, float gz)` Creates a gravity function with the given gravity value applied 3 dimensions.
    `Gravity(Vector3D grav3d)` Creates a gravity function with the given gravity value applied 3 dimensions.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Particle` | `apply(Particle p)` Applies this gravity function to the given particle, modifying its velocity and direction as appropriate.
    `Gravity` | `setGravity(float grav)` Sets the gravity function with the given gravity value applied in the 'y' direction.
    `Gravity` | `setGravity(float gx, float gy, float gz)` Sets the gravity function with the given gravity value applied 3 dimensions.
    `Gravity` | `setGravity(Vector3D grav3d)` Sets the gravity function with the given gravity value applied 3 dimensions.

    - ### Methods inherited from class org.gicentre.utils.network.traer.physics.Function

      `combine, functor, transform`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_GRAVITY

          public static final float DEFAULT_GRAVITY

      Default gravity value (0)
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Gravity

          public Gravity()

      Creates a zero-gravitational function.

    - #### Gravity

          public Gravity(float grav)

      Creates a gravity function with the given gravity value applied in the 'y' direction.
      Parameters:
        `grav` - Gravitational parameter.

    - #### Gravity

          public Gravity(float gx,
                         float gy,
                         float gz)

      Creates a gravity function with the given gravity value applied 3 dimensions.
      Parameters:
        `gx` - Gravitational parameter to be applied in the x-direction.
        `gy` - Gravitational parameter to be applied in the y-direction.
        `gz` - Gravitational parameter to be applied in the z-direction.

    - #### Gravity

          public Gravity(Vector3D grav3d)

      Creates a gravity function with the given gravity value applied 3 dimensions.
      Parameters:
        `grav3d` - Gravitational parameter to be applied in the 3 dimensions.

  - ### Method Detail

    - #### setGravity

          public Gravity setGravity(float grav)

      Sets the gravity function with the given gravity value applied in the 'y' direction.
      Parameters:
        `grav` - Gravitational parameter.
      Returns:
        The newly modified gravity function.

    - #### setGravity

          public Gravity setGravity(float gx,
                                    float gy,
                                    float gz)

      Sets the gravity function with the given gravity value applied 3 dimensions.
      Parameters:
        `gx` - Gravitational parameter to be applied in the x-direction.
        `gy` - Gravitational parameter to be applied in the y-direction.
        `gz` - Gravitational parameter to be applied in the z-direction.
      Returns:
        The newly modified gravity function.

    - #### setGravity

          public Gravity setGravity(Vector3D grav3d)

      Sets the gravity function with the given gravity value applied 3 dimensions.
      Parameters:
        `grav3d` - Gravitational parameter to be applied in three dimensions.
      Returns:
        The newly modified gravity function.

    - #### apply

          public Particle apply(Particle p)

      Applies this gravity function to the given particle, modifying its velocity and direction as appropriate.
      Specified by:
        `apply` in class `Function<Particle,Particle>`
      Parameters:
        `p` - Particle upon which to apply the gravity.
      Returns:
        The transformed value.