org.opensourcephysics.numerics
Class Vec3D

java.lang.Object
  extended by org.opensourcephysics.numerics.Vec3D

public class Vec3D
extends java.lang.Object

A 3-element vector that is represented by double-precision floating point x,y,z coordinates.


Field Summary
 double x
           
 double y
           
 double z
           
 
Constructor Summary
Vec3D()
          Constructs and initializes it to (0,0,0).
Vec3D(double[] v)
          Constructs and initializes a Vector3d from the array of length 3.
Vec3D(double x, double y, double z)
          Constructs and initializes a Vector3d from the specified xyz coordinates.
Vec3D(Vec3D v1)
          Constructs and initializes a Vector3d from the specified Vector3d.
 
Method Summary
 void add(Vec3D v1, Vec3D v2)
          Sets this vector to the vector addition of vectors v1 and v2.
 double angle(Vec3D v1)
          Returns the angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].
 void cross(Vec3D v1, Vec3D v2)
          Sets this vector to the vector cross product of vectors v1 and v2.
 double dot(Vec3D v1)
          Returns the dot product of this vector and vector v1.
 double magnitude()
          Returns the magnitude of this vector.
 double magnitudeSquared()
          Returns the squared magnitude of this vector.
 void multiply(Vec3D v1, double number)
          Sets this vector to the multiplication of vector v1 and a scalar number
 void normalize()
          Normalizes this vector in place.
 void subtract(Vec3D v1, Vec3D v2)
          Sets this vector to the vector subtraction of vectors v1 and v2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public double x

y

public double y

z

public double z
Constructor Detail

Vec3D

public Vec3D(double x,
             double y,
             double z)
Constructs and initializes a Vector3d from the specified xyz coordinates.

Parameters:
x - the x coordinate
y - the y coordinate
z - the z coordinate

Vec3D

public Vec3D(double[] v)
Constructs and initializes a Vector3d from the array of length 3.

Parameters:
v - the array of length 3 containing xyz in order

Vec3D

public Vec3D(Vec3D v1)
Constructs and initializes a Vector3d from the specified Vector3d.

Parameters:
v1 - the Vector3d containing the initialization x y z data

Vec3D

public Vec3D()
Constructs and initializes it to (0,0,0).

Method Detail

subtract

public final void subtract(Vec3D v1,
                           Vec3D v2)
Sets this vector to the vector subtraction of vectors v1 and v2.

Parameters:
v1 - the first vector
v2 - the second vector

add

public final void add(Vec3D v1,
                      Vec3D v2)
Sets this vector to the vector addition of vectors v1 and v2.

Parameters:
v1 - the first vector
v2 - the second vector

cross

public void cross(Vec3D v1,
                  Vec3D v2)
Sets this vector to the vector cross product of vectors v1 and v2.

Parameters:
v1 - the first vector
v2 - the second vector

multiply

public void multiply(Vec3D v1,
                     double number)
Sets this vector to the multiplication of vector v1 and a scalar number

Parameters:
v1 - the vector
number - to multiply v1

normalize

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


dot

public final double dot(Vec3D v1)
Returns the dot product of this vector and vector v1.

Parameters:
v1 - the other vector
Returns:
the dot product of this and v1

magnitudeSquared

public final double magnitudeSquared()
Returns the squared magnitude of this vector.

Returns:
the squared magnitude

magnitude

public final double magnitude()
Returns the magnitude of this vector.

Returns:
the magnitude

angle

public final double angle(Vec3D v1)
Returns the angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].

Parameters:
v1 - the other vector
Returns:
the angle in radians in the range [0,PI]