Package cnuphys.adaptiveSwim.geometry
Class Vector
java.lang.Object
cnuphys.adaptiveSwim.geometry.Point
cnuphys.adaptiveSwim.geometry.Vector
Ordinary 3D vector
- Author:
- heddle
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
angleBetween
(Vector a, Vector b) Compute the angle between two vectors in radiansstatic double
angleBetweenDeg
(Vector a, Vector b) Compute the angle between two vectors in degreesstatic Vector
The cross product of two vectorsstatic void
The in-place cross product of two vectorsstatic Vector
difference
(Vector a, Vector b) Get the difference between two vectorsstatic void
difference
(Vector a, Vector b, Vector c) Get the in-place difference between two vectorsdouble
length()
The length of the vectordouble
The square of the length of the vectorstatic Vector
project vector a in the direction of vector bvoid
scale
(double scaleFactor) Scale a vectorvoid
set
(double x, double y, double z) Set the components of the vectorGet a unit vector in the same direction as thisMethods inherited from class cnuphys.adaptiveSwim.geometry.Point
difference, difference, distance, distance, dot, dot, toString
-
Constructor Details
-
Vector
public Vector()Create a new vetor with a zero components -
Vector
Create a Vector from a point- Parameters:
p
- the point
-
Vector
public Vector(double x, double y, double z) Create a vector- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinate
-
-
Method Details
-
lengthSquared
public double lengthSquared()The square of the length of the vector- Returns:
- the square of the length of the vector
-
length
public double length()The length of the vector- Returns:
- the length of the vector
-
set
public void set(double x, double y, double z) Set the components of the vector -
cross
The cross product of two vectors- Parameters:
a
- one vectorb
- other vector- Returns:
- c = a x b
-
cross
The in-place cross product of two vectors- Parameters:
a
- one vectorb
- other vectorc
- on return c = a x b
-
scale
public void scale(double scaleFactor) Scale a vector- Parameters:
scaleFactor
- the scale factor
-
angleBetween
Compute the angle between two vectors in radians- Parameters:
a
- one vectorb
- the other vector- Returns:
- the angle between two vectors in radians
-
angleBetweenDeg
Compute the angle between two vectors in degrees- Parameters:
a
- one vectorb
- the other vector- Returns:
- the angle between two vectors in degrees
-
unitVector
Get a unit vector in the same direction as this- Returns:
- a unit vector
-
project
project vector a in the direction of vector b- Parameters:
a
- the vector to projectb
- the vector whose direction we project on- Returns:
- the projection of a
-
difference
Get the difference between two vectors- Parameters:
a
- one vectorb
- the other vector- Returns:
- the difference between two vectors a - b
-
difference
Get the in-place difference between two vectors- Parameters:
a
- one vectorb
- the other vectorc
- upon return the difference between two vectors a - b
-