Package uk.ac.starlink.dpac.epoch

# Class GVector3d

java.lang.Object
uk.ac.starlink.dpac.epoch.GVector3d

public class GVector3d extends Object
Class representing a three-dimensional vector in Eucledian space. The space is spanned by a right-handed, orthonormal triad designated [X, Y, Z] in the following.

The class suppors all the usual methods to perform conventional vector arithmetics such as vector and dot product.

Version:
  $Id: GVector3d.java 359256 2014-04-07 17:09:18Z hsiddiqu $
Author:
  aolias

## Constructor Summary

Constructors
Constructor
Description
`GVector3d()`
Constructs and initializes a `GVector3d` to `(0, 0, 0)`
`GVector3d(double s)`
Constructs and initializes a `GVector3d` to the tuple `(s, s, s)`.
`GVector3d(double[] v)`
Constructs and initializes a `GVector3d` from the first 3 elements of a given double array.
`GVector3d(double x, double y, double z)`
Constructs and initializes a `GVector3d` from a specified `(x, y, z)` tuple.
`GVector3d(GVector3d v)`
The copy constructor - constructs a new `GVector3d` from a given one by copying all elements.

## Method Summary

Modifier and Type
Method
Description
`GVector3d`
`add(double r)`
Adds a scalar `r` to all coordinates of the vector, i.e., `this = this + (r, r, r)`.
`GVector3d`
`add(GVector3d v)`
Adds another vector `v` to this one, i.e.
`static GVector3d`
`add(GVector3d v, GVector3d w)`
Adds two vectors and return the result a new one.
`GVector3d`
`cross(GVector3d vec)`
Sets this vector to the outer product of itself and a second vector `v`, i.e.
`static GVector3d`
`cross(GVector3d v, GVector3d w)`
Calculates the outer product of two given vectors `v` and `w` and returns the result as a new `GVector3d`.
`double`
`dot(GVector3d v)`
Calculates the dot product of this and another given vector.
`double`
`getX()`
`double`
`getY()`
`double`
`getZ()`
`static GVector3d[]`
`localTriad(double alpha, double delta)`
Computes the normal triad [p q r] at spherical coordinates `(alpha, delta)`
`GVector3d`
`scale(double s)`
Scales the vector by a scalar `s`, i.e.
`static GVector3d`
`scale(double s, GVector3d v)`
Constructs new vector from scaling a given one.
`GVector3d`
`scaleAdd(double s, GVector3d v)`
Scales a given vector with a scalar and add the result to this one, i.e.
`static GVector3d`
`scaleAdd(GVector3d v1, double s, GVector3d v2)`
Constructs new vector as sum of a given vector `v1` and a scaled vector `s*v2`.
`GVector3d`
`set(double x, double y, double z)`
Sets the elements of this vector to given 3-tuple.
`double`
`x()`
Identical to `getX()`
`double`
`y()`
Identical to `getY()`
`double`
`z()`
Identical to `getZ()`

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

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

## Constructor Details

### GVector3d

public GVector3d()
Constructs and initializes a `GVector3d` to `(0, 0, 0)`

### GVector3d

public GVector3d(double s)
Constructs and initializes a `GVector3d` to the tuple `(s, s, s)`.

Parameters:
  `s` - double value to be assigned to all components

### GVector3d

public GVector3d(double[] v) throws IllegalArgumentException
Constructs and initializes a `GVector3d` from the first 3 elements of a given double array.

Parameters:
  `v` - array of length >=3 to initialize this vector from
Throws:
  `IllegalArgumentException` - if input array has less than three elements

### GVector3d

public GVector3d(double x, double y, double z)
Constructs and initializes a `GVector3d` from a specified `(x, y, z)` tuple.

Parameters:
  `x` - `x` coordinate
  `y` - `y` coordinate
  `z` - `z` coordinate

### GVector3d

public GVector3d(GVector3d v)
The copy constructor - constructs a new `GVector3d` from a given one by copying all elements.

Parameters:
  `v` - Vector to set this object to

## Method Details

### set

public GVector3d set(double x, double y, double z)
Sets the elements of this vector to given 3-tuple.

Parameters:
  `x` - new value of the `X` coordinate
  `y` - new value of the `Y` coordinate
  `z` - new value of the `Z` coordinate
Returns:
  GVector3d

### getX

public double getX()

Returns:
  `X` coordinate value of this vector

### getY

public double getY()

Returns:
  `Y` coordinate value of this vector

### getZ

public double getZ()

Returns:
  `Z` coordinate value of this vector

### x

public double x()
Identical to `getX()`

Returns:
  double

### y

public double y()
Identical to `getY()`

Returns:
  double

### z

public double z()
Identical to `getZ()`

Returns:
  double

### localTriad

public static GVector3d[] localTriad(double alpha, double delta)
Computes the normal triad [p q r] at spherical coordinates `(alpha, delta)`

Parameters:
  `alpha` - longitude [rad] (0<=alpha<2 Pi)
  `delta` - latitude [rad] (-Pi/2<=delta<=Pi/2)
Returns:
  computed normal trid as three element array 0: unit vector in the direction of increasing `alpha` 1: unit vector in the direction of increasing `delta` 2: unit vector towards the point `(alpha, delta)`

### add

public GVector3d add(double r)
Adds a scalar `r` to all coordinates of the vector, i.e., `this = this + (r, r, r)`.

Parameters:
  `r` - scalar to add to all coordinates
Returns:
  vector modified in place

### add

public GVector3d add(GVector3d v)
Adds another vector `v` to this one, i.e. `this = this + v`.

Parameters:
  `v` - vector to add
Returns:
  vector modified in place

### add

public static GVector3d add(GVector3d v, GVector3d w)
Adds two vectors and return the result a new one.

Parameters:
  `v` - first operand
  `w` - second operand
Returns:
  sum of `v` and `w`

### cross

public GVector3d cross(GVector3d vec)
Sets this vector to the outer product of itself and a second vector `v`, i.e. `this = this x v`

Parameters:
  `vec` - vector with which to build the outer product
Returns:
  vector modified in place

### cross

public static GVector3d cross(GVector3d v, GVector3d w)
Calculates the outer product of two given vectors `v` and `w` and returns the result as a new `GVector3d`.

Parameters:
  `v` - left operand
  `w` - right operand
Returns:
  outer product of `v` and `w`

### dot

public double dot(GVector3d v)
Calculates the dot product of this and another given vector.

Parameters:
  `v` - vector to build the dot product with
Returns:
  dot product of this vector and `v`

### scale

public GVector3d scale(double s)
Scales the vector by a scalar `s`, i.e. `this = s*this`

Parameters:
  `s` - scalar to scale the vector with
Returns:
  vector modified in place

### scale

public static GVector3d scale(double s, GVector3d v)
Constructs new vector from scaling a given one.

Parameters:
  `s` - scalar scaling factor
  `v` - vector to scale
Returns:
  product of `s` and `v` as a new `GVector3d`

### scaleAdd

public GVector3d scaleAdd(double s, GVector3d v)
Scales a given vector with a scalar and add the result to this one, i.e. `this = this + s*v`.

Parameters:
  `s` - scalar scaling factor
  `v` - vector to scale
Returns:
  vector modified in place

### scaleAdd

public static GVector3d scaleAdd(GVector3d v1, double s, GVector3d v2)
Constructs new vector as sum of a given vector `v1` and a scaled vector `s*v2`.

Parameters:
  `v1` - first vector
  `s` - scalar scaling factor
  `v2` - second vector
Returns:
  new vector set to `v1+s*v2`