maspack.spatialmotion
Class SpatialVector

java.lang.Object
  extended bymaspack.matrix.VectorObject
      extended bymaspack.spatialmotion.SpatialVector
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Twist, Wrench

public abstract class SpatialVector
extends VectorObject
implements java.io.Serializable

A spatial vector, which is a 6-vector composed of two 3-vectors: a free vector and a line vector. Spatial vectors are described in Featherstone, Robot Dynamics Algorithms, and are used to represent quantities such as spatial velocities (or twists), spatial forces (or wrenchs).

Spatial vectors are either contarvariant (those associated with motion), or covariant (those associated with forces). For a contravariant spatial vector, elements 0-2 correspond to the free vector and elements 3-5 correspond to the line vector. For a covarient spatial vector, elements 0-2 correspond to the line vector and elements 3-5 correspond to the free vector (note that this transposing of element ordering is different from the treatment in Featherstone, which always asigns elements 0-2 to the line vector).

See Also:
Serialized Form

Method Summary
 void absolute()
          Sets the elements of this spatial vector to their absolute values.
 double dot(SpatialVector v1)
          Returns the dot product of this spatial vector and the spatial vector v1.
 boolean epsilonEquals(SpatialVector v1, double eps)
          Returns true if the elements of this spatial vector equal those of vector v1within a prescribed tolerance epsilon.
 boolean equals(SpatialVector v1)
          Returns true if the elements of this spatial vector exactly equal those of vector v1.
 void get(double[] values)
          Copies the elements of this spatial vector into an array of doubles.
 double get(int i)
          Gets a single element of this spatial vector.
 double infinityNorm()
          Returns the infinity norm of this spatial vector.
 void inverseTransform(RigidTransform3d X)
          Applies an inverse rigid spatial transformation to this vector, in place.
 void inverseTransform(RotationMatrix3d R)
          Applies an inverse rotational transformation to this spatial vector, in place.
 boolean isContravariant()
          Returns true if this spatial vector is contravariant.
 double maxElement()
          Returns the maximum element value of this spatial vector.
 double minElement()
          Returns the minimum element value of this spatial vector.
 void negate()
          Negates this spatial vector in place.
 double norm()
          Returns the 2 norm of this spatial vector.
 void normalize()
          Normalizes this spatial vector in place.
 double normSquared()
          Returns the square of the 2 norm of this spatial vector.
 double oneNorm()
          Returns the 1 norm of this spatial vector.
 void scale(double s)
          Scales the elements of this spatial vector by s.
 void set(double[] values)
          Sets the elements of this spatial vector from an array of doubles.
 void set(int i, double value)
          Sets a single element of this spatial vector.
 void setRandom()
          Sets the elements of this vector to uniformly distributed random values in the range -0.5 (inclusive) to 0.5 (exclusive).
 void setRandom(double lower, double upper)
          Sets the elements of this vector to uniformly distributed random values in a specified range.
 void setRandom(double lower, double upper, java.util.Random generator)
          Sets the elements of this vector to uniformly distributed random values in a specified range, using a supplied random number generator.
 void setZero()
          Sets the elements of this spatial vector to zero.
 int size()
          Returns the size of this spatial vector (which is always 6)
 java.lang.String toString(NumberFormat fmt)
          Returns a String representation of this vector, in which each element is formated using a C printf style as decribed by the parameter NumberFormat. When called numerous times, this routine can be more efficient than toString(String), because the NumberFormat does not need to be recreated each time from a specification string.
 void transform(RigidTransform3d X)
          Applies a rigid spatial transformation to this spatial vector, in place.
 void transform(RotationMatrix3d R)
          Applies a rotational transformation to this spatial vector, in place.
 
Methods inherited from class maspack.matrix.VectorObject
dot, epsilonEquals, equals, equals, get, isFixedSize, scan, set, setSize, toString, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

size

public int size()
Returns the size of this spatial vector (which is always 6)

Specified by:
size in class VectorObject
Returns:
6

isContravariant

public boolean isContravariant()
Returns true if this spatial vector is contravariant.

Returns:
true for contravariant vectors.

get

public double get(int i)
Gets a single element of this spatial vector. The element ordering depends on whether the vector is contravariant or covariant.

Specified by:
get in class VectorObject
Parameters:
i - element index
Returns:
element value throws ArrayIndexOutOfBoundsException if i is not in the range 0 to 5.

get

public void get(double[] values)
Copies the elements of this spatial vector into an array of doubles. The element ordering depends on whether the vector is contravariant or covariant.

Overrides:
get in class VectorObject
Parameters:
values - array into which values are copied

set

public void set(int i,
                double value)
Sets a single element of this spatial vector. The element ordering depends on whether the vector is contravariant or covariant.

Specified by:
set in class VectorObject
Parameters:
i - element index
value - element value
Returns:
element value throws ArrayIndexOutOfBoundsException if i is not in the range 0 to 5.

set

public void set(double[] values)
Sets the elements of this spatial vector from an array of doubles. The element ordering depends on whether the vector is contravariant or covariant.

Overrides:
set in class VectorObject
Parameters:
values - array from which values are copied

negate

public void negate()
Negates this spatial vector in place.


scale

public void scale(double s)
Scales the elements of this spatial vector by s.

Parameters:
s - scaling factor

norm

public double norm()
Returns the 2 norm of this spatial vector. This is the square root of the sum of the squares of the elements.

Overrides:
norm in class VectorObject
Returns:
vector 2 norm

normSquared

public double normSquared()
Returns the square of the 2 norm of this spatial vector. This is the sum of the squares of the elements.

Overrides:
normSquared in class VectorObject
Returns:
square of the 2 norm

maxElement

public double maxElement()
Returns the maximum element value of this spatial vector.

Overrides:
maxElement in class VectorObject
Returns:
maximal element

minElement

public double minElement()
Returns the minimum element value of this spatial vector.

Overrides:
minElement in class VectorObject
Returns:
minimal element

infinityNorm

public double infinityNorm()
Returns the infinity norm of this spatial vector. This is the maximum absolute value over all elements.

Overrides:
infinityNorm in class VectorObject
Returns:
vector infinity norm

oneNorm

public double oneNorm()
Returns the 1 norm of this spatial vector. This is the sum of the absolute values of the elements.

Overrides:
oneNorm in class VectorObject
Returns:
vector 1 norm

dot

public double dot(SpatialVector v1)
Returns the dot product of this spatial vector and the spatial vector v1.

Returns:
dot product

normalize

public void normalize()
Normalizes this spatial vector in place.


epsilonEquals

public boolean epsilonEquals(SpatialVector v1,
                             double eps)
Returns true if the elements of this spatial vector equal those of vector v1within a prescribed tolerance epsilon.

Parameters:
v1 - vector to compare with
eps - comparison tolerance
Returns:
false if the vectors are not equal within the specified tolerance

equals

public boolean equals(SpatialVector v1)
Returns true if the elements of this spatial vector exactly equal those of vector v1.

Parameters:
v1 - vector to compare with
Returns:
false if the vectors are not equal

setZero

public void setZero()
Sets the elements of this spatial vector to zero.


absolute

public void absolute()
Sets the elements of this spatial vector to their absolute values.


transform

public void transform(RotationMatrix3d R)
Applies a rotational transformation to this spatial vector, in place.

Parameters:
R - rotational transformation matrix

inverseTransform

public void inverseTransform(RotationMatrix3d R)
Applies an inverse rotational transformation to this spatial vector, in place.

Parameters:
R - rotational transformation matrix

transform

public void transform(RigidTransform3d X)
Applies a rigid spatial transformation to this spatial vector, in place.

Parameters:
X - rigid spatial transformation

inverseTransform

public void inverseTransform(RigidTransform3d X)
Applies an inverse rigid spatial transformation to this vector, in place.

Parameters:
X - rigid spatial transformation

toString

public java.lang.String toString(NumberFormat fmt)
Returns a String representation of this vector, in which each element is formated using a C printf style as decribed by the parameter NumberFormat. When called numerous times, this routine can be more efficient than toString(String), because the NumberFormat does not need to be recreated each time from a specification string.

Overrides:
toString in class VectorObject
Parameters:
fmt - numeric format
Returns:
String representation of this vector

setRandom

public void setRandom()
Sets the elements of this vector to uniformly distributed random values in the range -0.5 (inclusive) to 0.5 (exclusive).


setRandom

public void setRandom(double lower,
                      double upper)
Sets the elements of this vector to uniformly distributed random values in a specified range.

Parameters:
lower - lower random value (inclusive)
upper - upper random value (exclusive)

setRandom

public void setRandom(double lower,
                      double upper,
                      java.util.Random generator)
Sets the elements of this vector to uniformly distributed random values in a specified range, using a supplied random number generator.

Parameters:
lower - lower random value (inclusive)
upper - upper random value (exclusive)
generator - random number generator