something do not understand about code in polyhedra_ig2.cpp

Asked by lip on 2019-06-05

hello
below is the code i am reading:
bool Ig2_Polyhedra_Polyhedra_ScGeom::go(const shared_ptr<Shape>& shape1, const shared_ptr<Shape>& shape2, const State& state1, const State& state2, const Vector3r& shift2, const bool& force, const shared_ptr<Interaction>& interaction) {
const Se3r& se31=state1.se3;
const Se3r& se32=state2.se3;
shared_ptr<ScGeom> geom;
bool isNew = !interaction->geom;
if (isNew) {
Ig2_Polyhedra_Polyhedra_PolyhedraGeom ppGeom = Ig2_Polyhedra_Polyhedra_PolyhedraGeom();
ppGeom.interactionDetectionFactor = interactionDetectionFactor;
bool pp = ppGeom.go(shape1,shape2,state2,state1,shift2,force,interaction);
if (!pp) {
return false;
}
shared_ptr<PolyhedraGeom> pGeom = YADE_PTR_CAST<PolyhedraGeom>(interaction->geom);
geom = shared_ptr<ScGeom>(new ScGeom());
interaction->geom=geom;
} else {
}
Vector3r normal=(se32.position+shift2)-se31.position;
Real norm=normal.norm(); normal/=norm; // normal is unit vector now
geom->penetrationDepth=penetrationDepth;
scene = Omega::instance().getScene().get();
geom->precompute(state1,state2,scene,interaction,normal,isNew,shift2,false);
return true;
}
question1: what does the parameter shift2 do?
question2:what does se31.position refer to? i know that the position of sphere means the centre of it, but as to polyhedra, which point can define the position of it? Is the positon means the centroid of polyhedra or something else?

Question information

Language:
English Edit question
Status:
For:
Assignee:
No assignee Edit question
Last query:
2019-06-05
2019-06-05
 Jan Stránský (honzik) said on 2019-06-05: #1

Hello,

> question1

for non-periodic simulations, it is Vector3(0,0,0)
for periodic simulations, is is shift of the second body to make the interaction meaningful

> question2

se31.position would be in python state.pos
**usually** it is the center of mass. But in general b.state.pos and b.shape.v can be quite independent.

cheers
Jan