示例#1
0
void setup_tpeqd(Parameters& par, par_tpeqd& proj_parm)
{
    double lam_1, lam_2, phi_1, phi_2, A12, pp;
    /* get control point locations */
    phi_1 = pj_param(par.params, "rlat_1").f;
    lam_1 = pj_param(par.params, "rlon_1").f;
    phi_2 = pj_param(par.params, "rlat_2").f;
    lam_2 = pj_param(par.params, "rlon_2").f;
    if (phi_1 == phi_2 && lam_1 == lam_2) throw proj_exception(-25);
    par.lam0 = adjlon(0.5 * (lam_1 + lam_2));
    proj_parm.dlam2 = adjlon(lam_2 - lam_1);
    proj_parm.cp1 = cos(phi_1);
    proj_parm.cp2 = cos(phi_2);
    proj_parm.sp1 = sin(phi_1);
    proj_parm.sp2 = sin(phi_2);
    proj_parm.cs = proj_parm.cp1 * proj_parm.sp2;
    proj_parm.sc = proj_parm.sp1 * proj_parm.cp2;
    proj_parm.ccs = proj_parm.cp1 * proj_parm.cp2 * sin(proj_parm.dlam2);
    proj_parm.z02 = aacos(proj_parm.sp1 * proj_parm.sp2 + proj_parm.cp1 * proj_parm.cp2 * cos(proj_parm.dlam2));
    proj_parm.hz0 = .5 * proj_parm.z02;
    A12 = atan2(proj_parm.cp2 * sin(proj_parm.dlam2),
                proj_parm.cp1 * proj_parm.sp2 - proj_parm.sp1 * proj_parm.cp2 * cos(proj_parm.dlam2));
    proj_parm.ca = cos(pp = aasin(proj_parm.cp1 * sin(A12)));
    proj_parm.sa = sin(pp);
    proj_parm.lp = adjlon(atan2(proj_parm.cp1 * cos(A12), proj_parm.sp1) - proj_parm.hz0);
    proj_parm.dlam2 *= .5;
    proj_parm.lamc = HALFPI - atan2(sin(A12) * proj_parm.sp1, cos(A12)) - proj_parm.dlam2;
    proj_parm.thz0 = tan(proj_parm.hz0);
    proj_parm.rhshz0 = .5 / sin(proj_parm.hz0);
    proj_parm.r2z0 = 0.5 / proj_parm.z02;
    proj_parm.z02 *= proj_parm.z02;
    // par.inv = s_inverse;
    // par.fwd = s_forward;
    par.es = 0.;
}
示例#2
0
    inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
    {
        double t, z1, z2, dl1, dl2, sp, cp;

        sp = sin(lp_lat);
        cp = cos(lp_lat);
        z1 = aacos(this->m_proj_parm.sp1 * sp + this->m_proj_parm.cp1 * cp * cos(dl1 = lp_lon + this->m_proj_parm.dlam2));
        z2 = aacos(this->m_proj_parm.sp2 * sp + this->m_proj_parm.cp2 * cp * cos(dl2 = lp_lon - this->m_proj_parm.dlam2));
        z1 *= z1;
        z2 *= z2;
        xy_x = this->m_proj_parm.r2z0 * (t = z1 - z2);
        t = this->m_proj_parm.z02 - t;
        xy_y = this->m_proj_parm.r2z0 * asqrt(4. * this->m_proj_parm.z02 * z2 - t * t);
        if ((this->m_proj_parm.ccs * sp - cp * (this->m_proj_parm.cs * sin(dl1) - this->m_proj_parm.sc * sin(dl2))) < 0.)
            xy_y = -xy_y;
    }
示例#3
0
char *proobraz(char* input)
{
input = registr(input);

input=  ficha(input);
for (int i=0;i<strlen(input);i++)
    {
       ssin(i,input);
       ccos(i,input);
       aasin(i,input);
       aacos(i,input);
       aatan(i,input);
       cceil(i,input);
       cch(i,input);
       eexp(i,input);
       aabs(i,input);
       ffloor(i,input);
       lln(i,input);
       llog(i,input);
       ssh(i,input);
       ssqrt(i,input);
       ttan(i,input);
       tth(i,input);
       cctg(i,input);
	aactg(i,input);
	ccth(i,input);
    }
    return input;
}
示例#4
0
文件: PJ_tpeqd.c 项目: Maasik/proj.4
static XY s_forward (LP lp, PJ *P) {           /* Spheroidal, forward */
    XY xy = {0.0, 0.0};
    struct pj_opaque *Q = P->opaque;
	double t, z1, z2, dl1, dl2, sp, cp;

	sp = sin(lp.phi);
	cp = cos(lp.phi);
	z1 = aacos(P->ctx, Q->sp1 * sp + Q->cp1 * cp * cos (dl1 = lp.lam + Q->dlam2));
	z2 = aacos(P->ctx, Q->sp2 * sp + Q->cp2 * cp * cos (dl2 = lp.lam - Q->dlam2));
	z1 *= z1;
	z2 *= z2;

	xy.x = Q->r2z0 * (t = z1 - z2);
	t = Q->z02 - t;
	xy.y = Q->r2z0 * asqrt (4. * Q->z02 * z2 - t * t);
	if ((Q->ccs * sp - cp * (Q->cs * sin(dl1) - Q->sc * sin(dl2))) < 0.)
		xy.y = -xy.y;
	return xy;
}
示例#5
0
文件: oea.hpp 项目: microcai/boost
                // FORWARD(s_forward)  sphere
                // Project coordinates from geographic (lon, lat) to cartesian (x, y)
                inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
                {
                    T Az, M, N, cp, sp, cl, shz;

                    cp = cos(lp_lat);
                    sp = sin(lp_lat);
                    cl = cos(lp_lon);
                    Az = aatan2(cp * sin(lp_lon), this->m_proj_parm.cp0 * sp - this->m_proj_parm.sp0 * cp * cl) + this->m_proj_parm.theta;
                    shz = sin(0.5 * aacos(this->m_proj_parm.sp0 * sp + this->m_proj_parm.cp0 * cp * cl));
                    M = aasin(shz * sin(Az));
                    N = aasin(shz * cos(Az) * cos(M) / cos(M * this->m_proj_parm.two_r_m));
                    xy_y = this->m_proj_parm.n * sin(N * this->m_proj_parm.two_r_n);
                    xy_x = this->m_proj_parm.m * sin(M * this->m_proj_parm.two_r_m) * cos(N) / cos(N * this->m_proj_parm.two_r_n);
                }
示例#6
0
 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
 {
     double Az, M, N, cp, sp, cl, shz;
 
     cp = cos(lp_lat);
     sp = sin(lp_lat);
     cl = cos(lp_lon);
     Az = aatan2(cp * sin(lp_lon), this->m_proj_parm.cp0 * sp - this->m_proj_parm.sp0 * cp * cl) + this->m_proj_parm.theta;
     shz = sin(0.5 * aacos(this->m_proj_parm.sp0 * sp + this->m_proj_parm.cp0 * cp * cl));
     M = aasin(shz * sin(Az));
     N = aasin(shz * cos(Az) * cos(M) / cos(M * this->m_proj_parm.two_r_m));
     xy_y = this->m_proj_parm.n * sin(N * this->m_proj_parm.two_r_n);
     xy_x = this->m_proj_parm.m * sin(M * this->m_proj_parm.two_r_m) * cos(N) / cos(N * this->m_proj_parm.two_r_n);
 }
示例#7
0
文件: math.c 项目: DCurrent/openbor
HRESULT math_acos(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount)
{
    DOUBLE dbltemp;

    if(SUCCEEDED(ScriptVariant_DecimalValue(varlist[0], &dbltemp)))
    {
        double PI = 3.14159265;

        ScriptVariant_ChangeType(*pretvar, VT_DECIMAL);
        (*pretvar)->dblVal = (DOUBLE)(aacos((double)dbltemp) * 180.0 / PI);
        return S_OK;
    }
    *pretvar = NULL;
    return E_FAIL;
}
示例#8
0
文件: PJ_tpeqd.c 项目: Maasik/proj.4
PJ *PROJECTION(tpeqd) {
	double lam_1, lam_2, phi_1, phi_2, A12, pp;
    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
    if (0==Q)
        return freeup_new (P);
    P->opaque = Q;


	/* get control point locations */
	phi_1 = pj_param(P->ctx, P->params, "rlat_1").f;
	lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
	phi_2 = pj_param(P->ctx, P->params, "rlat_2").f;
	lam_2 = pj_param(P->ctx, P->params, "rlon_2").f;

	if (phi_1 == phi_2 && lam_1 == lam_2)
        E_ERROR(-25);
	P->lam0  = adjlon (0.5 * (lam_1 + lam_2));
	Q->dlam2 = adjlon (lam_2 - lam_1);

	Q->cp1 = cos (phi_1);
	Q->cp2 = cos (phi_2);
	Q->sp1 = sin (phi_1);
	Q->sp2 = sin (phi_2);
	Q->cs = Q->cp1 * Q->sp2;
	Q->sc = Q->sp1 * Q->cp2;
	Q->ccs = Q->cp1 * Q->cp2 * sin(Q->dlam2);
	Q->z02 = aacos(P->ctx, Q->sp1 * Q->sp2 + Q->cp1 * Q->cp2 * cos (Q->dlam2));
	Q->hz0 = .5 * Q->z02;
	A12 = atan2(Q->cp2 * sin (Q->dlam2),
		Q->cp1 * Q->sp2 - Q->sp1 * Q->cp2 * cos (Q->dlam2));
	Q->ca = cos(pp = aasin(P->ctx, Q->cp1 * sin(A12)));
	Q->sa = sin(pp);
	Q->lp = adjlon ( atan2 (Q->cp1 * cos(A12), Q->sp1) - Q->hz0);
	Q->dlam2 *= .5;
	Q->lamc = M_HALFPI - atan2(sin(A12) * Q->sp1, cos(A12)) - Q->dlam2;
	Q->thz0 = tan (Q->hz0);
	Q->rhshz0 = .5 / sin (Q->hz0);
	Q->r2z0 = 0.5 / Q->z02;
	Q->z02 *= Q->z02;

    P->inv = s_inverse;
    P->fwd = s_forward;
	P->es = 0.;

    return P;
}
示例#9
0
    inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
    {
        double cz1, cz2, s, d, cp, sp;

        cz1 = cos(boost::math::hypot(xy_y, xy_x + this->m_proj_parm.hz0));
        cz2 = cos(boost::math::hypot(xy_y, xy_x - this->m_proj_parm.hz0));
        s = cz1 + cz2;
        d = cz1 - cz2;
        lp_lon = - atan2(d, (s * this->m_proj_parm.thz0));
        lp_lat = aacos(boost::math::hypot(this->m_proj_parm.thz0 * s, d) * this->m_proj_parm.rhshz0);
        if ( xy_y < 0. )
            lp_lat = - lp_lat;
        /* lam--phi now in system relative to P1--P2 base equator */
        sp = sin(lp_lat);
        cp = cos(lp_lat);
        lp_lat = aasin(this->m_proj_parm.sa * sp + this->m_proj_parm.ca * cp * (s = cos(lp_lon -= this->m_proj_parm.lp)));
        lp_lon = atan2(cp * sin(lp_lon), this->m_proj_parm.sa * cp * s - this->m_proj_parm.ca * sp) + this->m_proj_parm.lamc;
    }
示例#10
0
	static VECT /* distance and azimuth from point 1 to point 2 */
vect(projCtx ctx, double dphi, double c1, double s1, double c2, double s2, double dlam) {
	VECT v;
	double cdl, dp, dl;

	cdl = cos(dlam);
	if (fabs(dphi) > 1. || fabs(dlam) > 1.)
		v.r = aacos(ctx, s1 * s2 + c1 * c2 * cdl);
	else { /* more accurate for smaller distances */
		dp = sin(.5 * dphi);
		dl = sin(.5 * dlam);
		v.r = 2. * aasin(ctx,sqrt(dp * dp + c1 * c2 * dl * dl));
	}
	if (fabs(v.r) > TOL)
		v.Az = atan2(c2 * sin(dlam), c1 * s2 - s1 * c2 * cdl);
	else
		v.r = v.Az = 0.;
	return v;
}
示例#11
0
文件: PJ_tpeqd.c 项目: Maasik/proj.4
static LP s_inverse (XY xy, PJ *P) {           /* Spheroidal, inverse */
    LP lp = {0.0,0.0};
    struct pj_opaque *Q = P->opaque;
	double cz1, cz2, s, d, cp, sp;

	cz1 = cos (hypot(xy.y, xy.x + Q->hz0));
	cz2 = cos (hypot(xy.y, xy.x - Q->hz0));
	s = cz1 + cz2;
	d = cz1 - cz2;
	lp.lam = - atan2(d, (s * Q->thz0));
	lp.phi = aacos(P->ctx, hypot (Q->thz0 * s, d) * Q->rhshz0);
	if ( xy.y < 0. )
		lp.phi = - lp.phi;
	/* lam--phi now in system relative to P1--P2 base equator */
	sp = sin (lp.phi);
	cp = cos (lp.phi);
	lp.phi = aasin (P->ctx, Q->sa * sp + Q->ca * cp * (s = cos(lp.lam -= Q->lp)));
	lp.lam = atan2 (cp * sin(lp.lam), Q->sa * cp * s - Q->ca * sp) + Q->lamc;
	return lp;
}
示例#12
0
文件: tpeqd.hpp 项目: microcai/boost
            inline void setup_tpeqd(Params const& params, Parameters& par, par_tpeqd<T>& proj_parm)
            {
                T lam_1, lam_2, phi_1, phi_2, A12, pp;

                /* get control point locations */
                phi_1 = pj_get_param_r<T, srs::spar::lat_1>(params, "lat_1", srs::dpar::lat_1);
                lam_1 = pj_get_param_r<T, srs::spar::lon_1>(params, "lon_1", srs::dpar::lon_1);
                phi_2 = pj_get_param_r<T, srs::spar::lat_2>(params, "lat_2", srs::dpar::lat_2);
                lam_2 = pj_get_param_r<T, srs::spar::lon_2>(params, "lon_2", srs::dpar::lon_2);

                if (phi_1 == phi_2 && lam_1 == lam_2)
                    BOOST_THROW_EXCEPTION( projection_exception(error_control_point_no_dist) );

                par.lam0 = adjlon(0.5 * (lam_1 + lam_2));
                proj_parm.dlam2 = adjlon(lam_2 - lam_1);

                proj_parm.cp1 = cos(phi_1);
                proj_parm.cp2 = cos(phi_2);
                proj_parm.sp1 = sin(phi_1);
                proj_parm.sp2 = sin(phi_2);
                proj_parm.cs = proj_parm.cp1 * proj_parm.sp2;
                proj_parm.sc = proj_parm.sp1 * proj_parm.cp2;
                proj_parm.ccs = proj_parm.cp1 * proj_parm.cp2 * sin(proj_parm.dlam2);
                proj_parm.z02 = aacos(proj_parm.sp1 * proj_parm.sp2 + proj_parm.cp1 * proj_parm.cp2 * cos(proj_parm.dlam2));
                proj_parm.hz0 = .5 * proj_parm.z02;
                A12 = atan2(proj_parm.cp2 * sin(proj_parm.dlam2),
                    proj_parm.cp1 * proj_parm.sp2 - proj_parm.sp1 * proj_parm.cp2 * cos(proj_parm.dlam2));
                proj_parm.ca = cos(pp = aasin(proj_parm.cp1 * sin(A12)));
                proj_parm.sa = sin(pp);
                proj_parm.lp = adjlon(atan2(proj_parm.cp1 * cos(A12), proj_parm.sp1) - proj_parm.hz0);
                proj_parm.dlam2 *= .5;
                proj_parm.lamc = geometry::math::half_pi<T>() - atan2(sin(A12) * proj_parm.sp1, cos(A12)) - proj_parm.dlam2;
                proj_parm.thz0 = tan(proj_parm.hz0);
                proj_parm.rhshz0 = .5 / sin(proj_parm.hz0);
                proj_parm.r2z0 = 0.5 / proj_parm.z02;
                proj_parm.z02 *= proj_parm.z02;

                par.es = 0.;
            }
示例#13
0
文件: PJ_oea.c 项目: dankelley/gre
#define PROJ_PARMS__ \
	double	theta; \
	double	m, n; \
	double	two_r_m, two_r_n, rm, rn, hm, hn; \
	double	cp0, sp0;
#define PJ_LIB__
#include	"projects.h"
PROJ_HEAD(oea, "Oblated Equal Area") "\n\tMisc Sph\n\tn= m= theta=";
FORWARD(s_forward); /* sphere */
	double Az, hz, M, N, cp, sp, cl, shz;

	cp = cos(lp.phi);
	sp = sin(lp.phi);
	cl = cos(lp.lam);
	Az = aatan2(cp * sin(lp.lam), P->cp0 * sp - P->sp0 * cp * cl) + P->theta;
	shz = sin(0.5 * aacos(P->sp0 * sp + P->cp0 * cp * cl));
	M = aasin(shz * sin(Az));
	N = aasin(shz * cos(Az) * cos(M) / cos(M * P->two_r_m));
	xy.y = P->n * sin(N * P->two_r_n);
	xy.x = P->m * sin(M * P->two_r_m) * cos(N) / cos(N * P->two_r_n);
	return (xy);
}
INVERSE(s_inverse); /* sphere */
	double N, M, xp, yp, z, Az, cz, sz, cAz;

	N = P->hn * aasin(xy.y * P->rn);
	M = P->hm * aasin(xy.x * P->rm * cos(N * P->two_r_n) / cos(N));
	xp = 2. * sin(M);
	yp = 2. * sin(N) * cos(M * P->two_r_m) / cos(M);
	cAz = cos(Az = aatan2(xp, yp) - P->theta);
	z = 2. * aasin(0.5 * hypot(xp, yp));
示例#14
0
#define PROJ_PARMS__                                                                                                             \
	double cp1, sp1, cp2, sp2, ccs, cs, sc, r2z0, z02, dlam2;                                                                    \
	double hz0, thz0, rhshz0, ca, sa, lp, lamc;
#define PJ_LIB__
#include <projects.h>
PROJ_HEAD(tpeqd, "Two Point Equidistant")
"\n\tMisc Sph\n\tlat_1= lon_1= lat_2= lon_2=";
FORWARD(s_forward); /* sphere */
double t, z1, z2, dl1, dl2, sp, cp;

sp = sin(lp.phi);
cp = cos(lp.phi);
z1 = aacos(P->ctx, P->sp1 *sp + P->cp1 * cp * cos(dl1 = lp.lam + P->dlam2));
z2 = aacos(P->ctx, P->sp2 *sp + P->cp2 * cp * cos(dl2 = lp.lam - P->dlam2));
z1 *= z1;
z2 *= z2;
xy.x = P->r2z0 * (t = z1 - z2);
t = P->z02 - t;
xy.y = P->r2z0 * asqrt(4. * P->z02 * z2 - t * t);
if ((P->ccs * sp - cp * (P->cs * sin(dl1) - P->sc * sin(dl2))) < 0.)
	xy.y = -xy.y;
return xy;
}
INVERSE(s_inverse); /* sphere */
double cz1, cz2, s, d, cp, sp;

cz1 = cos(hypot(xy.y, xy.x + P->hz0));
cz2 = cos(hypot(xy.y, xy.x - P->hz0));
s = cz1 + cz2;
d = cz1 - cz2;
lp.lam = -atan2(d, (s * P->thz0));
示例#15
0
	static double /* law of cosines */
lc(projCtx ctx, double b,double c,double a) {
	return aacos(ctx, .5 * (b * b + c * c - a * a) / (b * c));
}