All Downloads are FREE. Search and download functionalities are using the official Maven repository.

m.4.4.0.source-code.LceConv Maven / Gradle / Ivy

The newest version!
// SRM SDK Release 4.4.0 - January 21, 2010

// - SRM spec. 4.4

/*
 *                             NOTICE
 * 
 * This software is provided openly and freely for use in representing and
 * interchanging environmental data & databases.
 * 
 * This software was developed for use by the United States Government with
 * unlimited rights.  The software was developed under contract
 * DASG60-02-D-0006 TO-193 by Science Applications International Corporation.
 * The software is unclassified and is deemed as Distribution A, approved
 * for Public Release.
 * 
 * Use by others is permitted only upon the ACCEPTANCE OF THE TERMS AND
 * CONDITIONS, AS STIPULATED UNDER THE FOLLOWING PROVISIONS:
 * 
 *    1. Recipient may make unlimited copies of this software and give
 *       copies to other persons or entities as long as the copies contain
 *       this NOTICE, and as long as the same copyright notices that
 *       appear on, or in, this software remain.
 * 
 *    2. Trademarks. All trademarks belong to their respective trademark
 *       holders.  Third-Party applications/software/information are
 *       copyrighted by their respective owners.
 * 
 *    3. Recipient agrees to forfeit all intellectual property and
 *       ownership rights for any version created from the modification
 *       or adaptation of this software, including versions created from
 *       the translation and/or reverse engineering of the software design.
 * 
 *    4. Transfer.  Recipient may not sell, rent, lease, or sublicense
 *       this software.  Recipient may, however enable another person
 *       or entity the rights to use this software, provided that this
 *       AGREEMENT and NOTICE is furnished along with the software and
 *       /or software system utilizing this software.
 * 
 *       All revisions, modifications, created by the Recipient, to this
 *       software and/or related technical data shall be forwarded by the
 *       Recipient to the Government at the following address:
 * 
 *         SMDC
 *         Attention SEDRIS (TO193) TPOC
 *         P.O. Box 1500
 *         Huntsville, AL  35807-3801
 * 
 *         or via electronic mail to:  [email protected]
 * 
 *    5. No Warranty. This software is being delivered to you AS IS
 *       and there is no warranty, EXPRESS or IMPLIED, as to its use
 *       or performance.
 * 
 *       The RECIPIENT ASSUMES ALL RISKS, KNOWN AND UNKNOWN, OF USING
 *       THIS SOFTWARE.  The DEVELOPER EXPRESSLY DISCLAIMS, and the
 *       RECIPIENT WAIVES, ANY and ALL PERFORMANCE OR RESULTS YOU MAY
 *       OBTAIN BY USING THIS SOFTWARE OR DOCUMENTATION.  THERE IS
 *       NO WARRANTY, EXPRESS OR, IMPLIED, AS TO NON-INFRINGEMENT OF
 *       THIRD PARTY RIGHTS, MERCHANTABILITY, OR FITNESS FOR ANY
 *       PARTICULAR PURPOSE.  IN NO EVENT WILL THE DEVELOPER, THE
 *       UNITED STATES GOVERNMENT OR ANYONE ELSE ASSOCIATED WITH THE
 *       DEVELOPMENT OF THIS SOFTWARE BE HELD LIABLE FOR ANY CONSEQUENTIAL,
 *       INCIDENTAL OR SPECIAL DAMAGES, INCLUDING ANY LOST PROFITS
 *       OR LOST SAVINGS WHATSOEVER.
 */

/*
 * COPYRIGHT 2010, SCIENCE APPLICATIONS INTERNATIONAL CORPORATION.
 *                 ALL RIGHTS RESERVED.
 * 
 */

// SRM_OTHERS_GOES_HERE

/**
@author David Shen
*/

package SRM;

class LceConv extends Conversions
{
    private ToCcenConst _toCcenConst;

    protected LceConv()
    {
        // setting the source and destinations of this conversion object
        super (SRM_SRFT_Code.SRFTCOD_LOCOCENTRIC_EUCLIDEAN_3D,
               new SRM_SRFT_Code[] {SRM_SRFT_Code.SRFTCOD_CELESTIOCENTRIC,
                                    SRM_SRFT_Code.SRFTCOD_UNSPECIFIED });
    }

    protected Conversions makeClone()
    {
        return (Conversions) new LceConv();
    }

/*
 *----------------------------------------------------------------------------
 *
 * Conversion dispatcher
 *
 *----------------------------------------------------------------------------
 */
    protected SRM_Coordinate_Valid_Region_Code convert
    (
        SRM_SRFT_Code        destSrfType,
        BaseSRF              srcSrf,
        BaseSRF              destSrf,
        double[]             src,
        double[]             dest,
        SRM_ORM_Trans_Params hst
    ) throws SrmException
    {
        SRM_Coordinate_Valid_Region_Code retValid =
            SRM_Coordinate_Valid_Region_Code.COORDVALRGN_VALID;

        if (destSrfType == SRM_SRFT_Code.SRFTCOD_CELESTIOCENTRIC)
        {
            // pre validation - NO RESTRICTION

            // compute destination
            if (_toCcenConst == null)
              _toCcenConst = new ToCcenConst(((SRF_LococentricEuclidean3D)
                                              srcSrf).getSRFParameters());

            for (int i = 0; i < 3; i++)
            {
                dest[i] =
                  _toCcenConst.lococentre[i] +
                  src[0]*_toCcenConst.primary_axis[i] +
                  src[1]*_toCcenConst.secondary_axis[i] +
                  src[2]*_toCcenConst.xprod_rs[i];
            }
            dest[3] = 0.0;
        }
        else if (destSrfType == SRM_SRFT_Code.SRFTCOD_UNSPECIFIED)
        {
            // Just pass the coordinate through.
            // This is the last conversion of chain
            dest[0] = src[0];
            dest[1] = src[1];
            dest[2] = src[2];
        }
        return retValid;
    }

/*
 *----------------------------------------------------------------------------
 *
 * FUNCTION: toCcen
 *
 *----------------------------------------------------------------------------
 */
    private class ToCcenConst
    {
        double[] lococentre     = new double[3];
        double[] primary_axis   = new double[3];
        double[] secondary_axis = new double[3];
        double[] xprod_rs       = new double[3];

        public ToCcenConst(SRF_LCE_3D_Params params)
        {
            Const.vectCrossProd(params.primary_axis, params.secondary_axis,
                                xprod_rs);

            for (int i=0; i<3; i++)
            {
                lococentre[i]     = params.lococentre[i];
                primary_axis[i]   = params.primary_axis[i];
                secondary_axis[i] = params.secondary_axis[i];
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy