37 if (distance2 > distanceMax * distanceMax)
return false;
38 distance = sqrt(distance2);
65 distance = fabs(signedDistance);
68 if (distance >= distanceMax)
return false;
71 const std::array<Vec3D,3> edgeBranch {position -
vertex_[0], position - vertex_[1], position - vertex_[2]};
75 const size_t id = (edgeDistance[1] > edgeDistance[2]) ?
76 (edgeDistance[0] > edgeDistance[1] ? 0 : 1) : (edgeDistance[0] > edgeDistance[2] ? 0 : 2);
79 if (edgeDistance[
id] > distanceMax)
return false;
84 normal = (signedDistance >= 0) ? -faceNormal_ : faceNormal_;
90 if (positionAlongEdge < 0) {
92 distance = edgeBranch[id].getLength();
93 if (distance > distanceMax)
return false;
94 normal = edgeBranch[id] / -distance;
97 const size_t idRight = (
id + 1) % 3;
98 distance = edgeBranch[idRight].
getLength();
99 if (distance > distanceMax)
return false;
100 normal = edgeBranch[idRight] / -distance;
103 normal =
edge_[id] * positionAlongEdge - edgeBranch[id];
105 if (distance > distanceMax)
return false;
113 if (!angularVelocityDt.
isZero())
128 for (
int i = 0;
i < 3;
i++)
142 os <<
" vertexInLabFrame ";
143 for (
int i = 0;
i < 3;
i++)
151 const unsigned long s = vtk.
points.size();
156 std::vector<double> cell;
159 cell.push_back(s + 1);
160 cell.push_back(s + 2);
208 for (
int i = 0;
i < 3;
i++)
221 for (
int i = 0;
i < 3;
i++)
241 const Vec3D branch1 = point - vertex_[1];
242 const Vec3D branch2 = point - vertex_[2];
245 Mdouble s = sqrt(
Vec3D::cross(vertex_[1] - vertex_[0], vertex_[2] - vertex_[1]).getLengthSquared());
250 return (1 > s0 > 0 && 1 > s1 > 0 && 1 > s2 > 0);
bool setDistance(Mdouble &distance, const Vec3D &branch, Mdouble distanceMax)
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void normalise()
Makes this Vec3D unit length.
std::array< Vec3D, 3 > edge_
const std::complex< Mdouble > i
void updateVertexAndNormal()
This function should be called after setting either position_ or vertexInLabFrame_.
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
void writeVTK(VTKContainer &vtk) const override
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
void rotate(Vec3D &position) const
Applies the rotation to a position.
bool isZero() const
Checks if ALL elements are zero.
void read(std::istream &is) override
Reads an TriangleWall from an input stream, for example a restart file.
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
std::array< double, 3 > edgeLength_
Mdouble getWallInteractionRadius(const BaseWall *wall) const
returns the radius plus the interactionDistance
bool isInsideTriangle(const Vec3D &point) const
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override
Compute the distance from the wall for a given BaseParticle and return if there is a collision...
std::vector< std::vector< double > > triangleStrips
void setVertices(Vec3D A, Vec3D B, Vec3D C)
Sets member variables such that the wall represents a triangle with vertices A, B, C.
std::array< Vec3D, 3 > vertex_
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
void write(std::ostream &os) const override
Writes an TriangleWall to an output stream, for example a restart file.
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
std::vector< Vec3D > points
virtual void rotate(const Vec3D &angularVelocityDt)
Rotates this BaseInteractable.
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
void setOrientation(const Quaternion &orientation)
Sets the orientation of this BaseInteractable.
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
std::array< Vec3D, 3 > edgeNormal_
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
void move(const Vec3D &move) override
void rotate(const Vec3D &angularVelocity) override
Rotates this BaseInteractable.
std::array< Vec3D, 3 > vertexInLabFrame_
bool isLocal(Vec3D &min, Vec3D &max) const override
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.