当前位置: 首页>>代码示例>>C++>>正文


C++ SPtr::setGravity方法代码示例

本文整理汇总了C++中simulation::node::SPtr::setGravity方法的典型用法代码示例。如果您正苦于以下问题:C++ SPtr::setGravity方法的具体用法?C++ SPtr::setGravity怎么用?C++ SPtr::setGravity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simulation::node::SPtr的用法示例。


在下文中一共展示了SPtr::setGravity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setup

    /**
     * @brief Create the physical model
     *
     * @param m Mass of the particle
     * @param s Stiffness of the spring
     * @param d Damping ratio of the spring
     * @param xx0 initial position
     * @param vv0 initial velocity
     */
    void setup(
            SReal m, SReal s, SReal d,
            SReal xx0, SReal vv0
            )
    {
        mass = m;
        stiffness = s;
        damping = d;
        x0=xx0; v0=vv0;

        node = clearScene();
        node->setGravity( Vec3(0,0,0) );

        // The oscillator
        simulation::Node::SPtr oscillator = node->createChild("oscillator");

        DOF = addNew<MechanicalObject1>(oscillator,"DOF");
        DOF->resize(1);
        DOF->writePositions()[0]  = Vec1(x0);
        DOF->writeVelocities()[0] = Vec1(v0);

        UniformMass1::SPtr Mass = addNew<UniformMass1>(oscillator,"mass");
        Mass->mass.setValue( mass );

        compliance = addNew<UniformCompliance1>(oscillator,"compliance");
        compliance->isCompliance.setValue(false);
        compliance->compliance.setValue(1.0/stiffness);
        compliance->damping.setValue(damping);
    }
开发者ID:151706061,项目名称:sofa,代码行数:38,代码来源:DampedOscillator_test.cpp

示例2: createScene

    /// Create the context for the scene
    void createScene(double K, double m, double l0, double rm=0, double rk=0)
    {
        // Init simulation
        sofa::simulation::setSimulation(simulation = new sofa::simulation::graph::DAGSimulation());
        root = simulation::getSimulation()->createNewGraph("root");

        // Create the scene
        root->setGravity(Coord(0,-10,0));

        // Solver
        variationalSolver = addNew<VariationalSymplecticSolver> (getRoot());
        variationalSolver->f_rayleighStiffness.setValue(rk);
        variationalSolver->f_rayleighMass.setValue(rm);
        variationalSolver->f_computeHamiltonian.setValue(1);
        variationalSolver->f_newtonError.setValue(1e-12);//1e-18
        variationalSolver->f_newtonSteps.setValue(4);//7

        CGLinearSolver::SPtr cgLinearSolver = addNew<CGLinearSolver> (getRoot());
        cgLinearSolver->f_maxIter=3000;
        cgLinearSolver->f_tolerance =1e-12;
        cgLinearSolver->f_smallDenominatorThreshold=1e-12;

        // Set initial positions and velocities of fixed point and mass
        MechanicalObject3::VecCoord xFixed(1);
        MechanicalObject3::DataTypes::set( xFixed[0], 0., 2.,0.);
        MechanicalObject3::VecDeriv vFixed(1);
        MechanicalObject3::DataTypes::set( vFixed[0], 0.,0.,0.);
        MechanicalObject3::VecCoord xMass(1);
        MechanicalObject3::DataTypes::set( xMass[0], 0., 1.,0.);
        MechanicalObject3::VecDeriv vMass(1);
        MechanicalObject3::DataTypes::set( vMass[0], 0., 0., 0.);

        // Mass spring system
        root = this-> createMassSpringSystem(
                root,   // add mass spring system to the node containing solver
                K,      // stiffness
                m,      // mass
                l0,     // spring rest length
                xFixed, // Initial position of fixed point
                vFixed, // Initial velocity of fixed point
                xMass,  // Initial position of mass
                vMass); // Initial velocity of mass
    }
开发者ID:ejeanvoi,项目名称:sofa-kernel-cleaned,代码行数:44,代码来源:VariationalSymplecticImplicitSolverDynamic_test.cpp


注:本文中的simulation::node::SPtr::setGravity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。