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 doubleangleBetween(Vector a, Vector b) Compute the angle between two vectors in radiansstatic doubleangleBetweenDeg(Vector a, Vector b) Compute the angle between two vectors in degreesstatic VectorThe cross product of two vectorsstatic voidThe in-place cross product of two vectorsstatic Vectordifference(Vector a, Vector b) Get the difference between two vectorsstatic voiddifference(Vector a, Vector b, Vector c) Get the in-place difference between two vectorsdoublelength()The length of the vectordoubleThe square of the length of the vectorstatic Vectorproject vector a in the direction of vector bvoidscale(double scaleFactor) Scale a vectorvoidset(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
-