コード例 #1
0
ファイル: eck3.cpp プロジェクト: OSGeo/proj.4
static PJ_XY eck3_s_forward (PJ_LP lp, PJ *P) {           /* Spheroidal, forward */
    PJ_XY xy = {0.0,0.0};
    struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque);

    xy.y = Q->C_y * lp.phi;
    xy.x = Q->C_x * lp.lam * (Q->A + asqrt(1. - Q->B * lp.phi * lp.phi));
    return xy;
}
コード例 #2
0
ファイル: eck3.cpp プロジェクト: OSGeo/proj.4
static PJ_LP eck3_s_inverse (PJ_XY xy, PJ *P) {           /* Spheroidal, inverse */
    PJ_LP lp = {0.0,0.0};
    struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque);
    double denominator;

    lp.phi = xy.y / Q->C_y;
    denominator = (Q->C_x * (Q->A + asqrt(1. - Q->B * lp.phi * lp.phi)));
    if ( denominator == 0.0)
        lp.lam = HUGE_VAL;
    else
        lp.lam = xy.x / denominator;
    return lp;
}
コード例 #3
0
ファイル: tpeqd.hpp プロジェクト: TheRyaz/c_reading
    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;
    }
コード例 #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
ファイル: ad5934.c プロジェクト: grolly-gcl-website/grolly2
// read AD5934
uint32_t runSweep(uint8_t mode) {
    uint32_t ec = 0;
    uint16_t re = 0;
    uint16_t img = 0;
    uint32_t freq = 0;
    uint32_t mag = 0;
    uint32_t phase = 0;
    uint32_t gain = 0;
    uint32_t impedance = 0;
    uint32_t increment = 0;
    uint32_t tmp = 0;
    uint8_t i = 0;
    uint8_t flag = 0;
    uint16_t R1 = 0;
    uint16_t R2 = 0;

    uint8_t ctrl_r1 = 0;
    uint8_t ctrl_r2 = 0;
    uint8_t ctrl_r3 = 0;
    uint8_t ctrl_r4 = 0;


    // 1. Standby '10110000' Mask D8-10 of avoid tampering with gains
    ad5934_write_data(AD5934_CTRL_R1,(ad5934_read_data(AD5934_CTRL_R1) & 0x07) | 0xB0);

    // 2. Initialize sweep
    ad5934_write_data(AD5934_CTRL_R1,(ad5934_read_data(AD5934_CTRL_R1) & 0x07) | 0x10);

    // 3. Start sweep
    ad5934_write_data(AD5934_CTRL_R1,(ad5934_read_data(AD5934_CTRL_R1) & 0x07) | 0x20);

    vTaskDelay(100);

    while((ad5934_read_data(AD5934_STATUS_REG) & 0x07) < 4 ) {  // Check that status reg != 4, sweep not complete
        vTaskDelay(100); // delay between measurements

        flag = ad5934_read_data(AD5934_STATUS_REG)& 2;

        if (flag==2) {
            // read two bytes of real part
            R1 = ad5934_read_data(AD5934_REAL_DATA_R1);
            R2 = ad5934_read_data(AD5934_REAL_DATA_R2);
            re = (R1 << 8) | R2;
            re &= ~(1 << 15);

            // and read two another bytes of Imaginary part
            R1  = mod4int(ad5934_read_data(AD5934_IMG_DATA_R1));
            R2  = mod4int(ad5934_read_data(AD5934_IMG_DATA_R2));

            img = (R1 << 8) | R2;

            // here we need to calculate square root of powed real + powed imaginary
            // first calculate (real^2+img^2)
            tmp = (re*re)+(img*img);
            mag = asqrt(tmp);			// and square root
//			ec += freq;
            vTaskDelay(50);

            // detect edge of range to switch feedback resistor
            if (mag>15000 && range_mode==LOW_RANGE_CONDUCTIVITY) {
                init_adg715(HIGH_RANGE_CONDUCTIVITY);
            }
            else if (mag<2500 && range_mode==HIGH_RANGE_CONDUCTIVITY) {
                init_adg715(LOW_RANGE_CONDUCTIVITY);
            }

            else {	// if no range switches, then calculate current EC
                if (range_mode==LOW_RANGE_CONDUCTIVITY) {
                    ec = mag/10;	// calculate EC for 25uS..2500uS range (CN0349)
                    return ec;
                }
                else if (range_mode==HIGH_RANGE_CONDUCTIVITY) {
                    ec = mag;		// calculate EC for 0.5ms..200ms range
                    return ec;
                }
                else {
                    return ~(ec);	// wrong reading
                }
            }

            return ~(ec);			// wrong reading

        }
    }
    ad5934_write_data(AD5934_CTRL_R1,(ad5934_read_data(AD5934_CTRL_R1) & 0x07) | 0xA0);
}
コード例 #6
0
ファイル: PJ_tpeqd.c プロジェクト: joa-quim/MB-system-Win
#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));
lp.phi = aacos(P->ctx, hypot(P->thz0 *s, d) * P->rhshz0);
if (xy.y < 0.)
	lp.phi = -lp.phi;
コード例 #7
0
ファイル: PJ_fahey.c プロジェクト: 469447793/World-Wind-Java
#define PJ_LIB__
# include	<projects.h>
PROJ_HEAD(fahey, "Fahey") "\n\tPcyl, Sph.";
#define TOL 1e-6
FORWARD(s_forward); /* spheroid */
	xy.y = 1.819152 * ( xy.x = tan(0.5 * lp.phi) );
	xy.x = 0.819152 * lp.lam * asqrt(1 - xy.x * xy.x);
	return (xy);
}
INVERSE(s_inverse); /* spheroid */
	lp.phi = 2. * atan(xy.y /= 1.819152);
	lp.lam = fabs(xy.y = 1. - xy.y * xy.y) < TOL ? 0. :
		xy.x / (0.819152 * sqrt(xy.y));
	return (lp);
}
FREEUP; if (P) pj_dalloc(P); }
ENTRY0(fahey) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
コード例 #8
0
 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
 {
     lp_lat = xy_y / this->m_proj_parm.C_y;
     lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat)));
 }
コード例 #9
0
 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
 {
     xy_y = this->m_proj_parm.C_y * lp_lat;
     xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat));
 }
コード例 #10
0
 inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
 {
     xy_y = 1.819152 * ( xy_x = tan(0.5 * lp_lat) );
     xy_x = 0.819152 * lp_lon * asqrt(1 - xy_x * xy_x);
 }
コード例 #11
0
ファイル: PJ_eck3.c プロジェクト: dyang02/SurrogateTools
#ifndef lint
static const char SCCSID[]="@(#)PJ_eck3.c	4.1	94/02/15	GIE	REL";
#endif
#define PROJ_PARMS__ \
	double C_x, C_y, A, B;
#define PJ_LIB__
#include	<projects.h>
PROJ_HEAD(eck3, "Eckert III") "\n\tPCyl, Sph.";
PROJ_HEAD(putp1, "Putnins P1") "\n\tPCyl, Sph.";
PROJ_HEAD(wag6, "Wagner VI") "\n\tPCyl, Sph.";
PROJ_HEAD(kav7, "Kavraisky VII") "\n\tPCyl, Sph.";
FORWARD(s_forward); /* spheroid */
	xy.y = P->C_y * lp.phi;
	xy.x = P->C_x * lp.lam * (P->A + asqrt(1. - P->B * lp.phi * lp.phi));
	return (xy);
}
INVERSE(s_inverse); /* spheroid */
	lp.phi = xy.y / P->C_y;
	lp.lam = xy.x / (P->C_x * (P->A + asqrt(1. - P->B * lp.phi * lp.phi)));
	return (lp);
}
FREEUP; if (P) pj_dalloc(P); }
	static PJ *
setup(PJ *P) {
	P->es = 0.;
	P->inv = s_inverse;
	P->fwd = s_forward;
	return P;
}
ENTRY0(eck3)
	P->C_x = .42223820031577120149;