Table of contents
CSPICE_EL2CGV converts a SPICE ellipse to a center vector and two
generating vectors. The selected generating vectors are semi-axes of
the ellipse.
Given:
ellips a structure describing a SPICE ellipse. The structure has
the fields:
[1,1] = size(ellips); struct = class(ellips)
The structure has the fields:
center: [3,1] = size(center); double = class(center)
semiMinor: [3,1] = size(semiMinor); double = class(semiMinor)
semiMajor: [3,1] = size(semiMajor); double = class(semiMajor)
the call:
[center, smajor, sminor] = cspice_el2cgv( ellips )
returns:
center the location of the center of `ellips'.
[3,1] = size(center); double = class(center)
smajor the semi-major axis of `ellips'.
[3,1] = size(smajor); double = class(smajor)
sminor double precision 3x1 array defining the semi-minor
axis of `ellips'
[3,1] = size(sminor); double = class(sminor)
This ellipse is the set of points
center + cos(theta) smajor + sin(theta) sminor
where theta ranges over the interval (-pi, pi].
None.
Any numerical results shown for these examples may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) Given a SPICE ellipse structure, extract its components into
independent variables.
Example code begins here.
function el2cgv_ex1()
%
% Define two arbitrary, linearly independent vectors
% and a center vector.
%
vec1 = [ 1; 1; 1 ];
vec2 = [ 1; -1; 1 ];
center = [ 1; 1; 1 ];
%
% Calculate the semi-major and semi-minor axes of
% the ellipse as generated by `vec1' and `vec2'.
%
% The cspice_saelgv call determines the orthogonal axes
% of an ellipse from two generating vectors.
%
[smajor, sminor ] = cspice_saelgv( vec1, vec2 );
%
% Load the generating vectors into an ellipse structure.
%
[ellips] = cspice_cgv2el( center, smajor, sminor );
fprintf( 'Input SPICE ellipse:\n' );
fprintf( ' Semi-minor axis: %10.6f %10.6f %10.6f\n', ...
ellips.semiMinor);
fprintf( ' Semi-major axis: %10.6f %10.6f %10.6f\n', ...
ellips.semiMajor);
fprintf( ' Center : %10.6f %10.6f %10.6f\n\n', ...
ellips.center );
%
% Extract the SPICE ellipse structure components into
% variable.
%
[cent, smaj, smin] = cspice_el2cgv( ellips );
fprintf( 'Ellipse components:\n' );
fprintf( ' Semi-minor axis: %10.6f %10.6f %10.6f\n', ...
smin);
fprintf( ' Semi-major axis: %10.6f %10.6f %10.6f\n', ...
smaj);
fprintf( ' Center : %10.6f %10.6f %10.6f\n\n', ...
cent );
When this program was executed on a Mac/Intel/Octave6.x/64-bit
platform, the output was:
Input SPICE ellipse:
Semi-minor axis: 0.000000 1.414214 0.000000
Semi-major axis: 1.414214 -0.000000 1.414214
Center : 1.000000 1.000000 1.000000
Ellipse components:
Semi-minor axis: 0.000000 1.414214 0.000000
Semi-major axis: 1.414214 -0.000000 1.414214
Center : 1.000000 1.000000 1.000000
2) Given an ellipsoid and a viewpoint exterior to it, calculate
the limb ellipse as seen from that viewpoint.
Example code begins here.
function el2cgv_ex2()
%
% Define an ellipsoid
%
a = sqrt(2.);
b = 2.*sqrt(2.);
c = sqrt(2.);
%
% Locate a viewpoint exterior to the ellipsoid.
%
viewpt = [ 2., 0., 0. ]';
%
% Calculate the limb ellipse as seen by from the viewpoint.
%
limb = cspice_edlimb( a, b, c, viewpt );
%
% Output the structure components.
%
fprintf( 'Semiminor axis: %10.3f %10.3f %10.3f\n', ...
limb.semiMinor );
fprintf( 'Semimajor axis: %10.3f %10.3f %10.3f\n', ...
limb.semiMajor );
fprintf( 'Center: %10.3f %10.3f %10.3f\n', ...
limb.center );
%
% Check against expected values:
%
% Semiminor: 0., 0., -1.
% Semimajor: 0., 2., 0.
% Center : 1., 0., 0.
%
When this program was executed on a Mac/Intel/Octave6.x/64-bit
platform, the output was:
Semiminor axis: 0.000 0.000 -1.000
Semimajor axis: 0.000 2.000 -0.000
Center: 1.000 0.000 0.000
SPICE ellipses serve to simplify calling sequences and reduce
the chance for error in declaring and describing argument lists
involving ellipses.
The set of ellipse conversion routines is
cspice_cgv2el( Center and generating vectors to ellipse )
cspice_el2cgv( Ellipse to center and generating vectors )
A word about the output of this routine: the semi-major axis of
an ellipse is a vector of largest possible magnitude in the set
cos(theta) vec1 + sin(theta) vec2,
where theta is in the interval (-pi, pi]. There are two such
vectors; they are additive inverses of each other. The semi-minor
axis is an analogous vector of smallest possible magnitude. The
semi-major and semi-minor axes are orthogonal to each other. If
smajor and sminor are choices of semi-major and semi-minor axes,
then the input ellipse can also be represented as the set of
points
center + cos(theta) smajor + sin(theta) sminor
where theta ranges over the interval (-pi, pi].
1) If the input argument `ellips' is undefined, an error is
signaled by the Matlab error handling system.
2) If the input argument `ellips' is not of the expected type, or
it does not have the expected dimensions and size, an error is
signaled by the Mice interface.
None.
None.
MICE.REQ
ELLIPSES.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Mice Version 1.1.0, 10-AUG-2021 (EDW) (JDR)
Changed input argument name "ellipse" to "ellips".
Edited the header to comply with NAIF standard. Fixed typos in
-I/O section. Added example's problem statement, reformatted
example's output and added second example.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections.
Eliminated use of "lasterror" in rethrow.
Removed reference to the function's corresponding CSPICE header from
-Required_Reading section.
-Mice Version 1.0.1, 09-NOV-2012 (EDW)
Edited -I/O section to conform to NAIF standard for Mice
documentation.
-Mice Version 1.0.0, 30-DEC-2008 (EDW)
ellipse to center and generating vectors
|