public class Vec3 extends Object
Modifier and Type | Field and Description |
---|---|
static Vec3 |
DOWN
a unit vector pointing down
|
static Vec3 |
EAST
a unit vector pointing east
|
static Vec3 |
NORTH
a unit vector pointing north
|
static Vec3 |
ORIGIN
the origin vector (zero along each axis)
|
double |
x
the x component of the vector
|
double |
y
the y component of the vector
|
double |
z
the z component of the vector
|
Constructor and Description |
---|
Vec3(double x,
double y,
double z)
Creates a vector with the specified components.
|
Modifier and Type | Method and Description |
---|---|
Vec3 |
addDecRad(double angle)
Returns a new vector equal to this vector with the specified angle added
to the declination.
|
Vec3 |
addIncRad(double angle)
Returns a new vector equal to this vector with the specified angle added
to the inclination.
|
double |
angleTo(Vec3 v)
Returns the signed angle between this vector and another vector.
|
Vec3 |
correctForm(double az,
double dip)
Applies a sample correction to this vector.
|
Vec3 |
correctSample(double az,
double dip)
Applies a sample correction to this vector.
|
Vec3 |
cross(Vec3 v)
Returns the cross product of this vector and another vector.
|
double |
distance(Vec3 v)
Returns the distance between two vectors.
|
Vec3 |
divideBy(double a)
Divides this vector by a scalar value.
|
Vec3 |
divideBy(Vec3 v)
Divides the components of this vector individually by the corresponding
components of another vector.
|
double |
dot(Vec3 v)
Returns the dot product of this vector and another vector.
|
boolean |
equals(Object o) |
boolean |
equals(Vec3 v,
double precision)
Compares vectors for equality to a specified precision.
|
static Vec3 |
equatorPoint(Vec3 v0,
Vec3 v1)
Returns the unit vector on the intersection of the equator (z=0 line)
and the great circle between the supplied points.
|
static Vec3 |
fromPolarDegrees(double mag,
double inc,
double dec)
Creates a vector from a polar specification in degrees.
|
static Vec3 |
fromPolarRadians(double mag,
double inc,
double dec)
Creates a vector from a polar specification in radians.
|
double |
getComponent(MeasurementAxis component)
Returns a specified component of this vector.
|
double |
getDecDeg()
Returns this vector's declination in degrees.
|
double |
getDecRad()
Returns this vector's declination in radians.
|
double |
getDipDeg()
Returns the strike of the plane normal this vector
|
static double[][] |
getFormationCorrectionMatrix(double az,
double dip)
Returns a matrix to correct a vector for a given formation orientation.
|
double |
getIncDeg()
Returns this vector's inclination in degrees.
|
double |
getIncRad()
Returns this vector's inclination in radians.
|
static double[][] |
getSampleCorrectionMatrix(double az,
double dip)
Returns a matrix to correct a vector for a given sample orientation.
|
double |
getStrikeDeg()
Returns the strike of the plane normal to this vector
|
static double[][] |
getZRotationMatrix(double angle)
Returns a matrix for a rotation about the z axis.
|
List<Vec3> |
greatCirclePoints(int n,
boolean closed)
Returns a list of equally spaced points around a great circle having this
vector as its pole.
|
int |
hashCode() |
static List<List<Vec3>> |
interpolateEquatorPoints(List<Vec3> vs)
Given a list of points, return a list of lists containing the same points
plus possible extras.
|
Vec3 |
invert()
Returns the inverse of this vector.
|
boolean |
isFinite()
Checks that this vector contains no NaN or infinite values.
|
double |
mag()
Returns the magnitude of this vector.
|
static List<Vec3> |
makeEllipse(KentParams kentParams)
Returns a list of points outlining the confidence ellipse for a supplied
set of Kent statistical parameters.
|
List<Vec3> |
makeSmallCircle(double radiusDegrees)
Returns a list of vectors defining a small circle around this vector's
direction.
|
static Vec3 |
mean(Collection<Vec3> vectors)
Returns the mean of a collection of vectors.
|
static Vec3 |
meanDirection(Collection<Vec3> points)
Returns the mean direction of a collection of unit vectors.
|
Vec3 |
minus(Vec3 v)
Subtracts another vector from this vector.
|
Vec3 |
nearestOnCircle(Vec3 v)
Using the enclosing vector to define the pole of a great circle G, this
method accepts another unit vector v and returns the nearest unit vector
to v which lies on G.
|
Vec3 |
normalize()
Normalizes this vector.
|
Jama.Matrix |
oTensor()
Returns the orientation tensor of this vector.
|
Vec3 |
plus(Vec3 v)
Adds this vector and another vector.
|
Vec3 |
rot180(MeasurementAxis axis)
Rotates the vector by 180 degrees about the specified axis.
|
Vec3 |
rotY(double angle)
Rotates this vector about the y axis.
|
Vec3 |
rotZ(double angle)
Rotates this vector about the z axis.
|
boolean |
sameHemisphere(Vec3 v)
Returns true if and only if the supplied vector is in the same
(upper/lower) hemisphere as this one.
|
Vec3 |
setX(double newX)
Sets the x component of this vector.
|
Vec3 |
setY(double newY)
Sets the y component of this vector.
|
Vec3 |
setZ(double newZ)
Sets the z component of this vector.
|
static List<Vec3> |
spherInterpDir(Vec3 v0,
Vec3 v1,
Vec3 onPath,
double stepSize)
Interpolates a great-circle path in a chosen direction between two
specified vectors.
|
static List<Vec3> |
spherInterpolate(Vec3 v0,
Vec3 v1,
double stepSize)
Given two vectors, interpolates unit vectors along a great-circle path
between them.
|
static Vec3 |
sum(Collection<Vec3> vectors)
Returns the sum of a specified collection of vectors.
|
Vec3 |
times(double a)
Multiplies this vector by a scalar value.
|
Vec3 |
times(Vec3 v)
Multiplies the components of this vector individually by the
corresponding components of another vector.
|
String |
toString()
Returns a string representation of this vector.
|
Vec3 |
transform(double[][] matrix)
Multiplies this vector by a supplied matrix.
|
public final double x
public final double y
public final double z
public static final Vec3 ORIGIN
public static final Vec3 NORTH
public static final Vec3 EAST
public static final Vec3 DOWN
public Vec3(double x, double y, double z)
x
- the x component of the new vectory
- the y component of the new vectorz
- the z component of the new vectorpublic Vec3 addDecRad(double angle)
angle
- the angle in radians to add to the declination
(must be finite)public Vec3 addIncRad(double angle)
angle
- the angle in radians to add to the inclination
(must be finite)public Vec3 rot180(MeasurementAxis axis)
axis
- the axis about which to rotatepublic static Vec3 equatorPoint(Vec3 v0, Vec3 v1)
v0
- a non-null, finite vector specifying a directionv1
- a non-null, finite vector specifying a directionv
for which v.z==0
, which lies
on the shortest great-circle path between the normalizations of
v0
and v1
public boolean sameHemisphere(Vec3 v)
v
- a non-null, finite vectortrue
if and only if the supplied vector is in the same
(upper/lower) hemisphere as this one.IllegalArgumentException
- if v
is not finiteNullPointerException
- if v
is nullpublic static List<List<Vec3>> interpolateEquatorPoints(List<Vec3> vs)
vs
- a list of vectors specifying directionsvs
; none of the sub-lists crosses the equatorpublic static List<Vec3> spherInterpolate(Vec3 v0, Vec3 v1, double stepSize)
v0
- a non-null, non-zero, finite vectorv1
- a non-null, non-zero, finite vectorstepSize
- the step size for interpolation in radians, in the range
(0, 2*PI)v0
and v1
NullPointerException
- if either of the input vectors is nullIllegalArgumentException
- if any of the arguments are outside the
specified rangespublic static List<Vec3> spherInterpDir(Vec3 v0, Vec3 v1, Vec3 onPath, double stepSize)
onPath
.
The supplied step size is only used as a guideline; the actual step size
may at certain positions drop to 0 (i.e. a point is repeated) or increase
to as much as 1.8*stepSize.v0
- a non-null, non-zero, finite vector giving the first
end-point of the arcv1
- a non-null, non-zero, finite vector giving the second
end-point of the arconPath
- a non-null, non-zero, finite vector indicating the
direction of the arcstepSize
- approximate size of interpolation step in radians,
in the range (0, 2*PI)v0
and v1
, passing as close as possible to onPath
public Vec3 rotY(double angle)
angle
- a finite angle in radiansangle
radians
about the y axispublic Vec3 rotZ(double angle)
rotZ(π/2)
called on the eastward-pointing
vector (0, 1, 0) would produce the southward-pointing vector (-1, 0, 0).angle
- a finite angle in radiansangle
radians
about the z axispublic static double[][] getZRotationMatrix(double angle)
getZRotationMatrix(π/2)
applied to the eastward-pointing vector (0, 1, 0) would produce
the southward-pointing vector (-1, 0, 0).angle
- a finite angle in radiansangle
radians about the z axispublic static double[][] getSampleCorrectionMatrix(double az, double dip)
az
- the sample dip azimuth in radians (must be finite)dip
- the sample dip angle in radians (must be finite)public Vec3 correctSample(double az, double dip)
az
- the sample dip azimuth in radians (must be finite)dip
- the sample dip angle in radians (must be finite)public Vec3 correctForm(double az, double dip)
az
- the formation dip azimuth in radians (must be finite)dip
- the formation dip angle in radians (must be finite)public List<Vec3> greatCirclePoints(int n, boolean closed)
n
- number of points to return (must be >0)closed
- if true, first point will also be appended to end of list,
giving n+1 points, but only n unique ones, creating a closed circle.public static double[][] getFormationCorrectionMatrix(double az, double dip)
az
- the formation dip azimuth in radians (must be finite)dip
- the formation dip angle in radians (must be finite)public Vec3 transform(double[][] matrix)
matrix
- a three-by-three matrixpublic Vec3 nearestOnCircle(Vec3 v)
v
- a unit vectorpublic Vec3 normalize()
public double getComponent(MeasurementAxis component)
component
- the component to returnpublic double mag()
public Vec3 plus(Vec3 v)
v
- a vectorv
public Vec3 minus(Vec3 v)
v
- a vectorv
public Vec3 times(double a)
a
- a numbera
public Vec3 times(Vec3 v)
v
- a vector(this.x*v.x,
this.y*v.y, this.z*v.z)
public Vec3 divideBy(double a)
a
- a numbera
public Vec3 divideBy(Vec3 v)
v
- a vector(this.x/v.x,
this.y/v.y, this.z/v.z)
public double dot(Vec3 v)
v
- a vectorv
public Vec3 cross(Vec3 v)
v
- a vectorv
public Vec3 invert()
public Jama.Matrix oTensor()
public double angleTo(Vec3 v)
v
- a vectorv
, in radianspublic static Vec3 fromPolarDegrees(double mag, double inc, double dec)
mag
- magnitude for the new vectorinc
- inclination for the new vector, in degreesdec
- declination for the new vector, in degreespublic static Vec3 fromPolarRadians(double mag, double inc, double dec)
mag
- magnitude for the new vectorinc
- inclination for the new vector, in radiansdec
- declination for the new vector, in radianspublic double getIncRad()
public double getDecRad()
public double getIncDeg()
public double getDecDeg()
public double getStrikeDeg()
public double getDipDeg()
public static Vec3 sum(Collection<Vec3> vectors)
vectors
- a collections of vectorspublic static Vec3 meanDirection(Collection<Vec3> points)
points
- a collection of unit vectorspoints
public static Vec3 mean(Collection<Vec3> vectors)
vectors
- a collections of vectorspublic Vec3 setX(double newX)
newX
- the new value for the x componentpublic Vec3 setY(double newY)
newY
- the new value for the y componentpublic Vec3 setZ(double newZ)
newZ
- the new value for the z componentpublic List<Vec3> makeSmallCircle(double radiusDegrees)
radiusDegrees
- the radius of the desired circle, in degreespublic static List<Vec3> makeEllipse(KentParams kentParams)
kentParams
- a non-null set of Kent parameterspublic String toString()
public boolean isFinite()
public double distance(Vec3 v)
v
- a non-null, finite vector with which to compare this onev
public boolean equals(Vec3 v, double precision)
true
if they are
sufficiently close. "Sufficiently close" is defined by a supplied
precision parameter: for the method to return true
, the distance
between the vectors must be less than precision * max(m1, m2)
where m1
and m2
are the lengths of the two vectors.v
- a non-null, finite vector with which to compare this oneprecision
- a finite, non-negative precision parameter for the
comparisontrue
iff the vectors are equal to within the specified
precisionCopyright © 2022. All rights reserved.