~ubuntu-branches/debian/jessie/yade/jessie

« back to all changes in this revision

Viewing changes to pkg/common/StepDisplacer.hpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-08-04 19:34:58 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140804193458-cw8qhnujxe9wzi15
Tags: 1.11.0-1
* [a0600ae] Imported Upstream version 1.11.0
* [a3055e0] Do not use parallel build on kfreebsd-amd64 and s390x.
* [f86b405] Remove applied patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// 2008 © Václav Šmilauer <eudoxos@arcig.cz> 
2
2
#pragma once
3
 
 
4
3
#include<yade/core/PartialEngine.hpp>
 
4
#include<yade/core/State.hpp>
 
5
#include<yade/core/Scene.hpp>
5
6
 
6
7
class StepDisplacer: public PartialEngine {
7
8
        public:
8
 
                virtual void action();
 
9
                virtual void action() {
 
10
                        FOREACH(Body::id_t id, ids){
 
11
                        const shared_ptr<Body>& b=Body::byId(id,scene);
 
12
                        if(setVelocities){
 
13
                                const Real& dt=scene->dt;
 
14
                                b->state->vel=mov/dt;
 
15
                                AngleAxisr aa(rot); aa.axis().normalize();
 
16
                                b->state->angVel=aa.axis()*aa.angle()/dt;
 
17
                                LOG_DEBUG("Angular velocity set to "<<aa.axis()*aa.angle()/dt<<". Axis="<<aa.axis()<<", angle="<<aa.angle());
 
18
                        }
 
19
                        if(!setVelocities){
 
20
                                b->state->pos+=mov;
 
21
                                b->state->ori=rot*b->state->ori;
 
22
                        }
 
23
                }
 
24
        }
9
25
        YADE_CLASS_BASE_DOC_ATTRS(StepDisplacer,PartialEngine,"Apply generalized displacement (displacement or rotation) stepwise on subscribed bodies. Could be used for purposes of contact law tests (by moving one sphere compared to another), but in this case, see rather :yref:`LawTester`",
10
26
                ((Vector3r,mov,Vector3r::Zero(),,"Linear displacement step to be applied per iteration, by addition to :yref:`State.pos`."))
11
27
                ((Quaternionr,rot,Quaternionr::Identity(),,"Rotation step to be applied per iteration (via rotation composition with :yref:`State.ori`)."))
14
30
        DECLARE_LOGGER;
15
31
};
16
32
REGISTER_SERIALIZABLE(StepDisplacer);
17
 
        
18