Package org.opensourcephysics.numerics
Class Vec3D
java.lang.Object
org.opensourcephysics.numerics.Vec3D
A 3-element vector that is represented by double-precision floating point
x,y,z coordinates.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVec3D()
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.Constructs and initializes a Vector3d from the specified Vector3d. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Sets this vector to the vector addition of vectors v1 and v2.final double
Returns the angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].void
Sets this vector to the vector cross product of vectors v1 and v2.final double
Returns the dot product of this vector and vector v1.final double
Returns the magnitude of this vector.final double
Returns the squared magnitude of this vector.void
Sets this vector to the multiplication of vector v1 and a scalar numberfinal void
Normalizes this vector in place.final void
Sets this vector to the vector subtraction of vectors v1 and v2.
-
Field Details
-
x
public double x -
y
public double y -
z
public double z
-
-
Constructor Details
-
Vec3D
public Vec3D(double x, double y, double z) Constructs and initializes a Vector3d from the specified xyz coordinates.- Parameters:
x
- the x coordinatey
- the y coordinatez
- 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
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 Details
-
subtract
Sets this vector to the vector subtraction of vectors v1 and v2.- Parameters:
v1
- the first vectorv2
- the second vector
-
add
Sets this vector to the vector addition of vectors v1 and v2.- Parameters:
v1
- the first vectorv2
- the second vector
-
cross
Sets this vector to the vector cross product of vectors v1 and v2.- Parameters:
v1
- the first vectorv2
- the second vector
-
multiply
Sets this vector to the multiplication of vector v1 and a scalar number- Parameters:
v1
- the vectornumber
- to multiply v1
-
normalize
public final void normalize()Normalizes this vector in place. -
dot
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
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]
-