jhplot.math
Class Vec
- java.lang.Object
-
- jhplot.math.Vec
-
public class Vec extends java.lang.Object
A small library to work with vectors defined by some dimension. Default is the dimension of Euclidean space (3).
-
-
Constructor Summary
Constructors Constructor and Description Vec()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static double[]
add(double[] a, double[] b)
Addition of two vectors.static double
dotProduct(double[] a, double[] b)
Dot product of two vectors.static double[]
drCharge(double[] rVector, double pull, int qa, int qb)
Returns radial unit vector times pull and -qa*qb.static double
magnitude(double[] a)
Returns the magnitude of this vector.static double[]
multiplay(double c, double[] a)
Vector times scalarstatic double[]
randomVector(double c)
make a random vector.static double[]
reflect(double[] rVector, double[] draVector, int s)
Reflection at the boundarystatic void
setDimension(int dimension)
Set dimention of vectors.static double[]
subtract(double[] a, double[] b)
Subtraction of two vectors.static double[]
unitVector(double[] a)
Returns the unit vector of this vector.
-
-
-
Method Detail
-
setDimension
public static void setDimension(int dimension)
Set dimention of vectors.- Parameters:
dimension
- dimension of the vectors.
-
randomVector
public static double[] randomVector(double c)
make a random vector.- Returns:
- Returns a random vector (initial conditions).
-
multiplay
public static double[] multiplay(double c, double[] a)
Vector times scalar
-
add
public static double[] add(double[] a, double[] b)
Addition of two vectors.
-
subtract
public static double[] subtract(double[] a, double[] b)
Subtraction of two vectors.
-
dotProduct
public static double dotProduct(double[] a, double[] b)
Dot product of two vectors.
-
magnitude
public static double magnitude(double[] a)
Returns the magnitude of this vector.
-
unitVector
public static double[] unitVector(double[] a)
Returns the unit vector of this vector.
-
reflect
public static double[] reflect(double[] rVector, double[] draVector, int s)
Reflection at the boundary
-
drCharge
public static double[] drCharge(double[] rVector, double pull, int qa, int qb)
Returns radial unit vector times pull and -qa*qb. (Charges)
-
-
DMelt 3.0 © DataMelt by jWork.ORG