@NotThreadSafe
public class RX
extends java.lang.Object
3D rigid transform representation and computations.
The translation component of the transform is represented as a simple
translation vector (tx
, ty
, tz
). There are no
internal constraints on the translation value.
The rotation component is represented both as a unit quaternion (qx
, qy
, qz
, qw
) with (qx
, qy
,
qz
) the vector part and qw
the scalar part and as an
exponential map vector (ex
, ey
, ez
). Several
invariants are maintained:
qw
is non-negativeMutating operations typically return a reference to the mutated object.
This class is not internally synchronized.
Copyright (C) 2007 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Modifier and Type | Class and Description |
---|---|
static class |
RX.Test
Unit tests, invoked by
main(java.lang.String[]) . |
Modifier and Type | Field and Description |
---|---|
protected static java.util.List<TimeMetrics> |
allMetrics
collection of all metrics, if enabled
|
protected static TimeMetrics |
canonicalizeEMMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
consMetrics
metrics for indicated function, if enabled
|
private static java.lang.String |
cvsid |
static double |
DEF_DEMDQ_H
default perturbation magnitude for numeric partial derivative
|
static double |
DEF_DQDEM_H
default perturbation magnitude for numeric partial derivative
|
static double |
DEF_DRDEM_H
default perturbation magnitude for numeric partial derivative
|
static double |
DEF_DRDQ_H
default perturbation magnitude for numeric partial derivative
|
static double |
DEF_RANDOM_ROTATION_RANGE
default random rotation magnitude
|
static double |
DEF_RANDOM_TRANSLATION_RANGE
default random translation magnitude
|
protected static TimeMetrics |
dEMdQAnalyticMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
dEMdQNumericMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
dQdEMAnalyticMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
dQdEMNumericMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
dRdEMAnalyticMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
dRdEMFromdRdQAnddQdEMMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
dRdEMNumericMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
dRdQAnalyticMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
dRdQNumericMetrics
metrics for indicated function, if enabled
|
protected boolean |
eDirty
rotation representation dirty flag
|
static java.lang.String[] |
EM_COMPONENT_NAME
EM vector component names
|
static boolean |
ENABLE_METRICS
enable or disable metrics collection
|
protected static TimeMetrics |
epsilonEqualsMetrics
metrics for indicated function, if enabled
|
protected double |
ex
EM component, initially (0, 0, 0)
|
static int |
EX
EM component in a TXEM vector
|
protected double |
ey
EM component, initially (0, 0, 0)
|
static int |
EY
EM component in a TXEM vector
|
protected double |
ez
EM component, initially (0, 0, 0)
|
static int |
EZ
EM component in a TXEM vector
|
static java.lang.String |
FMT
decimal printf format
|
static java.lang.String |
FMT_S
string printf format same width as
FMT |
static int |
FMT_WIDTH
field width for
FMT |
static java.lang.String |
FMT3
decimal format string for 3 vector
|
static java.lang.String |
FMT4
decimal format string for 4 vector
|
protected static TimeMetrics |
fromMatrixMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
fromScrewMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
getRotMatrixMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
invertMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
isIdentityMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
normalizeQuaternionMetrics
metrics for indicated function, if enabled
|
protected boolean |
qDirty
rotation representation dirty flag
|
static java.lang.String[] |
QUATERNION_COMPONENT_NAME
Quaternion vector component names
|
protected double |
qw
Quaternion component, initialized to (0, 0, 0, 1), the identity
rotation.
|
protected double |
qx
Quaternion component, initialized to (0, 0, 0, 1), the identity
rotation.
|
protected double |
qy
Quaternion component, initialized to (0, 0, 0, 1), the identity
rotation.
|
protected double |
qz
Quaternion component, initialized to (0, 0, 0, 1), the identity
rotation.
|
protected static TimeMetrics |
randomizeMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
rotateTMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
rotateV3FloatMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
rotateV3Metrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
screwInterpMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
toMatrixMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
transformV3FloatMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
transformV3Metrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
translateV3FloatMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
translateV3Metrics
metrics for indicated function, if enabled
|
static double |
TWO_PI
2*PI
|
double |
tx
translation component, initially (0, 0, 0)
|
static int |
TX
TX component in a TXEM vector
|
static java.lang.String[] |
TX_COMPONENT_NAME
TX vector component names
|
static java.lang.String[] |
TXEM_COMPONENT_NAME
TXEM vector component names
|
double |
ty
translation component, initially (0, 0, 0)
|
static int |
TY
TX component in a TXEM vector
|
double |
tz
translation component, initially (0, 0, 0)
|
static int |
TZ
TX component in a TXEM vector
|
protected static TimeMetrics |
updateEMMetrics
metrics for indicated function, if enabled
|
protected static TimeMetrics |
updateQuaternionMetrics
metrics for indicated function, if enabled
|
static int |
W
Component in a vector.
|
static int |
X
Component in a vector.
|
protected static TimeMetrics |
xPendEitherMetrics
metrics for indicated function, if enabled
|
static int |
Y
Component in a vector.
|
static int |
Z
Component in a vector.
|
Modifier | Constructor and Description |
---|---|
protected |
RX()
use
cons() to make a new RX |
Modifier and Type | Method and Description |
---|---|
RX |
aim(double... d)
Set the rotation component such that (0, 0, 1) is transformed to be
parallel to d.
|
RX |
append(RX other)
covers
xPendEither(vona.math.RX, boolean, boolean) , always appends without inversion |
RX |
appendEither(RX other,
boolean invert)
covers
xPendEither(vona.math.RX, boolean, boolean) , always appends |
RX |
appendInverse(RX other)
covers
xPendEither(vona.math.RX, boolean, boolean) , always appends inverse |
protected double |
canonicalizeEM()
Canonicalize the EM rep to a magnitude (i.e.
|
protected boolean |
canonicalizeQuaternion()
Ensure that
qw is positive, flipping the quaternion if
necessary. |
protected double |
clamp(double value,
double min,
double max)
clamps value to [min, max], ignoring NaN
|
boolean |
clampEM(double[] min,
double[] max)
Covers
clampEM(int, double[], int, double[], boolean) , starts
at 0 and always checks aliases. |
boolean |
clampEM(double[] min,
double[] max,
boolean checkAliases)
Covers
clampEM(int, double[], int, double[], boolean) , starts
at 0. |
boolean |
clampEM(int minStart,
double[] min,
int maxStart,
double[] max,
boolean checkAliases)
Clamps the exponential map vector to the given min and
max, ignoring NaN limits.
|
boolean |
clampTranslation(int minStart,
double[] min,
int maxStart,
double[] max)
Clamps the translation vector to the given min and max
vectors, ignoring NaN limits.
|
static RX |
cons()
make a new identity rigid transform
|
static RX |
consFromMatrix(double[] m)
covers
fromMatrix(double[]) , conses a new RX |
static RX |
consFromXYO(double[] x,
double[] y,
double[] o)
Covers
consFromXYO(double[], double[], double[]) , conses a new
RX . |
static RX |
consRandom()
covers
randomize() , conses a new RX |
static RX |
consRandom(double translationRange,
double rotationRange)
Covers
randomize(double, double) conses a new RX . |
double[][] |
dEMdQAnalytic()
covers
dEMdQAnalytic(double[][]) , conses. |
double[][] |
dEMdQAnalytic(double[][] dEMdQ)
Similar to
dEMdQNumeric(double[][], double) but uses
analytic formulas instead of numeric perturbation. |
double[][] |
dEMdQNumeric()
covers
dEMdQNumeric(double[][], double) , conses with
DEF_DEMDQ_H . |
double[][] |
dEMdQNumeric(double h)
covers
dEMdQNumeric(double[][], double) , conses. |
double[][] |
dEMdQNumeric(double[][] dEMdQ)
covers
dEMdQNumeric(double[][], double) with DEF_DEMDQ_H . |
double[][] |
dEMdQNumeric(double[][] dEMdQ,
double h)
Computes partial derivatives of exponential map components with respect
to quaternion components, at the current state of this RX, based on
numeric perturbation.
|
double[][] |
dQdEMAnalytic()
covers
dQdEMAnalytic(double[][]) , conses |
double[][] |
dQdEMAnalytic(double[][] dQdEM)
Similar to
dQdEMNumeric(double[][], double) but uses analytic
formulas instead of numeric perturbation. |
double[][] |
dQdEMNumeric()
covers
dQdEMNumeric(double[][], double) , conses with DEF_DQDEM_H . |
double[][] |
dQdEMNumeric(double h)
covers
dQdEMNumeric(double[][], double) , conses. |
double[][] |
dQdEMNumeric(double[][] dQdEM)
covers
dQdEMNumeric(double[][], double) with DEF_DQDEM_H . |
double[][] |
dQdEMNumeric(double[][] dQdEM,
double h)
Computes partial derivatives of quaternion components with respect to
exponential map components, at the current state of this RX, based on
numeric perturbation.
|
double[][] |
dRdEMAnalytic()
Covers
dRdEMAnalytic(double[][], double[][], double[][]) ,
conses. |
double[][] |
dRdEMAnalytic(double[][] dRdEM)
Covers
dRdEMAnalytic(double[][], double[][], double[][]) ,
conses dRdQ and dQdEM. |
double[][] |
dRdEMAnalytic(double[][] dRdEM,
double[][] dRdQ,
double[][] dQdEM)
Similar to
dRdEMNumeric(double[][], double) but uses
analytic formulas instead of numeric perturbation. |
double[][] |
dRdEMFromdRdQAnddQdEM(double[][] dRdEM,
double[][] dRdQ,
double[][] dQdEM)
Compute dRdEM by multiplying a given dRdQ and dQdEM.
|
double[][] |
dRdEMNumeric()
covers
dRdEMNumeric(double[][], double) , conses with
DEF_DRDEM_H . |
double[][] |
dRdEMNumeric(double h)
Covers
dRdEMNumeric(double[][], double) , conses. |
double[][] |
dRdEMNumeric(double[][] dRdEM)
Covers
dRdEMNumeric(double[][], double) with DEF_DRDEM_H . |
double[][] |
dRdEMNumeric(double[][] dRdEM,
double h)
Like
dRdQNumeric(double[][], double) but computes derivative
with respect to the EM vector. |
double[][] |
dRdQAnalytic()
covers
dRdQAnalytic(double[][]) , conses. |
double[][] |
dRdQAnalytic(double[][] dRdQ)
Similar to
dRdQNumeric(double[][], double) but uses
analytic formulas instead of numeric perturbation. |
double[][] |
dRdQNumeric()
covers
dRdQNumeric(double[][], double) , conses with
DEF_DRDQ_H . |
double[][] |
dRdQNumeric(double h)
Covers
dRdQNumeric(double[][], double) , conses. |
double[][] |
dRdQNumeric(double[][] dRdQ)
Covers
dRdQNumeric(double[][], double) with DEF_DRDQ_H . |
double[][] |
dRdQNumeric(double[][] dRdQ,
double h)
Computes partial derivatives of rotation matrix components with respect
to quaternion components, at the current state of this RX, based on
numeric perturbation.
|
void |
dump()
covers
dump(PrintStream, String) , to System.out, no msg |
void |
dump(java.io.PrintStream s)
covers
dump(PrintStream, String) , no msg |
void |
dump(java.io.PrintStream s,
java.lang.String msg)
dump(PrintStream, String, boolean) , no newline |
void |
dump(java.io.PrintStream s,
java.lang.String msg,
boolean newline)
dump to human-readable to stream s
|
void |
dump(java.lang.String msg)
covers
dump(PrintStream, String) , to System.out |
static void |
dumpColMatrix(double[][] m)
Covers
dumpColMatrix(PrintStream, double[][], String) , to
System.out, no msg. |
static void |
dumpColMatrix(java.io.PrintStream s,
double[][] m)
Covers
dumpColMatrix(PrintStream, double[][], String) , no
msg. |
static void |
dumpColMatrix(java.io.PrintStream s,
double[][] m,
java.lang.String msg)
Dump all of column-major matrix m human-readable to stream
s.
|
static void |
dumpMatrix(double[] m)
Covers
dumpMatrix(PrintStream, double[], String) , to
System.out, no msg. |
static void |
dumpMatrix(java.io.PrintStream s,
double[] m)
covers
dumpMatrix(PrintStream, double[], String) , no msg |
static void |
dumpMatrix(java.io.PrintStream s,
double[] m,
java.lang.String msg)
dump all of 4x4 matrix m human-readable to stream s
|
static void |
dumpRotMatrix(double[] m)
Covers
dumpRotMatrix(PrintStream, double[], String) , to
System.out, no msg. |
static void |
dumpRotMatrix(java.io.PrintStream s,
double[] m)
covers
dumpRotMatrix(PrintStream, double[], String) , no msg |
static void |
dumpRotMatrix(java.io.PrintStream s,
double[] m,
java.lang.String msg)
dump all of 3x3 matrix m human-readable to stream s
|
static void |
dumpScrew(double... screw)
Covers
dumpScrew(PrintStream, String, double...) , to
System.out, no msg. |
static void |
dumpScrew(java.io.PrintStream s,
double... screw)
covers
dumpScrew(PrintStream, String, double...) , no msg |
static void |
dumpScrew(java.io.PrintStream s,
java.lang.String msg,
double... screw)
Covers
dumpScrew(PrintStream, String, int, double...) , starts
at 0. |
static void |
dumpScrew(java.io.PrintStream str,
java.lang.String msg,
double[] p,
double[] d,
double[] s)
Covers
dumpScrew(PrintStream, String, int, double[], int,
double[], int, double[]) , starts at 0. |
static void |
dumpScrew(java.io.PrintStream s,
java.lang.String msg,
int start,
double... screw)
Covers
dumpScrew(PrintStream, String, int, double[], int,
double[], int, double[]) , with the three component vectors packed in
order. |
static void |
dumpScrew(java.io.PrintStream str,
java.lang.String msg,
int pStart,
double[] p,
int dStart,
double[] d,
int sStart,
double[] s)
Dump a screw human-readable to stream s.
|
static void |
dumpSquareTensor(double[][] m)
Covers
dumpSquareTensor(PrintStream, double[][], String) , to
System.out, no msg. |
static void |
dumpSquareTensor(java.io.PrintStream s,
double[][] m)
Covers
dumpSquareTensor(PrintStream, double[][], String) , no
msg. |
static void |
dumpSquareTensor(java.io.PrintStream s,
double[][] m,
java.lang.String msg)
Dump all of a tensor of row-major square matrices m
human-readable to stream s.
|
static void |
dumpStats()
covers
dumpStats(java.io.PrintStream) , to System.out |
static void |
dumpStats(java.io.PrintStream s)
dump all metrics, if enabled
|
void |
dumpTXEM(java.io.PrintStream s)
dump the TXEM vector of this RX
|
static void |
dumpTXEM(java.io.PrintStream s,
double[] txem)
covers
dumpTXEM(PrintStream, int, double[]) , starts at 0 |
static void |
dumpTXEM(java.io.PrintStream s,
double tx,
double ty,
double tz,
double ex,
double ey,
double ez)
dump the indicated TXEM vector
|
static void |
dumpTXEM(java.io.PrintStream s,
int start,
double[] txem)
dump the indicated TXEM vector
|
RX |
dup()
convenience to
cons() and set(vona.math.RX) |
static RX |
dup(RX rx)
convenience to
cons() and set(vona.math.RX) |
boolean |
epsilonEquals(RX other)
covers
epsilonEquals(RX, double) , uses VonaMath.DP2R |
boolean |
epsilonEquals(RX other,
double eps)
check if this RX is effectively equal to other
|
boolean |
epsilonEqualsDBG(RX other)
covers
epsilonEqualsDBG(RX, double) w/ VonaMath.DP2R |
boolean |
epsilonEqualsDBG(RX other,
double eps)
show info about a failing equality
|
boolean |
equals(java.lang.Object other)
defers to
epsilonEquals(vona.math.RX, double) unless other == this |
RX |
fromMatrix(double[] m)
Set all components from row-major 16-element matrix m.
|
RX |
fromScrew(double... screw)
covers
fromScrew(int, double...) with start 0 |
RX |
fromScrew(double[] p,
double[] d,
double[] s)
Covers
fromScrew(int, double[], int, double[], int, double[]) ,
with all starts 0. |
RX |
fromScrew(double t,
double d,
double px,
double py,
double pz,
double dx,
double dy,
double dz)
Set to ccw right-hand rotation of t radians about axis through
(px, py, pz) in direction of vector (dx, dy, dz), combined
with translation d in that direction.
|
RX |
fromScrew(int start,
double... screw)
Covers
fromScrew(int, double[], int, double[], int, double[]) ,
with the three component vectors packed in order. |
RX |
fromScrew(int pStart,
double[] p,
int dStart,
double[] d,
int sStart,
double[] s)
|
RX |
fromXYO(double[] x,
double[] y,
double[] o)
Covers
fromMatrix(double[]) , builds the matrix given vectors
along the local frame x and y axes and the local frame origin. |
double[] |
gatherFromTXEM(int[] txemIndices,
int start,
double[] value)
Covers
gatherFromTXEM(int[], int, double[], int, double[], int,
double[]) , always uses canonical EM vector. |
double[] |
gatherFromTXEM(int[] txemIndices,
int start,
double[] value,
int minStart,
double[] min,
int maxStart,
double[] max)
complimentary to
scatterToTXEM(int[], int, double...) . |
double[] |
gatherShortestTXEMTo(RX other,
int[] txemIndices,
int start,
double[] value)
Gather a difference vector which, when added to the indicated TXEM
vector indices of this RX, will make those components equal to the
corresponding components of other, using either its current EM
vector with twist t or the corresponding anti-parallel
non-canonical EM vector with twist t-2pi, whichever is closer to
the current em vector of this RX.
|
double[] |
gatherTXEMTo(RX other,
int[] txemIndices,
int start,
double[] value)
Gather a difference vector which, when added to the indicated TXEM
vector indices of this RX, will make those components equal to the
corresponding components of other.
|
double[] |
getEM()
covers
getEM(int, double[]) , always conses |
double[] |
getEM(double[] e)
covers
getEM(int, double[]) , starts at 0 |
double[] |
getEM(int start,
double[] e)
Get the rotation as an EM vector canonicalized to a magnitude of at
most PI.
|
double |
getMaxTXEMComponentDiff(RX other)
Get the largest abs TXEM component difference between this RX and
other.
|
double[] |
getQuaternion()
covers
getQuaternion(int, double[]) , always conses |
double[] |
getQuaternion(double[] q)
covers
getQuaternion(int, double[]) , starts at 0 |
double[] |
getQuaternion(int start,
double[] q)
|
double |
getQuaternionComponent(int index)
complimentary to
setQuaternionComponent(int, double) |
double[] |
getRotMatrix()
covers
getRotMatrix(double[]) , conses the matrix |
double[] |
getRotMatrix(double[] m)
Set row-major 9-element matrix m from the rotation component of
this
RX (i.e. |
double[] |
getShortestTXEMTo(RX other,
int start,
double[] value)
Covers
gatherShortestTXEMTo(RX, int[], int, double[]) , gets
all six TXEM vector components in order. |
double[] |
getTranslation()
covers
getTranslation(int, double[]) , always conses |
double[] |
getTranslation(double[] t)
covers
getTranslation(int, double[]) , starts at 0 |
double[] |
getTranslation(int start,
double[] t)
get the translation
|
double |
getTwist()
get the RH twist angle about the current rotation axis in radians
|
double[] |
getTXEM()
getTXEM(int, double...) starting at 0 and consing |
double[] |
getTXEM(double[] txem)
getTXEM(int, double...) starting at 0 |
double[] |
getTXEM(int start,
double[] txem)
getTranslation(int, double[]) and getEM(int, double[]) to a packed vector. |
double |
getTXEMComponent(int index)
complimentary to
setTXEMComponent(int, double) |
double[] |
getTXEMTo(RX other,
int start,
double[] value)
Covers
gatherTXEMTo(RX, int[], int, double[]) , gets
all six TXEM vector components in order. |
protected boolean |
inEMLimits(int minStart,
double[] min,
int maxStart,
double[] max)
Check if the EM vector of this RX is within the specified limits.
|
void |
interpolateEM(double u)
Same as
interpolateEM(double, RX, RX) with from
identity and to aliasing this RX. |
void |
interpolateEM(double u,
RX to)
Covers
interpolateEM(double, RX, RX) with from
aliasing this RX. |
void |
interpolateEM(double u,
RX from,
RX to)
Linearly interpolate the rotation component of this RX between the
rotation component of from and the rotation component of to
in EM space.
|
RX |
interpolateTranslation(double u)
Covers
interpolateTranslation(double, RX, RX) with from
identity and to aliasing this RX. |
RX |
interpolateTranslation(double u,
RX to)
Covers
interpolateTranslation(double, RX, RX) with from
aliasing this RX. |
RX |
interpolateTranslation(double u,
RX from,
RX to)
Linearly interpolate the translation component of this RX between the
translation component of from and the translation component of
to.
|
void |
interpolateTXEM(double u)
Same as
interpolateTXEM(double, double[], double[]) with
from identity and to aliasing this RX. |
void |
interpolateTXEM(double u,
double[] to)
Same as
interpolateTXEM(double, double[], double[]) with
from aliasing this RX. |
void |
interpolateTXEM(double u,
double[] from,
double[] to)
Linearly interpolate the translation and EM rotation components of this
RX between from and to in TXEM space.
|
void |
interpolateTXEM(double u,
double ftx,
double fty,
double ftz,
double fex,
double fey,
double fez,
double ttx,
double tty,
double ttz,
double tex,
double tey,
double tez)
|
void |
interpolateTXEM(double u,
RX to)
Same as
interpolateTXEM(double, RX, RX) with from
aliasing this RX. |
void |
interpolateTXEM(double u,
RX from,
RX to)
|
RX |
invert()
invert in-place
|
boolean |
isIdentity()
check if this RX is effectively the identity transform
|
boolean |
isPureRotation()
|
boolean |
isPureRotation(double tol)
check if this RX is effectively a pure rotation
|
boolean |
isPureTranslation()
|
boolean |
isPureTranslation(double tol)
check if this RX is effectively a pure translation
|
static void |
main(java.lang.String[] arg)
conses and invokes a
RX.Test |
protected static TimeMetrics |
makeMetrics(java.lang.String name)
Make a metrics object with the given name and add it to
allMetrics , iff ENABLE_METRICS . |
protected void |
normalizeQuaternion()
(re) normalize the quaternion rep
|
RX |
prepend(RX other)
covers
xPendEither(vona.math.RX, boolean, boolean) , always prepends without inversion |
RX |
prependEither(RX other,
boolean invert)
covers
xPendEither(vona.math.RX, boolean, boolean) , always prepends |
RX |
prependInverse(RX other)
covers
xPendEither(vona.math.RX, boolean, boolean) , always prepends inverse |
RX |
randomize()
|
RX |
randomize(double translationRange,
double rotationRange)
Set this RX to a random transform.
|
static void |
resetStats()
reset all metrics, if enabled
|
void |
rotateT()
Covers
rotateT(double, double, double, double) , uses current
rotation quaternion of this RX, which will be updated if dirty. |
void |
rotateT(double qx,
double qy,
double qz,
double qw)
Rotate the current translation vector of this RX in-place by the unit
quaternion (qx, qy, qz, qw) with vector component (qx, qy,
qz) and scalar component qw.
|
double[] |
rotateV3(boolean invert,
double... v)
Covers
rotateV3(boolean, int, double...) with start =
0. |
float[] |
rotateV3(boolean invert,
float... v)
covers
rotateV3(double...) |
double[] |
rotateV3(boolean invert,
int start,
double... v)
Rotate 3D vector v.
|
float[] |
rotateV3(boolean invert,
int start,
float... v)
similar to
rotateV3(boolean, int, double...) |
double[] |
rotateV3(double... v)
Covers
rotateV3(boolean, int, double...) , never inverts,
start = 0. |
float[] |
rotateV3(float... v)
covers
rotateV3(double...) |
double[] |
rotateV3(int start,
double... v)
Covers
rotateV3(boolean, int, double...) , never inverts. |
float[] |
rotateV3(int start,
float... v)
covers
rotateV3(int, double...) |
RX |
rotAxis(double t,
double dx,
double dy,
double dz)
Set to right-hand rotation of t radians about an axis through
the origin in the direction of vector (dx, dy, dz).
|
RX |
rotAxis(double t,
double px,
double py,
double pz,
double dx,
double dy,
double dz)
Set to right-hand rotation of t radians about axis through
(px, py, pz) in direction of vector (dx, dy, dz).
|
RX |
rotAxis(double t,
int pStart,
double[] p,
int dStart,
double[] d)
|
RX |
rotX(double t)
Set to right-hand rotation of t radians about positive x
axis.
|
RX |
rotY(double t)
Set to right-hand rotation of t radians about positive y
axis.
|
RX |
rotZ(double t)
Set to right-hand rotation of t radians about positive z
axis.
|
RX |
scaleTranslation(double scale)
scale the translation vector without modifying the rotation
|
boolean |
scatterToTXEM(int[] txemIndices,
int start,
double... value)
setTXEMComponent(int, double) for each index in txemIndices, in
order. |
boolean |
scatterToTXEM(int[] txemIndices,
RX other)
Like
scatterToTXEM(int[], int, double...) but takes source
values from other. |
RX |
screwInterp(double u)
Covers
screwInterp(double, int, double[], int, double[], int,
double[]) with no optional outputs. |
RX |
screwInterp(double u,
double[] screw)
covers
screwInterp(double, int, double[]) , starts at 0 |
RX |
screwInterp(double u,
double[] c,
double[] d,
double[] s)
Covers
screwInterp(double, int, double[], int, double[], int,
double[]) with zero start indices for optional outputs. |
RX |
screwInterp(double u,
int start,
double[] screw)
Covers
screwInterp(double, int, double[], int, double[], int,
double[]) , with the three component vectors packed in order. |
RX |
screwInterp(double u,
int cStart,
double[] c,
int dStart,
double[] d,
int sStart,
double[] s)
Replace this RX by a transform that produces a keyframe at along the
right-handed screw motion taking the identity transform to the current
value of this
RX . |
RX |
set(RX rx)
set all components from rx
|
RX |
setEither(RX rx,
boolean invert)
convenience to
set(vona.math.RX) and possibly invert() |
RX |
setEM(double... e)
covers
setEM(int, double...) , starts at 0 |
RX |
setEM(double x,
double y,
double z)
Set the rotation as an EM vector without modifying the translation.
|
RX |
setEM(int start,
double... e)
|
RX |
setIdentity()
set to identity
|
RX |
setIdentityRotation()
set rotation to identity, leave translation unchanged
|
RX |
setIdentityTranslation()
set translation to identity, leave rotation unchanged
|
RX |
setInverse(RX rx)
convenience to
set(vona.math.RX) and invert() |
RX |
setQuaternion(double... q)
covers
setQuaternion(int, double...) , starts at 0 |
RX |
setQuaternion(double x,
double y,
double z,
double w)
Set the rotation as a quaternion without modifying the translation.
|
RX |
setQuaternion(int start,
double... q)
|
boolean |
setQuaternionComponent(int index,
double value)
Set one quaternion component.
|
RX |
setToEM(double... e)
covers
setToEM(int, double...) , starts at index 0 |
RX |
setToEM(double x,
double y,
double z)
Set to a rotation given as an EM vector.
|
RX |
setToEM(int start,
double... e)
|
RX |
setToQuaternion(double... q)
covers
setToQuaternion(int, double...) , starts at index 0 |
RX |
setToQuaternion(double x,
double y,
double z,
double w)
Set to a quaternion.
|
RX |
setToQuaternion(int start,
double... q)
|
RX |
setToTranslation(double... t)
covers
setToTranslation(int, double...) , starts at index 0 |
RX |
setToTranslation(double x,
double y,
double z)
Set to a translation.
|
RX |
setToTranslation(int start,
double... t)
|
RX |
setTranslation(double... t)
covers
setTranslation(int, double...) , starts at 0 |
RX |
setTranslation(double x,
double y,
double z)
set the translation without modifying the rotation
|
RX |
setTranslation(int start,
double... t)
|
RX |
setTXEM(double... txem)
setTXEM(int, double...) starting at 0 |
RX |
setTXEM(int start,
double... txem)
setTranslation(double, double, double) and setEM(double, double, double) from a packed vector. |
boolean |
setTXEMComponent(int index,
double value)
Set one component of a virtual packed vector composed of the internal
translation and exponential map vectors in that order.
|
protected static double |
sign(double v)
like signum but returns +1 for v == 0
|
double[] |
toMatrix()
covers
toMatrix(double[]) , conses the matrix |
double[] |
toMatrix(double[] m)
Set row-major 16-element matrix m from this
RX (i.e. |
double[] |
toScrew()
covers
toScrew(double[]) , always conses |
double[] |
toScrew(double[] screw)
covers
toScrew(int, double[]) , starts at 0 |
void |
toScrew(double[] c,
double[] d,
double[] s)
Covers
screwInterp(double, int, double[], int, double[], int,
double[]) with u 1.0 and zero start indices for optional
outputs. |
double[] |
toScrew(int start,
double[] screw)
Covers
toScrew(int, double[], int, double[], int, double[]) ,
with the three component vectors packed in order. |
void |
toScrew(int cStart,
double[] c,
int dStart,
double[] d,
int sStart,
double[] s)
Covers
screwInterp(double, int, double[], int, double[], int,
double[]) with u 1.0. |
java.lang.String |
toString()
toString(String) , no msg |
java.lang.String |
toString(java.lang.String msg)
dump(PrintStream, String, boolean) , no newline, to String |
double[] |
transformV3(boolean invert,
double... v)
Covers
transformV3(boolean, int, double...) with start =
0. |
float[] |
transformV3(boolean invert,
float... v)
|
double[] |
transformV3(boolean invert,
int start,
double... v)
Transform 3D vector v.
|
float[] |
transformV3(boolean invert,
int start,
float... v)
|
double[] |
transformV3(double... v)
Covers
transformV3(boolean, int, double...) , start = 0,
never inverts. |
float[] |
transformV3(float... v)
covers
transformV3(double...) |
double[] |
transformV3(int start,
double... v)
Covers
transformV3(boolean, int, double...) , never inverts. |
float[] |
transformV3(int start,
float... v)
covers
transformV3(int, double...) |
double[] |
translateV3(boolean invert,
double... v)
Covers
translateV3(boolean, int, double...) , with start
= 0. |
float[] |
translateV3(boolean invert,
float... v)
|
double[] |
translateV3(boolean invert,
int start,
double... v)
Translate 3D vector v.
|
float[] |
translateV3(boolean invert,
int start,
float... v)
similar to
translateV3(boolean, int, double...) |
double[] |
translateV3(double... v)
Covers
translateV3(boolean, int, double...) , never inverts,
start = 0. |
float[] |
translateV3(float... v)
covers
translateV3(double...) |
double[] |
translateV3(int start,
double... v)
Covers
translateV3(boolean, int, double...) , never inverts. |
float[] |
translateV3(int start,
float... v)
covers
translateV3(int, double...) |
boolean |
txemComponentEpsilonEquals(double[] txem,
int index)
|
boolean |
txemComponentEpsilonEquals(double[] txem,
int index,
double eps)
Compare an individual TXEM component.
|
static boolean |
txemComponentEpsilonEquals(double v1,
double v2,
int index)
|
static boolean |
txemComponentEpsilonEquals(double v1,
double v2,
int index,
double eps)
Compare an individual TXEM component value.
|
boolean |
txemComponentEpsilonEquals(double value,
int index)
|
boolean |
txemComponentEpsilonEquals(double value,
int index,
double eps)
Compare an individual TXEM component value.
|
boolean |
txemComponentEpsilonEquals(RX other,
int index)
Covers
txemComponentEpsilonEquals(RX, int, double) , uses
VonaMath.DP2R . |
boolean |
txemComponentEpsilonEquals(RX other,
int index,
double eps)
Like
txemComponentEpsilonEquals(double[], int, double) ,
compare to other . |
protected double |
updateEM()
covers
updateEM(boolean) , always canonical |
protected double |
updateEM(boolean canonicalize)
Compute the log map to update the EM rep from the current value of the
quaternion rep.
|
protected double |
updateQuaternion()
covers
updateQuaternion(boolean) , not nearest |
protected double |
updateQuaternion(boolean nearest)
Compute the exponential map to update the quaternion rep from the
current value of the EM rep.
|
RX |
xPendEither(RX other,
boolean invert,
boolean prepend)
Prepend or append other, optionally inverting other
first.
|
private static final java.lang.String cvsid
public static final double DEF_DQDEM_H
public static final double DEF_DEMDQ_H
public static final double DEF_DRDQ_H
public static final double DEF_DRDEM_H
public static final double TWO_PI
public static final double DEF_RANDOM_TRANSLATION_RANGE
public static final double DEF_RANDOM_ROTATION_RANGE
public static final int FMT_WIDTH
FMT
public static final java.lang.String FMT
public static final java.lang.String FMT_S
FMT
public static final java.lang.String FMT3
public static final java.lang.String FMT4
public static final int X
Component in a vector.
For a quaternion, W
is the scalar part, and it comes last so
that 2 and 3 vectors can start with X
.
public static final int Y
Component in a vector.
For a quaternion, W
is the scalar part, and it comes last so
that 2 and 3 vectors can start with X
.
public static final int Z
Component in a vector.
For a quaternion, W
is the scalar part, and it comes last so
that 2 and 3 vectors can start with X
.
public static final int W
Component in a vector.
For a quaternion, W
is the scalar part, and it comes last so
that 2 and 3 vectors can start with X
.
public static final int TX
public static final int TY
public static final int TZ
public static final int EX
public static final int EY
public static final int EZ
public static final java.lang.String[] TX_COMPONENT_NAME
public static final java.lang.String[] EM_COMPONENT_NAME
public static final java.lang.String[] QUATERNION_COMPONENT_NAME
public static final java.lang.String[] TXEM_COMPONENT_NAME
public double tx
public double ty
public double tz
protected double qx
Quaternion component, initialized to (0, 0, 0, 1), the identity rotation.
protected double qy
Quaternion component, initialized to (0, 0, 0, 1), the identity rotation.
protected double qz
Quaternion component, initialized to (0, 0, 0, 1), the identity rotation.
protected double qw
Quaternion component, initialized to (0, 0, 0, 1), the identity rotation.
protected double ex
protected double ey
protected double ez
protected boolean qDirty
protected boolean eDirty
public static final boolean ENABLE_METRICS
protected static final java.util.List<TimeMetrics> allMetrics
protected static final TimeMetrics consMetrics
protected static final TimeMetrics toMatrixMetrics
protected static final TimeMetrics fromMatrixMetrics
protected static final TimeMetrics getRotMatrixMetrics
protected static final TimeMetrics fromScrewMetrics
protected static final TimeMetrics screwInterpMetrics
protected static final TimeMetrics xPendEitherMetrics
protected static final TimeMetrics invertMetrics
protected static final TimeMetrics epsilonEqualsMetrics
protected static final TimeMetrics isIdentityMetrics
protected static final TimeMetrics transformV3Metrics
protected static final TimeMetrics rotateV3Metrics
protected static final TimeMetrics translateV3Metrics
protected static final TimeMetrics transformV3FloatMetrics
protected static final TimeMetrics rotateV3FloatMetrics
protected static final TimeMetrics translateV3FloatMetrics
protected static final TimeMetrics randomizeMetrics
protected static final TimeMetrics rotateTMetrics
protected static final TimeMetrics normalizeQuaternionMetrics
protected static final TimeMetrics canonicalizeEMMetrics
protected static final TimeMetrics updateQuaternionMetrics
protected static final TimeMetrics updateEMMetrics
protected static final TimeMetrics dQdEMNumericMetrics
protected static final TimeMetrics dQdEMAnalyticMetrics
protected static final TimeMetrics dEMdQNumericMetrics
protected static final TimeMetrics dEMdQAnalyticMetrics
protected static final TimeMetrics dRdQNumericMetrics
protected static final TimeMetrics dRdQAnalyticMetrics
protected static final TimeMetrics dRdEMNumericMetrics
protected static final TimeMetrics dRdEMAnalyticMetrics
protected static final TimeMetrics dRdEMFromdRdQAnddQdEMMetrics
protected RX()
cons()
to make a new RXprotected static TimeMetrics makeMetrics(java.lang.String name)
Make a metrics object with the given name and add it to allMetrics
, iff ENABLE_METRICS
.
public static RX cons()
public static RX dup(RX rx)
cons()
and set(vona.math.RX)
public RX dup()
cons()
and set(vona.math.RX)
public RX setIdentity()
public RX setIdentityTranslation()
public RX setIdentityRotation()
public RX setInverse(RX rx)
set(vona.math.RX)
and invert()
public RX setEither(RX rx, boolean invert)
set(vona.math.RX)
and possibly invert()
public RX setTranslation(double x, double y, double z)
public RX setTranslation(int start, double... t)
public RX setTranslation(double... t)
setTranslation(int, double...)
, starts at 0public RX setToTranslation(double x, double y, double z)
Set to a translation.
The rotation is set to identity.
public RX setToTranslation(int start, double... t)
public RX setToTranslation(double... t)
setToTranslation(int, double...)
, starts at index 0public RX scaleTranslation(double scale)
public boolean clampTranslation(int minStart, double[] min, int maxStart, double[] max)
Clamps the translation vector to the given min and max vectors, ignoring NaN limits.
protected double clamp(double value, double min, double max)
public double[] getTranslation(int start, double[] t)
public double[] getTranslation(double[] t)
getTranslation(int, double[])
, starts at 0public double[] getTranslation()
getTranslation(int, double[])
, always consespublic RX setQuaternion(double x, double y, double z, double w)
Set the rotation as a quaternion without modifying the translation.
The supplied quaternion will be internally normalized and canonicalized (i.e. if w is negative the quat will be flipped). The vector component is (x, y, z) and the scalar component is w. The quaternion (0, 0, 0, 0) is set as if it were the identity rotation (0, 0, 0, 1).
public RX setQuaternion(int start, double... q)
public RX setQuaternion(double... q)
setQuaternion(int, double...)
, starts at 0public RX setToQuaternion(double x, double y, double z, double w)
Set to a quaternion.
The translation is set to identity.
The supplied quaternion will be internally normalized and canonicalized (i.e. if w is negative the quat will be flipped).
public RX setToQuaternion(int start, double... q)
public RX setToQuaternion(double... q)
setToQuaternion(int, double...)
, starts at index 0public double[] getQuaternion(int start, double[] q)
public double[] getQuaternion(double[] q)
getQuaternion(int, double[])
, starts at 0public double[] getQuaternion()
getQuaternion(int, double[])
, always consespublic boolean setQuaternionComponent(int index, double value)
Set one quaternion component.
If the component is changed the quaternion will be re-normalized and re-canonicalized.
public double getQuaternionComponent(int index)
setQuaternionComponent(int, double)
public RX setEM(double x, double y, double z)
Set the rotation as an EM vector without modifying the translation.
The supplied EM vector will be internally canonicalized to a magnitude of at most PI.
public RX setEM(int start, double... e)
public RX setEM(double... e)
setEM(int, double...)
, starts at 0public RX setToEM(double x, double y, double z)
Set to a rotation given as an EM vector.
The translation is set to identity.
The supplied EM vector will be internally canonicalized to a magnitude of at most PI.
public RX setToEM(int start, double... e)
public RX setToEM(double... e)
setToEM(int, double...)
, starts at index 0public RX rotX(double t)
Set to right-hand rotation of t radians about positive x axis.
This is a convenience cover of setToEM(double, double, double)
.
public RX rotY(double t)
Set to right-hand rotation of t radians about positive y axis.
This is a convenience cover of setToEM(double, double, double)
.
public RX rotZ(double t)
Set to right-hand rotation of t radians about positive z axis.
This is a convenience cover of setToEM(double, double, double)
.
public RX rotAxis(double t, double dx, double dy, double dz)
Set to right-hand rotation of t radians about an axis through the origin in the direction of vector (dx, dy, dz).
The vector (dx, dy, dz) will be normalized internally.
This is a convenience cover of setToEM(double, double, double)
.
public RX rotAxis(double t, double px, double py, double pz, double dx, double dy, double dz)
Set to right-hand rotation of t radians about axis through (px, py, pz) in direction of vector (dx, dy, dz).
The vector (dx, dy, dz) will be normalized internally.
Sets the translation and both rotation representations.
public RX rotAxis(double t, int pStart, double[] p, int dStart, double[] d)
public RX aim(double... d)
Set the rotation component such that (0, 0, 1) is transformed to be parallel to d.
The translation component is not modified.
public boolean clampEM(int minStart, double[] min, int maxStart, double[] max, boolean checkAliases)
Clamps the exponential map vector to the given min and max, ignoring NaN limits.
The vector is canonicalized to a maximum magnitude of PI iff any changes are made.
public boolean clampEM(double[] min, double[] max, boolean checkAliases)
Covers clampEM(int, double[], int, double[], boolean)
, starts
at 0.
public boolean clampEM(double[] min, double[] max)
Covers clampEM(int, double[], int, double[], boolean)
, starts
at 0 and always checks aliases.
public double[] getEM(int start, double[] e)
Get the rotation as an EM vector canonicalized to a magnitude of at most PI.
public double[] getEM(double[] e)
getEM(int, double[])
, starts at 0public double[] getEM()
getEM(int, double[])
, always consespublic double getTwist()
public RX setTXEM(int start, double... txem)
setTranslation(double, double, double)
and setEM(double, double, double)
from a packed vector.
public RX setTXEM(double... txem)
setTXEM(int, double...)
starting at 0public double[] getTXEM(int start, double[] txem)
getTranslation(int, double[])
and getEM(int, double[])
to a packed vector.
public double[] getTXEM(double[] txem)
getTXEM(int, double...)
starting at 0public double[] getTXEM()
getTXEM(int, double...)
starting at 0 and consingpublic boolean scatterToTXEM(int[] txemIndices, int start, double... value)
setTXEMComponent(int, double)
for each index in txemIndices, in
order.
txemIndices
- the target txem indices, null for all. If the number
of indices passed exceeds the capacity of value then the latter
ones are ignored.start
- read start index in valuevalue
- the values to set, NaN values are skippedpublic boolean scatterToTXEM(int[] txemIndices, RX other)
Like scatterToTXEM(int[], int, double...)
but takes source
values from other.
In this case the source values are not allowed to be NaN.
public boolean setTXEMComponent(int index, double value)
Set one component of a virtual packed vector composed of the internal translation and exponential map vectors in that order.
The exponential map vector is canonicalized to a maximum magnitude of PI iff any changes are made.
public double[] gatherFromTXEM(int[] txemIndices, int start, double[] value, int minStart, double[] min, int maxStart, double[] max)
complimentary to scatterToTXEM(int[], int, double...)
.
If min and/or max limits are specified, and the canonical EM vector of this RX is not within the limits, then the the corresponding anti-parallel non-canonical EM vector with twist t-2pi is checked; if it is within limits it is used instead. If neither are within limits then the canonical vector is used.
protected boolean inEMLimits(int minStart, double[] min, int maxStart, double[] max)
Check if the EM vector of this RX is within the specified limits.
public double[] gatherFromTXEM(int[] txemIndices, int start, double[] value)
Covers gatherFromTXEM(int[], int, double[], int, double[], int,
double[])
, always uses canonical EM vector.
public double getTXEMComponent(int index)
setTXEMComponent(int, double)
public double[] gatherTXEMTo(RX other, int[] txemIndices, int start, double[] value)
Gather a difference vector which, when added to the indicated TXEM vector indices of this RX, will make those components equal to the corresponding components of other.
public double[] getTXEMTo(RX other, int start, double[] value)
Covers gatherTXEMTo(RX, int[], int, double[])
, gets
all six TXEM vector components in order.
public double[] gatherShortestTXEMTo(RX other, int[] txemIndices, int start, double[] value)
Gather a difference vector which, when added to the indicated TXEM vector indices of this RX, will make those components equal to the corresponding components of other, using either its current EM vector with twist t or the corresponding anti-parallel non-canonical EM vector with twist t-2pi, whichever is closer to the current em vector of this RX.
public double[] getShortestTXEMTo(RX other, int start, double[] value)
Covers gatherShortestTXEMTo(RX, int[], int, double[])
, gets
all six TXEM vector components in order.
public double getMaxTXEMComponentDiff(RX other)
Get the largest abs TXEM component difference between this RX and other.
public double[] toMatrix(double[] m)
Set row-major 16-element matrix m from this RX
(i.e. the
first four elements of m are the first row of the matrix, from left
to right).
public double[] toMatrix()
toMatrix(double[])
, conses the matrixpublic RX fromMatrix(double[] m)
Set all components from row-major 16-element matrix m.
public static RX consFromMatrix(double[] m)
fromMatrix(double[])
, conses a new RX
public RX fromXYO(double[] x, double[] y, double[] o)
Covers fromMatrix(double[])
, builds the matrix given vectors
along the local frame x and y axes and the local frame origin.
x
- vector along the local frame x axis, will be internally
normalized, must have nonzero lengthy
- vector along the local frame y axis, will be internally
normalized, must have nonzero length, must be orthogonal to xpublic static RX consFromXYO(double[] x, double[] y, double[] o)
Covers consFromXYO(double[], double[], double[])
, conses a new
RX
.
public double[] getRotMatrix(double[] m)
Set row-major 9-element matrix m from the rotation component of
this RX
(i.e. the first three elements of m are the first
row of the matrix, from left to right).
public double[] getRotMatrix()
getRotMatrix(double[])
, conses the matrixpublic double[][] dQdEMNumeric(double[][] dQdEM, double h)
Computes partial derivatives of quaternion components with respect to exponential map components, at the current state of this RX, based on numeric perturbation.
The result is a matrix with rows corresponding to quaternion components
in order (X
, Y
, Z
, W
), and columns
corresponding to EM components in order (X
, Y
, Z
). It is organized as a two-dimensional array in column major order,
i.e. dQdEM[X
] is a reference to the leftmost column, which
itself will be an array of length 4. Only the specified columns are
computed.
h
- the perturbation to apply to the EM components, NaN or <= 0
to use DEF_DQDEM_H
dQdEM
- if non-null, the result will be filled in here for each
non-null column, else a new array with all columns will be consedpublic double[][] dQdEMNumeric(double[][] dQdEM)
covers dQdEMNumeric(double[][], double)
with DEF_DQDEM_H
.
public double[][] dQdEMNumeric(double h)
covers dQdEMNumeric(double[][], double)
, conses.
public double[][] dQdEMNumeric()
covers dQdEMNumeric(double[][], double)
, conses with DEF_DQDEM_H
.
public double[][] dQdEMAnalytic(double[][] dQdEM)
Similar to dQdEMNumeric(double[][], double)
but uses analytic
formulas instead of numeric perturbation.
public double[][] dQdEMAnalytic()
dQdEMAnalytic(double[][])
, consespublic double[][] dEMdQNumeric(double[][] dEMdQ, double h)
Computes partial derivatives of exponential map components with respect to quaternion components, at the current state of this RX, based on numeric perturbation.
The result is a matrix with rows corresponding to exponential map
components in order (X
, Y
, Z
), and columns
corresponding to quaternion components in order (X
, Y
,
Z
, W
). It is organized as a two-dimensional array in
row major order, i.e. dEMdQ[X
] is a reference to the
topmost row, which itself will be an array of length 4. Only the
specified rows are computed.
h
- the perturbation to apply to the quaternion components, NaN or
<= 0 to use DEF_DEMDQ_H
dEMdQ
- if non-null, the result will be filled in here for each
non-null row, else a new array with all rows will be consedpublic double[][] dEMdQNumeric(double[][] dEMdQ)
covers dEMdQNumeric(double[][], double)
with DEF_DEMDQ_H
.
public double[][] dEMdQNumeric(double h)
covers dEMdQNumeric(double[][], double)
, conses.
public double[][] dEMdQNumeric()
covers dEMdQNumeric(double[][], double)
, conses with
DEF_DEMDQ_H
.
public double[][] dEMdQAnalytic(double[][] dEMdQ)
Similar to dEMdQNumeric(double[][], double)
but uses
analytic formulas instead of numeric perturbation.
public double[][] dEMdQAnalytic()
covers dEMdQAnalytic(double[][])
, conses.
public double[][] dRdQNumeric(double[][] dRdQ, double h)
Computes partial derivatives of rotation matrix components with respect to quaternion components, at the current state of this RX, based on numeric perturbation.
The result is an array of four row-major 3x3 matrices ("planes"),
corresponding to quaternion components in order (X
, Y
,
Z
, W
), i.e. dRdQ[X
] is a reference to a
3x3 matrix that gives the partial derivatives of the rotation matrix
elements with respect to qx
. Only the specified planes are
computed.
dRdQ
- if non-null, the result will be filled in here for each
non-null plane, else a new array with all planes will be consedh
- the numeric change to apply to the quaternion components, NaN or
<= 0 to use DEF_DRDQ_H
public double[][] dRdQNumeric(double[][] dRdQ)
Covers dRdQNumeric(double[][], double)
with DEF_DRDQ_H
.
public double[][] dRdQNumeric(double h)
Covers dRdQNumeric(double[][], double)
, conses.
public double[][] dRdQNumeric()
covers dRdQNumeric(double[][], double)
, conses with
DEF_DRDQ_H
.
public double[][] dRdQAnalytic(double[][] dRdQ)
Similar to dRdQNumeric(double[][], double)
but uses
analytic formulas instead of numeric perturbation.
public double[][] dRdQAnalytic()
covers dRdQAnalytic(double[][])
, conses.
public double[][] dRdEMNumeric(double[][] dRdEM, double h)
Like dRdQNumeric(double[][], double)
but computes derivative
with respect to the EM vector.
public double[][] dRdEMNumeric(double[][] dRdEM)
Covers dRdEMNumeric(double[][], double)
with DEF_DRDEM_H
.
public double[][] dRdEMNumeric(double h)
Covers dRdEMNumeric(double[][], double)
, conses.
public double[][] dRdEMNumeric()
covers dRdEMNumeric(double[][], double)
, conses with
DEF_DRDEM_H
.
public double[][] dRdEMAnalytic(double[][] dRdEM, double[][] dRdQ, double[][] dQdEM)
Similar to dRdEMNumeric(double[][], double)
but uses
analytic formulas instead of numeric perturbation.
dRdQ
- if not null then dRdQ will be analytically computed here as an
intermediate step (must have all planes); otherwise an internal temporary
array will be conseddQdEM
- if not null then dQdEM will be analytically computed here as
an intermediate step (must have a column for each non-null plane of
dRdEM); otherwise an internal temporary array will be consedpublic double[][] dRdEMAnalytic(double[][] dRdEM)
Covers dRdEMAnalytic(double[][], double[][], double[][])
,
conses dRdQ and dQdEM.
public double[][] dRdEMAnalytic()
Covers dRdEMAnalytic(double[][], double[][], double[][])
,
conses.
public double[][] dRdEMFromdRdQAnddQdEM(double[][] dRdEM, double[][] dRdQ, double[][] dQdEM)
Compute dRdEM by multiplying a given dRdQ and dQdEM.
public RX fromScrew(double t, double d, double px, double py, double pz, double dx, double dy, double dz)
Set to ccw right-hand rotation of t radians about axis through (px, py, pz) in direction of vector (dx, dy, dz), combined with translation d in that direction.
The vector (dx, dy, dz) will be normalized internally.
public RX fromScrew(int pStart, double[] p, int dStart, double[] d, int sStart, double[] s)
s
- the first element is the axial rotation about d in radians
and the second element is the axial translation along dpublic RX fromScrew(double[] p, double[] d, double[] s)
Covers fromScrew(int, double[], int, double[], int, double[])
,
with all starts 0.
public RX fromScrew(int start, double... screw)
Covers fromScrew(int, double[], int, double[], int, double[])
,
with the three component vectors packed in order.
public RX fromScrew(double... screw)
fromScrew(int, double...)
with start 0public RX screwInterp(double u, int cStart, double[] c, int dStart, double[] d, int sStart, double[] s)
Replace this RX by a transform that produces a keyframe at along the
right-handed screw motion taking the identity transform to the current
value of this RX
.
The storage of the optional output vectors p, d, and s may overlap; they are written in that order.
u
- the keyframe position. Current transform is not modified if
u is 1; it is set to identity if u is 0. u in the
range [0, 1] will give the interpolation from identity to the current
value of this transform. Negative u and u>1 are allowed.cStart
- start index of store location in cc
- if non-null then a point on the axis of the screw is stored heredStart
- start index of store location in dd
- if non-null then a unit vector in the direction of the axis of
the screw is stored heresStart
- start index of store location in ss
- if non-null then the first element is set to the axial rotation
at the keyframe in radians, which is the same as the twist angle of the
returned transform, and the second element is set to the axial translation
along d at the keyframepublic RX screwInterp(double u, double[] c, double[] d, double[] s)
Covers screwInterp(double, int, double[], int, double[], int,
double[])
with zero start indices for optional outputs.
public RX screwInterp(double u, int start, double[] screw)
Covers screwInterp(double, int, double[], int, double[], int,
double[])
, with the three component vectors packed in order.
public RX screwInterp(double u, double[] screw)
screwInterp(double, int, double[])
, starts at 0public RX screwInterp(double u)
Covers screwInterp(double, int, double[], int, double[], int,
double[])
with no optional outputs.
public void toScrew(int cStart, double[] c, int dStart, double[] d, int sStart, double[] s)
Covers screwInterp(double, int, double[], int, double[], int,
double[])
with u 1.0.
public void toScrew(double[] c, double[] d, double[] s)
Covers screwInterp(double, int, double[], int, double[], int,
double[])
with u 1.0 and zero start indices for optional
outputs.
public double[] toScrew(int start, double[] screw)
Covers toScrew(int, double[], int, double[], int, double[])
,
with the three component vectors packed in order.
screw
- the screw parameters are returned here beginning at
start packed in order c, d, s; a new array is consed if nullpublic double[] toScrew(double[] screw)
toScrew(int, double[])
, starts at 0public double[] toScrew()
toScrew(double[])
, always consespublic RX interpolateTranslation(double u, RX from, RX to)
Linearly interpolate the translation component of this RX between the translation component of from and the translation component of to.
The rotation component of this RX is not modified. from and to may alias each other and this RX.
u
- the keyframe position. Current translation is not modified if
u is 1 and is set to identity if u is 0. u in the
range [0, 1] will give the interpolation from from to to.
Negative u and u>1 are allowed.public RX interpolateTranslation(double u, RX to)
Covers interpolateTranslation(double, RX, RX)
with from
aliasing this RX.
public RX interpolateTranslation(double u)
Covers interpolateTranslation(double, RX, RX)
with from
identity and to aliasing this RX.
public void interpolateEM(double u, RX from, RX to)
Linearly interpolate the rotation component of this RX between the rotation component of from and the rotation component of to in EM space.
The translation component of this RX is not modified. from and to may alias each other and this RX.
u
- the keyframe position. Current rotation is not modified if
u is 1 and is set to identity if u is 0. u in the
range [0, 1] will give the interpolation from from to to.
Negative u and u>1 are allowed.public void interpolateEM(double u, RX to)
Covers interpolateEM(double, RX, RX)
with from
aliasing this RX.
public void interpolateEM(double u)
Same as interpolateEM(double, RX, RX)
with from
identity and to aliasing this RX.
public void interpolateTXEM(double u, double[] from, double[] to)
Linearly interpolate the translation and EM rotation components of this RX between from and to in TXEM space.
from and to may alias each other; if null they alias this RX. from and to need not have canonical EM vectors, but the interpolation result will be canonicalized.
u
- the keyframe position. Current TXEM is not modified if u
is 1 and is set to identity if u is 0. u in the range [0,
1] will give the interpolation from from to to. Negative
u and u>1 are allowed.public void interpolateTXEM(double u, double ftx, double fty, double ftz, double fex, double fey, double fez, double ttx, double tty, double ttz, double tex, double tey, double tez)
public void interpolateTXEM(double u, double[] to)
Same as interpolateTXEM(double, double[], double[])
with
from aliasing this RX.
public void interpolateTXEM(double u, RX to)
Same as interpolateTXEM(double, RX, RX)
with from
aliasing this RX.
public void interpolateTXEM(double u)
Same as interpolateTXEM(double, double[], double[])
with
from identity and to aliasing this RX.
public RX xPendEither(RX other, boolean invert, boolean prepend)
Prepend or append other, optionally inverting other first.
Appending other corresponds to a a left multiply by other, so that a left multiply of a (column) vector by the resulting product transforms that vector by the product, in order.
It is legal for other to alias this RX
. Otherwise, the
contents of other are not modified.
public RX appendEither(RX other, boolean invert)
xPendEither(vona.math.RX, boolean, boolean)
, always appendspublic RX append(RX other)
xPendEither(vona.math.RX, boolean, boolean)
, always appends without inversionpublic RX appendInverse(RX other)
xPendEither(vona.math.RX, boolean, boolean)
, always appends inversepublic RX prependEither(RX other, boolean invert)
xPendEither(vona.math.RX, boolean, boolean)
, always prependspublic RX prepend(RX other)
xPendEither(vona.math.RX, boolean, boolean)
, always prepends without inversionpublic RX prependInverse(RX other)
xPendEither(vona.math.RX, boolean, boolean)
, always prepends inversepublic RX invert()
public boolean txemComponentEpsilonEquals(double value, int index, double eps)
Compare an individual TXEM component value.
Does not internally updateEM(boolean)
.
value
- the other valueindex
- the index of the component to compareeps
- the epsilon value to use for the EM componentspublic boolean txemComponentEpsilonEquals(double value, int index)
public static boolean txemComponentEpsilonEquals(double v1, double v2, int index, double eps)
Compare an individual TXEM component value.
v1
- the first valuev2
- the second valueindex
- the index of the component to compareeps
- the epsilon value to use for the EM componentspublic static boolean txemComponentEpsilonEquals(double v1, double v2, int index)
public boolean txemComponentEpsilonEquals(double[] txem, int index, double eps)
Compare an individual TXEM component.
Does not internally updateEM(boolean)
this or other
.
txem
- the TXEM vector to compareindex
- the index of the component to compareeps
- the epsilon value to use for the EM componentspublic boolean txemComponentEpsilonEquals(double[] txem, int index)
public boolean txemComponentEpsilonEquals(RX other, int index, double eps)
Like txemComponentEpsilonEquals(double[], int, double)
,
compare to other
.
Does not internally updateEM(boolean)
this or other
.
public boolean txemComponentEpsilonEquals(RX other, int index)
Covers txemComponentEpsilonEquals(RX, int, double)
, uses
VonaMath.DP2R
.
public boolean epsilonEquals(RX other, double eps)
public boolean epsilonEquals(RX other)
epsilonEquals(RX, double)
, uses VonaMath.DP2R
public boolean epsilonEqualsDBG(RX other, double eps)
public boolean epsilonEqualsDBG(RX other)
epsilonEqualsDBG(RX, double)
w/ VonaMath.DP2R
public boolean equals(java.lang.Object other)
epsilonEquals(vona.math.RX, double)
unless other == this
equals
in class java.lang.Object
public boolean isIdentity()
public boolean isPureTranslation(double tol)
public boolean isPureTranslation()
public boolean isPureRotation(double tol)
public boolean isPureRotation()
public RX randomize(double translationRange, double rotationRange)
Set this RX to a random transform.
translationRange
- each translation component is set to a random
value in a symmetric range of this width about the originrotationRange
- the rotation is set to a random twist in a symmetric
range of this width about the origin about a random axis. Internally
clamped to a maximum magnitude of PI.public RX randomize()
Covers randomize(double, double)
, uses DEF_RANDOM_TRANSLATION_RANGE
and DEF_RANDOM_ROTATION_RANGE
.
public static RX consRandom(double translationRange, double rotationRange)
Covers randomize(double, double)
conses a new RX
.
public static RX consRandom()
randomize()
, conses a new RX
public double[] transformV3(boolean invert, int start, double... v)
Transform 3D vector v.
Corresponds to a left multiply of v by the matrix equivalent to this transform.
start
- the index of the first element of the 3D vector to transform
in vpublic float[] transformV3(boolean invert, int start, float... v)
public double[] transformV3(int start, double... v)
Covers transformV3(boolean, int, double...)
, never inverts.
public float[] transformV3(int start, float... v)
transformV3(int, double...)
public double[] transformV3(boolean invert, double... v)
Covers transformV3(boolean, int, double...)
with start =
0.
public float[] transformV3(boolean invert, float... v)
public double[] transformV3(double... v)
Covers transformV3(boolean, int, double...)
, start = 0,
never inverts.
public float[] transformV3(float... v)
transformV3(double...)
public double[] translateV3(boolean invert, int start, double... v)
Translate 3D vector v.
start
- the index of the first element of the 3D vector to translate
in vpublic float[] translateV3(boolean invert, int start, float... v)
translateV3(boolean, int, double...)
public double[] translateV3(int start, double... v)
Covers translateV3(boolean, int, double...)
, never inverts.
public float[] translateV3(int start, float... v)
translateV3(int, double...)
public double[] translateV3(boolean invert, double... v)
Covers translateV3(boolean, int, double...)
, with start
= 0.
public float[] translateV3(boolean invert, float... v)
public double[] translateV3(double... v)
Covers translateV3(boolean, int, double...)
, never inverts,
start = 0.
public float[] translateV3(float... v)
translateV3(double...)
public double[] rotateV3(boolean invert, int start, double... v)
Rotate 3D vector v.
The computation uses the quaternion rotation representation, which will be updated if dirty.
start
- the index of the first element of the 3D vector to rotate
in vinvert
- whether to rotate by the inverse of the current rotation of
this RXpublic float[] rotateV3(boolean invert, int start, float... v)
rotateV3(boolean, int, double...)
public double[] rotateV3(int start, double... v)
Covers rotateV3(boolean, int, double...)
, never inverts.
public float[] rotateV3(int start, float... v)
rotateV3(int, double...)
public double[] rotateV3(boolean invert, double... v)
Covers rotateV3(boolean, int, double...)
with start =
0.
public float[] rotateV3(boolean invert, float... v)
rotateV3(double...)
public double[] rotateV3(double... v)
Covers rotateV3(boolean, int, double...)
, never inverts,
start = 0.
public float[] rotateV3(float... v)
rotateV3(double...)
public void rotateT(double qx, double qy, double qz, double qw)
Rotate the current translation vector of this RX in-place by the unit quaternion (qx, qy, qz, qw) with vector component (qx, qy, qz) and scalar component qw.
.public void rotateT()
Covers rotateT(double, double, double, double)
, uses current
rotation quaternion of this RX, which will be updated if dirty.
protected void normalizeQuaternion()
protected boolean canonicalizeQuaternion()
Ensure that qw
is positive, flipping the quaternion if
necessary.
protected double canonicalizeEM()
Canonicalize the EM rep to a magnitude (i.e. twist angle) of at most PI.
The EM rep must not be dirty at time of call. The quaternion rep is not modified.
protected double updateQuaternion(boolean nearest)
Compute the exponential map to update the quaternion rep from the current value of the EM rep.
The EM rep must not be dirty at time of call, but it does not need to
be canonical. There are always two choices for the computed quaternion
q since q and -q encode the same rotation. If
canonical is specified then the choice is made by selecting the
quaternion whose vector part is parallel (rather than anti-parallel) the
current EM vector. In this case the computed qw
will be
non-negative (i.e. the quaternion will be canonical) iff the current EM
vector has a magnitude of at most pi (i.e. it is also canonical); in
general if t is the magnitude of the curent EM vector then the
computed qw
will be
If nearest is specified, the new quaternion is selected to be
nearest the current quaternion for this RX
. If both options are
equi-distant then the behaviour is as if nearest were
false.
protected double updateQuaternion()
updateQuaternion(boolean)
, not nearestprotected double updateEM(boolean canonicalize)
Compute the log map to update the EM rep from the current value of the quaternion rep.
The quaternion rep must not be dirty at time of call, and is presumed
to be normalized, though it need not be canonical, qw
may be
positive or negative. It is not modified.
protected final double updateEM()
updateEM(boolean)
, always canonicalpublic static void main(java.lang.String[] arg)
RX.Test
public void dump(java.io.PrintStream s, java.lang.String msg, boolean newline)
public void dump(java.io.PrintStream s, java.lang.String msg)
dump(PrintStream, String, boolean)
, no newlinepublic java.lang.String toString(java.lang.String msg)
dump(PrintStream, String, boolean)
, no newline, to Stringpublic java.lang.String toString()
toString(String)
, no msgtoString
in class java.lang.Object
public void dump(java.io.PrintStream s)
dump(PrintStream, String)
, no msgpublic void dump(java.lang.String msg)
dump(PrintStream, String)
, to System.outpublic void dump()
dump(PrintStream, String)
, to System.out, no msgpublic static void dumpTXEM(java.io.PrintStream s, double tx, double ty, double tz, double ex, double ey, double ez)
public void dumpTXEM(java.io.PrintStream s)
public static void dumpTXEM(java.io.PrintStream s, int start, double[] txem)
public static void dumpTXEM(java.io.PrintStream s, double[] txem)
dumpTXEM(PrintStream, int, double[])
, starts at 0public static void dumpMatrix(java.io.PrintStream s, double[] m, java.lang.String msg)
public static void dumpMatrix(java.io.PrintStream s, double[] m)
dumpMatrix(PrintStream, double[], String)
, no msgpublic static void dumpMatrix(double[] m)
Covers dumpMatrix(PrintStream, double[], String)
, to
System.out, no msg.
public static void dumpRotMatrix(java.io.PrintStream s, double[] m, java.lang.String msg)
public static void dumpRotMatrix(java.io.PrintStream s, double[] m)
dumpRotMatrix(PrintStream, double[], String)
, no msgpublic static void dumpRotMatrix(double[] m)
Covers dumpRotMatrix(PrintStream, double[], String)
, to
System.out, no msg.
public static void dumpColMatrix(java.io.PrintStream s, double[][] m, java.lang.String msg)
Dump all of column-major matrix m human-readable to stream s.
public static void dumpColMatrix(java.io.PrintStream s, double[][] m)
Covers dumpColMatrix(PrintStream, double[][], String)
, no
msg.
public static void dumpColMatrix(double[][] m)
Covers dumpColMatrix(PrintStream, double[][], String)
, to
System.out, no msg.
public static void dumpSquareTensor(java.io.PrintStream s, double[][] m, java.lang.String msg)
Dump all of a tensor of row-major square matrices m human-readable to stream s.
public static void dumpSquareTensor(java.io.PrintStream s, double[][] m)
Covers dumpSquareTensor(PrintStream, double[][], String)
, no
msg.
public static void dumpSquareTensor(double[][] m)
Covers dumpSquareTensor(PrintStream, double[][], String)
, to
System.out, no msg.
public static void dumpScrew(java.io.PrintStream str, java.lang.String msg, int pStart, double[] p, int dStart, double[] d, int sStart, double[] s)
Dump a screw human-readable to stream s.
public static void dumpScrew(java.io.PrintStream str, java.lang.String msg, double[] p, double[] d, double[] s)
Covers dumpScrew(PrintStream, String, int, double[], int,
double[], int, double[])
, starts at 0.
public static void dumpScrew(java.io.PrintStream s, java.lang.String msg, int start, double... screw)
Covers dumpScrew(PrintStream, String, int, double[], int,
double[], int, double[])
, with the three component vectors packed in
order.
public static void dumpScrew(java.io.PrintStream s, java.lang.String msg, double... screw)
Covers dumpScrew(PrintStream, String, int, double...)
, starts
at 0.
public static void dumpScrew(java.io.PrintStream s, double... screw)
dumpScrew(PrintStream, String, double...)
, no msgpublic static void dumpScrew(double... screw)
Covers dumpScrew(PrintStream, String, double...)
, to
System.out, no msg.
public static void dumpStats(java.io.PrintStream s)
public static void dumpStats()
dumpStats(java.io.PrintStream)
, to System.outpublic static void resetStats()
protected static double sign(double v)