yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #05609
Re: [Question #188032]: looking for the InCylinder folder
Question #188032 on Yade changed:
https://answers.launchpad.net/yade/+question/188032
Christian Sommerfeld posted a new comment:
First of all i created a new hpp and a new cpp file named cone.hpp and
cone.cpp with the same code like in the cylinder.hpp and cylinder.cpp to
check if it is still working, when i only changed the name. Furthermore,
i implemented the following code into the _packPredicates.cpp file:
class inCone: public Predicate{
Vector3r c1,c2,c12; Real radius,ht;
public:
inCone(const Vector3r& _c1, const Vector3r& _c2, Real _radius){c1=_c1; c2=_c2; c12=c2-c1; radius=_radius; ht=c12.norm(); }
bool operator()(const Vector3r& pt, Real pad=0.) const {
Real u=(pt.dot(c12)-c1.dot(c12))/(ht*ht); // normalized coordinate along the c1--c2 axis
if((u*ht<0+pad) || (u*ht>ht-pad)) return false; // out of cylinder along the axis
Real axisDist=((pt-c1).cross(pt-c2)).norm()/ht;
if(axisDist>radius-pad) return false;
return true;
}
py::tuple aabb() const {
// see http://www.gamedev.net/community/forums/topic.asp?topic_id=338522&forum_id=20&gforum_id=0 for the algorithm
const Vector3r& A(c1); const Vector3r& B(c2);
Vector3r k(
sqrt((pow(A[1]-B[1],2)+pow(A[2]-B[2],2)))/ht,
sqrt((pow(A[0]-B[0],2)+pow(A[2]-B[2],2)))/ht,
sqrt((pow(A[0]-B[0],2)+pow(A[1]-B[1],2)))/ht);
Vector3r mn=A.cwise().min(B), mx=A.cwise().max(B);
return vvec2tuple((mn-radius*k).eval(),(mx+radius*k).eval());
}
};
py::class_<inCone,py::bases<Predicate> >("inCone","Cone predicate",py::init<const Vector3r&,const Vector3r&,Real>(py::args("centerBottom","centerTop","radius"),"Ctor taking centers of the lateral walls (as 3-tuples) and radius."));
what is the same code as for inCylinder
But when i want to create an inCone with the following code:
from yade import pack
pred=pack.inCone(centerBottom=(0,0,-.1),centerTop=(0,0,.1),radius=.05)
i get the following error:
AttributeError Traceback (most recent call
last)
/usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
----> 1
2
3
4
5
AttributeError: 'module' object has no attribute 'inCone'
and iḿ not sure what i have to do, because there isnt any direction and file like this
/usr/lib/yade-daily/py/yade/__init__.pyc
which is
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.