void unormg_c ( ConstSpiceDouble * v1,
SpiceInt ndim,
SpiceDouble * vout,
SpiceDouble * vmag )
Normalize a double precision vector of arbitrary dimension and
return its magnitude.
None.
VECTOR
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
v1 I Vector to be normalized.
ndim I Dimension of v1 (and also vout).
vout O Unit vector v1 / |v1|.
If v1 = 0, vout will also be zero.
vout can overwrite v1.
vmag O Magnitude of v1, that is, |v1|.
v1 This variable may contain any vector of arbitrary
dimension, including the zero vector.
ndim This is the dimension of v1 and vout.
vout This variable contains the unit vector in the direction
of v1. If v1 is the zero vector, then vout will also be
the zero vector.
vmag This is the magnitude of v1.
None.
1) If ndim is not physically realistic, greater than zero, a
BADDIMENSION error is flagged.
None.
unormg_c references a function called vnormg_c (which itself is
numerically stable) to calculate the norm of the input vector v1.
If the norm is equal to zero, then each component of the output
vector vout is set to zero. Otherwise, vout is calculated by
dividing v1 by the norm. No error detection or correction is
implemented.
The following table shows how selected v1 implies vout and mag.
v1 ndim vout mag
-----------------------------------------------------------------
(5, 12) 2 (5/13, 12/13) 13
(1D-7, 2D-7, 2D-7) 3 (1/3, 2/3, 2/3) 3D-7
No error checking is implemented in this subroutine to guard
against numeric overflow.
None.
W.M. Owen (JPL)
W.L. Taber (JPL)
E.D. Wright (JPL)
-CSPICE Version 1.2.0, 06-FEB-2017 (EDW)
Bug fix: eliminated spurious semi-colon on "for(...)" line.
This caused the output vector not to be set when the input
argument `v1' was the zero vector.
Corrected section order.
-CSPICE Version 1.1.0, 22-OCT-1998 (NJB)
Made input vector const. Converted check-in style to discovery.
-CSPICE Version 1.0.0, 31-MAR-1998 (EDW)
n-dimensional unit vector and norm
Link to routine unormg_c source file unormg_c.c
|