SpiceBoolean vzerog_c ( ConstSpiceDouble * v, SpiceInt ndim )
Indicate whether a general-dimensional vector is the zero vector.
None.
MATH
VECTOR
Variable I/O Description
-------- --- --------------------------------------------------
v I Vector to be tested.
ndim I Dimension of v.
The function returns the value SPICETRUE if and only if v is the
zero vector.
v,
ndim are, respectively, a vector and its dimension.
The function returns the value SPICETRUE if and only if v is the
zero vector.
None.
Error free.
1) When ndim is non-positive, this function returns the value
SPICEFALSE (A vector of non-positive dimension cannot be the
zero vector.)
None.
This function has the same truth value as the logical expression
( vnormg_c ( v, ndim ) == 0. )
Replacing the above expression by
vzerog_c ( v, ndim );
has several advantages: the latter expresses the test more
clearly, looks better, and doesn't go through the work of scaling,
squaring, taking a square root, and re-scaling (all of which
vnormg_c must do) just to find out that a vector is non-zero.
A related function is vzero_c, which accepts three-dimensional
vectors.
1) When testing whether a vector is the zero vector, one
normally constructs tests like
if ( vnormg_c ( v, ndim ) == 0. )
{
.
.
.
These can be replaced with the code
if ( vzerog_c ( v, ndim ) )
{
.
.
.
2) Make sure that a `unit' quaternion is non-zero before
converting it to a rotation matrix.
if ( vzerog_c ( q, 4 ) )
{
[ handle error ]
else
{
vhatg_c ( q, 4, q )
q2m_c ( q, m )
.
.
.
None.
None.
N.J. Bachman (JPL)
I.M. Underwood (JPL)
E.D. Wright (JPL)
-CSPICE Version 1.0.0, 29-JUN-1999
test whether an n-dimensional vector is the zero vector
Link to routine vzerog_c source file vzerog_c.c
|