示例#1
0
Balloon::Balloon(double r, double dt, Eigen::MatrixXd positions, Eigen::MatrixXi faces)
    :
    ParticleObject(r)
{
    m_radius = r;
    m_step = dt;
    m_positions = positions;
    m_speeds = Eigen::MatrixXd::Zero(positions.rows(), positions.cols());
    m_forces = Eigen::MatrixXd::Zero(m_positions.rows(), m_positions.cols());
    m_num_point = m_positions.rows();
    m_mass = m_mass_all / (double)m_num_point;
    c = 2.0*sqrt(m_mass*k)/3.0;
    m_faces = faces;
    m_faceactive = Eigen::VectorXi::Zero(m_faces.rows());
    for(int i=0; i<m_faceactive.rows(); i++)
    {
        m_faceactive(i) = 1;
    }
    igl::adjacency_list(m_faces, m_adjacency_list);
    igl::triangle_triangle_adjacency(m_positions, m_faces, m_facetoface);

    std::vector<std::vector<int>> tmp_list;
    igl::vertex_triangle_adjacency(m_positions, m_faces, m_vertextoface, tmp_list);
    initEdges();
    computeNormals();


    calcAveRadius();

    m_threshold_ratio = Eigen::VectorXd::Ones(m_edges.rows()) * threshold_ratio;

    // for(int i=0; i<m_positions.rows(); i++){
    //   // std::cout << "adjacent to " << i << ": " << m_adjacency_list[i].size() << std::endl;
    // }
    // for(int i=0; i<m_positions.rows(); i++){
    //   // std::cout << "normal " << i << ": " << m_normals.norm() << std::endl;
    // }
}
示例#2
0
文件: element.c 项目: jaingaurav/rstm
/* =============================================================================
 * TMelement_alloc
 *
 * Contains a copy of input arg 'coordinates'
 * =============================================================================
 */
element_t*
TMelement_alloc (TM_ARGDECL coordinate_t* coordinates, long numCoordinate)
{
    element_t* elementPtr = NULL;

    elementPtr = (element_t*)TM_MALLOC(sizeof(element_t));
    if (elementPtr) {
        long i;
        for (i = 0; i < numCoordinate; i++) {
            elementPtr->coordinates[i] = coordinates[i];
        }
        elementPtr->numCoordinate = numCoordinate;
        minimizeCoordinates(elementPtr);
        checkAngles(elementPtr);
        calculateCircumCircle(elementPtr);
        initEdges(elementPtr, coordinates, numCoordinate);
        elementPtr->neighborListPtr = TMLIST_ALLOC(&element_listcompare);
        assert(elementPtr->neighborListPtr);
        elementPtr->isGarbage = false;
        elementPtr->isReferenced = false;
    }

    return elementPtr;
}