コード例 #1
0
/* Calculates the gravity gradient tensor caused by a prism. */
int prism_ggt_sph(PRISM prism, double lonp, double latp, double rp, double *ggt)
{
    double x = 0, y = 0, z = 0, ggtprism[9], ggtpoint[9];

    global2local(lonp, latp, rp, prism, &x, &y, &z);
    ggtprism[0] = prism_gxx(prism, x, y, z);
    ggtprism[1] = prism_gxy(prism, x, y, z);
    /* -1 because the prisms z is Down, but transformation assumes z is Up */
    /* z -> Up is the system of the tesseroid */
    ggtprism[2] = -1*prism_gxz(prism, x, y, z);
    ggtprism[3] = ggtprism[1];
    ggtprism[4] = prism_gyy(prism, x, y, z);
    /* Same as xz */
    ggtprism[5] = -1*prism_gyz(prism, x, y, z);
    ggtprism[6] = ggtprism[2];
    ggtprism[7] = ggtprism[5];
    ggtprism[8] = -(ggtprism[0] + ggtprism[4]);
    ggt_prism2point(ggtprism, prism, lonp, latp, rp, ggtpoint);
    ggt[0] = ggtpoint[0];
    ggt[1] = ggtpoint[1];
    ggt[2] = ggtpoint[2];
    ggt[3] = ggtpoint[4];
    ggt[4] = ggtpoint[5];
    ggt[5] = ggtpoint[8];

    return 0;
}
コード例 #2
0
/* Test coordinate transformation */
static char * test_global2local()
{
    #define R 6378137.0
    #define N 3
    PRISM prisms[N] = {
        {3000,-5000,5000,-5000,5000,0,5000, 2.45, -36.32, R},
        {2000,-3000,3000,-2000,2000,0,800, -45.45, -103.1, R},
        {1000,-2000,2000,-1000,1000,0,234, -80.45, 183.2, R}};
    double x, y, z, newz[N] = {-3000, 1234, -2.3456};
    int i;

    for(i = 0; i < N; i++)
    {
        global2local(prisms[i].lon, prisms[i].lat, R - newz[i], prisms[i],
                     &x, &y, &z);
        sprintf(msg, "(prism %d) x: expect %.10g got %.10g", i, 0., x);
        mu_assert_almost_equals(x, 0., 0.00000001, msg);
        sprintf(msg, "(prism %d) y: expect %.10g got %.10g", i, 0., y);
        mu_assert_almost_equals(y, 0., 0.00000001, msg);
        sprintf(msg, "(prism %d) z: expect %.10g got %.10g", i, newz[i], z);
        mu_assert_almost_equals(z, newz[i], 0.00000001, msg);
    }
    #undef R
    #undef N
    return 0;
}
コード例 #3
0
/* Calculates the potential caused by a prism. */
double prism_pot_sph(PRISM prism, double lonp, double latp, double rp)
{
    double x = 0, y = 0, z = 0, res;

    global2local(lonp, latp, rp, prism, &x, &y, &z);
    res = prism_pot(prism, x, y, z);

    return res;
}
コード例 #4
0
    void ClipRectActor::handleEvent(Event* event)
    {
        if (TouchEvent::isTouchEvent(event->type))
        {
            TouchEvent* te = safeCast<TouchEvent*>(event);
            Vector2 localPosition = global2local(te->localPosition);
            if (!isOn(localPosition))
                return;
        }

        _Actor::handleEvent(event);
    }
コード例 #5
0
ファイル: rod.cpp プロジェクト: dimaleks/uDeviceX
void RodIC::exec(const MPI_Comm& comm, ParticleVector *pv, cudaStream_t stream)
{
    auto rv = dynamic_cast<RodVector*>(pv);
    auto domain = pv->state->domain;
    
    if (rv == nullptr)
        die("rods can only be generated out of rod vectors; provided '%s'", pv->name.c_str());

    int objSize = rv->objSize;
    int nObjs = 0;
    int nSegments = (objSize - 1) / 5;

    auto positions = createRodTemplate(nSegments, centerLine, torsion);

    assert(objSize == positions.size());
    
    for (auto& entry : com_q)
    {
        float3 com {entry[0], entry[1], entry[2]};
        float4 q   {entry[3], entry[4], entry[5], entry[6]};

        q = normalize(q);        

        if (domain.globalStart.x <= com.x && com.x < domain.globalStart.x + domain.localSize.x &&
            domain.globalStart.y <= com.y && com.y < domain.globalStart.y + domain.localSize.y &&
            domain.globalStart.z <= com.z && com.z < domain.globalStart.z + domain.localSize.z)
        {
            com = domain.global2local(com);
            int oldSize = rv->local()->size();
            rv->local()->resize(oldSize + objSize, stream);

            for (int i = 0; i < objSize; i++)
            {
                float3 r = rotate(positions[i], q) + com;
                Particle p;
                p.r = r;
                p.u = make_float3(0);

                rv->local()->coosvels[oldSize + i] = p;
            }

            nObjs++;
        }
    }

    rv->local()->coosvels.uploadToDevice(stream);
    rv->local()->computeGlobalIds(comm, stream);
    rv->local()->extraPerParticle.getData<Particle>(ChannelNames::oldParts)->copy(rv->local()->coosvels, stream);

    info("Initialized %d '%s' rods", nObjs, rv->name.c_str());
}
コード例 #6
0
    Vector2 global2local(Actor* actor, const Vector2& globalPos)
    {
        Vector2 pos = globalPos;
        if (!actor)
            return pos;
        Actor* parent = actor->getParent();
        if (parent)
        {
            pos = global2local(parent, globalPos);
        }

        pos = actor->global2local(pos);

        return pos;
    }
コード例 #7
0
/* Calculates the gravitational attraction caused by a prism. */
int prism_g_sph(PRISM prism, double lonp, double latp, double rp, double *gx,
                double *gy, double *gz)
{
    double x = 0, y = 0, z = 0, gprism[3], gpoint[3];

    global2local(lonp, latp, rp, prism, &x, &y, &z);
    gprism[0] = prism_gx(prism, x, y, z);
    gprism[1] = prism_gy(prism, x, y, z);
    /* Nagy wants z down, but the transformation assumes z up */
    gprism[2] = -prism_gz(prism, x, y, z);
    g_prism2point(gprism, prism, lonp, latp, rp, gpoint);
    *gx = gpoint[0];
    *gy = gpoint[1];
    /* Put z back down again to maintain the normal convention for gz */
    *gz = -gpoint[2];

    return 0;
}
コード例 #8
0
ファイル: mesh.cpp プロジェクト: macoro/CG_projects
BBox* Mesh::bounding_box(){
    double minx, miny, minz, maxx, maxy, maxz;
    Point3D p0(m_verts[0][0],m_verts[0][1],m_verts[0][2]);
    minx = maxx = p0[0];
    miny = maxy = p0[1];
    minz = maxz = p0[2];

    for(size_t vert = 1; vert < m_verts.size(); vert++){
        Point3D p(m_verts[vert][0],m_verts[vert][1],m_verts[vert][2]);
        //x
        if(p[0] < minx)
            minx = p[0];
        else if(p[0] > maxx)
            maxx = p[0];
        //y
        if(p[1] < miny)
            miny = p[1];
        else if(p[1] > maxy)
            maxy = p[1];
        //z
        if(p[2] < minz)
            minz = p[2];
        else if(p[2] > maxz)
            maxz = p[2];
    }

    Vector3D size( (maxx - minx),(maxy - miny),(maxz - minz) );
    Point3D pos(minx,miny,minz);

    m_Po = pos;
    m_S = Vector3D(size[0],0,0);
    m_T = Vector3D(0,size[1],0);
    m_U = Vector3D(0,0,size[2]);

    global2local();

    return new BBox(pos,size);
}