public class Vec3d
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Methods with names ending in "Local" modify the current instance. They are used to avoid creating temporary vectors.
The conventional order of components is (X, Y, Z).
| Modifier and Type | Field and Description |
|---|---|
static Vec3d |
UNIT_X
Shared instance of the +X direction (1,0,0).
|
static Vec3d |
UNIT_Y
Shared instance of the +Y direction (0,1,0).
|
static Vec3d |
UNIT_Z
Shared instance of the +Z direction (0,0,1).
|
double |
x
The first (X) component.
|
double |
y
The 2nd (Y) component.
|
double |
z
The 3rd (Z) component.
|
static Vec3d |
ZERO
Shared instance of the all-zero vector (0,0,0).
|
| Constructor and Description |
|---|
Vec3d()
Instantiates an all-zero vector (0,0,0).
|
Vec3d(double x,
double y,
double z)
Instantiates a vector with the specified components.
|
Vec3d(Vec3d v)
Instantiates a copy of the argument.
|
Vec3d(Vec3i v) |
Vec3d(com.jme3.math.Vector3f v)
Instantiates a double-precision copy of the argument.
|
| Modifier and Type | Method and Description |
|---|---|
Vec3d |
add(double vx,
double vy,
double vz)
Adds specified amounts to the vector's components and returns the sum as
a new instance.
|
Vec3d |
add(Vec3d v)
Adds the argument and returns the sum as a new instance.
|
Vec3d |
add(Vec3i v) |
Vec3d |
addLocal(double vx,
double vy,
double vz)
Adds specified amounts to the vector's components and returns the
(modified) current instance.
|
Vec3d |
addLocal(Vec3d v)
Adds the argument and returns the (modified) current instance.
|
Vec3d |
addLocal(Vec3i v)
Adds the Vec3i argument and returns the (modified) current instance.
|
Vec3d |
addScaledVectorLocal(Vec3d toAdd,
double scale) |
Vec3i |
ceil()
Returns the Math.ceil() version of this Vec3d as a Vec3i.
|
Vec3d |
clone()
Creates a copy.
|
Vec3d |
cross(double vx,
double vy,
double vz) |
Vec3d |
cross(Vec3d v)
Calculates a cross product with the argument and returns the product as a
new instance.
|
Vec3d |
crossLocal(Vec3d v) |
double |
distance(double vx,
double vy,
double vz) |
double |
distance(Vec3d v) |
double |
distanceSq(double vx,
double vy,
double vz) |
double |
distanceSq(Vec3d v) |
double |
distanceSq(Vec3i v) |
Vec3d |
divide(double s)
Divides by the scalar argument and returns the quotient as a new
instance.
|
Vec3d |
divide(Vec3d v)
Divides component-wise by the argument and returns the quotient as a
new instance.
|
Vec3d |
divide(Vec3i v) |
Vec3d |
divideLocal(double s)
Divides by the argument and returns the (modified) current instance.
|
Vec3d |
divideLocal(Vec3d v)
Divides component-wise by the argument and returns the (modified) current
instance.
|
double |
dot(double vx,
double vy,
double vz) |
double |
dot(Vec3d v)
Returns the dot (or inner) product with the argument.
|
double |
dot(Vec3i v) |
boolean |
equals(java.lang.Object o)
Tests for exact equality with the argument, distinguishing -0 from 0.
|
Vec3i |
floor()
Returns the Math.floor() version of this Vec3d as a Vec3i.
|
double |
get(int i)
Returns the indexed component.
|
int |
hashCode()
Returns a hash code.
|
Vec3d |
interpolateLocal(Vec3d start,
Vec3d end,
double mix)
Sets the value of this Vec3d to be the linearly interpolated
value of start and end using the mix value as the 0 to 1 position
between start and end.
|
boolean |
isFinite()
Tests for finite components.
|
boolean |
isNaN()
Returns true if any of the x,y,z elements are NaN.
|
boolean |
isSimilar(Vec3d other,
double epsilon)
Returns true if this Vec3d is similar to the specified Vec3d within
some value of epsilon.
|
double |
length()
Returns the length (or magnitude).
|
double |
lengthSq()
Returns the square of the length.
|
Vec3d |
maxLocal(Vec3d v) |
Vec3d |
minLocal(Vec3d v) |
Vec3d |
mult(double s)
Multiplies with the scalar argument and returns the product as a new
instance.
|
Vec3d |
mult(Vec3d v)
Multiplies component-wise with the argument and returns the product as a
new instance.
|
Vec3d |
mult(Vec3i v) |
Vec3d |
multLocal(double s)
Multiplies by the scalar argument and returns the (modified) current
instance.
|
Vec3d |
multLocal(Vec3d v)
Multiplies component-wise by the argument and returns the (modified)
current instance.
|
Vec3d |
multLocal(Vec3i v) |
Vec3d |
normalize() |
Vec3d |
normalizeLocal()
Normalize this vector in place.
|
Vec3d |
set(double x,
double y,
double z)
Sets all 3 components to specified values.
|
Vec3d |
set(int i,
double d)
Alters the indexed component.
|
Vec3d |
set(Vec3d v)
Copies all 3 components from the argument.
|
Vec3d |
set(Vec3i v) |
Vec3d |
set(com.jme3.math.Vector3f v)
Copies all 3 components from the argument, converting them to
double precision.
|
Vec3d |
subtract(double vx,
double vy,
double vz)
Subtracts specified amounts from the vector's components and returns the
difference as a new instance.
|
Vec3d |
subtract(Vec3d v)
Subtracts the argument and returns the difference as a new instance.
|
Vec3d |
subtract(Vec3i v) |
Vec3d |
subtractLocal(double vx,
double vy,
double vz)
Subtracts the specified amounts from the vector's components and returns
the (modified) current instance.
|
Vec3d |
subtractLocal(Vec3d v)
Subtracts the argument and returns the (modified) current instance.
|
Vec3d |
subtractLocal(Vec3i v) |
java.lang.String |
toString()
Returns a string representation of the vector, which is unaffected.
|
Vec3i |
toVec3i()
Returns the raw (int) cast version of this Vec3d as a Vec3i.
|
com.jme3.math.Vector3f |
toVector3f()
Creates a single-precision copy of the current instance.
|
Vec3d |
xzy() |
Vec3d |
zeroEpsilon(double e) |
public static final Vec3d UNIT_X
public static final Vec3d UNIT_Y
public static final Vec3d UNIT_Z
public static final Vec3d ZERO
public double x
public double y
public double z
public Vec3d()
public Vec3d(double x,
double y,
double z)
x - the desired X componenty - the desired Y componentz - the desired Z componentpublic Vec3d(Vec3d v)
v - the Vec3d to copy (not null, unaffected)public Vec3d(Vec3i v)
public Vec3d(com.jme3.math.Vector3f v)
v - the input Vector3f (not null, unaffected)public com.jme3.math.Vector3f toVector3f()
public boolean isNaN()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
o is null, false is returned. Either way, the current instance is
unaffected.equals in class java.lang.Objecto - the object to compare (may be null, unaffected)this and o have identical values,
otherwise falsepublic boolean isSimilar(Vec3d other, double epsilon)
other - the Vec3d to compare (may be null, unaffected)epsilon - the tolerance for comparisonpublic boolean isFinite()
public final Vec3d set(double x, double y, double z)
x - the desired X componenty - the desired Y componentz - the desired Z componentpublic final Vec3d set(Vec3d v)
v - the Vec3d to copy (not null, unaffected)public final Vec3d set(com.jme3.math.Vector3f v)
v - the Vector3f to copy (not null, unaffected)public final Vec3i toVec3i()
public final Vec3i floor()
public final Vec3i ceil()
public final Vec3d clone()
clone in class java.lang.Objectpublic double get(int i)
i - 0, 1, or 2java.lang.IndexOutOfBoundsException - if i is not 0, 1, or 2public Vec3d set(int i, double d)
i - which component to set: 0 → the X component, 1 →
the Y component, 2 → the Z componentd - the desired component valuejava.lang.IllegalArgumentException - if i is not 0, 1, or 2public final Vec3d add(Vec3d v)
v - the vector to add (not null, unaffected)public final Vec3d add(double vx, double vy, double vz)
vx - the amount to add to the X componentvy - the amount to add to the Y componentvz - the amount to add to the Z componentpublic final Vec3d subtract(Vec3d v)
v - the vector to subtract (not null, unaffected)public final Vec3d subtract(double vx, double vy, double vz)
vx - the amount to add to the X componentvy - the amount to add to the Y componentvz - the amount to add to the Z componentpublic final Vec3d mult(double s)
s - the scaling factorpublic final Vec3d mult(Vec3d v)
v - the scale vector (not null, unaffected)public final Vec3d divide(double s)
s - the divisorpublic final Vec3d divide(Vec3d v)
v - the inverse scale vector (not null, unaffected)public final Vec3d addLocal(Vec3d v)
It IS safe for v and this to be the same object.
v - the vector to add (not null, unaffected unless it's
this)public final Vec3d addLocal(Vec3i v)
v - the vector to add (not null, unaffected)public final Vec3d addLocal(double vx, double vy, double vz)
vx - the amount to add to the X componentvy - the amount to add to the Y componentvz - the amount to add to the Z componentpublic final Vec3d subtractLocal(Vec3d v)
It IS safe for v and this to be the same object.
v - the vector to subtract (not null, unaffected unless it's
this)public final Vec3d subtractLocal(double vx, double vy, double vz)
vx - the amount to subtract from the X componentvy - the amount to subtract from the Y componentvz - the amount to subtract from the Z componentpublic final Vec3d multLocal(double s)
s - the scaling factorpublic final Vec3d multLocal(Vec3d v)
It IS safe for v and this to be the same object.
v - the scale vector (not null, unaffected unless it's this)public final Vec3d divideLocal(double s)
s - the divisorpublic final Vec3d divideLocal(Vec3d v)
It IS safe for v and this to be the same object.
v - the divisor (not null, unaffected unless it's this)public final double lengthSq()
public final double length()
public final double distanceSq(Vec3d v)
public final double distanceSq(Vec3i v)
public final double distance(Vec3d v)
public final double distanceSq(double vx,
double vy,
double vz)
public final double distance(double vx,
double vy,
double vz)
public final Vec3d normalize()
public final Vec3d normalizeLocal()
public final double dot(Vec3d v)
v - the vector to multiply (not null, unaffected)public final double dot(Vec3i v)
public final double dot(double vx,
double vy,
double vz)
public final Vec3d cross(Vec3d v)
v - the right factor (not null, unaffected)this cross v (a new Vec3d)public final Vec3d cross(double vx, double vy, double vz)
public final Vec3d zeroEpsilon(double e)
public final Vec3d interpolateLocal(Vec3d start, Vec3d end, double mix)
public final Vec3d xzy()
public java.lang.String toString()
Vec3d[1.0, 0.0, 0.0]
toString in class java.lang.Object