frog
Class Accel3D

java.lang.Object
  extended by frog.Accel3D
All Implemented Interfaces:
Serializable

public class Accel3D
extends Object
implements Serializable

The basic unit FROG works on. Accel3D objects contain a single sampling of a device's accelerometers. They also contain helpful methods to manipulate that data.

Author:
Team Better Recognize
See Also:
Serialized Form

Constructor Summary
Accel3D(double x, double y, double z)
          Creates a new Accel3D containing the given axis values.
 
Method Summary
 void add(Accel3D other)
          Performs vector addition on this object using another Accel3D object.
 double distanceFrom(Accel3D other)
          Finds the distance between this Accel3D and another.
 double getMagnitude()
          Gets the vector magnitude of this Accel3D.
 double getX()
          Gets acceleration (in G's) of the X axis.
 double getY()
          Gets acceleration (in G's) of the Y axis.
 double getZ()
          Gets acceleration (in G's) of the Z axis.
 void rescale(double scaleFactor)
          Scales the X, Y, and Z values to a given scale value.
 double[] toArray()
          Returns the Accel3D converted to an array (double[3]).
 String toString()
          Returns a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Accel3D

public Accel3D(double x,
               double y,
               double z)
Creates a new Accel3D containing the given axis values.

Parameters:
x - the acceleration in the x-direction (in G's)
y - the acceleration in the y-direction (in G's)
z - the acceleration in the z-direction (in G's)
Method Detail

add

public void add(Accel3D other)
Performs vector addition on this object using another Accel3D object. The result is stored back in this Accel3D.

Parameters:
other - another Accel3D to add to this Accel3D

distanceFrom

public double distanceFrom(Accel3D other)
Finds the distance between this Accel3D and another.

Parameters:
other - an Accel3D to compare with
Returns:
the distance of this acceleration vector from the input

getMagnitude

public double getMagnitude()
Gets the vector magnitude of this Accel3D.

Returns:
the magnitude of the acceleration vector

getX

public double getX()
Gets acceleration (in G's) of the X axis.

Returns:
the acceleration in the x-direction

getY

public double getY()
Gets acceleration (in G's) of the Y axis.

Returns:
the acceleration in the y-direction

getZ

public double getZ()
Gets acceleration (in G's) of the Z axis.

Returns:
the acceleration in the z-direction

rescale

public void rescale(double scaleFactor)
Scales the X, Y, and Z values to a given scale value.

Parameters:
scaleFactor - amount to scale by; if 1.0, this vector remains unchanged

toArray

public double[] toArray()
Returns the Accel3D converted to an array (double[3]).

Returns:
this Accel3D in the form of {x, y, z}

toString

public String toString()
Returns a String representation of this object.

Overrides:
toString in class Object
Returns:
this Accel3D in the form of "(x, y, z)"