71 Triangle(Vector3d P1, Vector3d P2, Vector3d P3);
72 virtual ~Triangle() {};
74 void setUnitNormal(Vector3d normal) {
76 HaveUnitNormal_ =
true;
79 void addVertices(Vector3d P1, Vector3d P2, Vector3d P3);
81 void addVertexSD(
StuntDouble* thisSD) { vertexSD_.push_back(thisSD); }
83 std::vector<StuntDouble*> getVertices() {
return vertexSD_; }
85 void setArea(RealType area) {
90 Vector3d getNormal() {
94 return computeNormal();
97 Vector3d getUnitNormal() {
98 if (HaveUnitNormal_) {
101 return computeUnitNormal();
106 std::swap(vertices_[1], vertices_[2]);
109 a_ = vertices_[0] - vertices_[1];
110 b_ = vertices_[0] - vertices_[2];
111 c_ = vertices_[1] - vertices_[2];
113 HaveUnitNormal_ =
false;
121 return computeArea();
125 RealType computeArea();
126 Vector3d computeNormal();
127 Vector3d computeCentroid();
128 Vector3d computeUnitNormal();
130 void setCentroid(Vector3d centroid) {
131 centroid_ = centroid;
132 HaveCentroid_ =
true;
135 Vector3d getCentroid() {
139 return computeCentroid();
143 Vector3d getFacetVelocity() {
return facetVelocity_; }
145 void setFacetVelocity(Vector3d facetVelocity) {
146 facetVelocity_ = facetVelocity;
149 void setFacetMass(RealType mass) { mass_ = mass; }
151 RealType getFacetMass() {
return mass_; }
153 Vector3d vertex1()
const {
return vertices_[0]; }
154 Vector3d vertex2()
const {
return vertices_[1]; }
155 Vector3d vertex3()
const {
return vertices_[2]; }
157 RealType a() {
return a_.
length(); }
159 RealType b() {
return b_.length(); }
161 RealType c() {
return c_.length(); }
163 RealType getHydroLength() {
167 RealType t1 = a1 + b1 + c1;
168 RealType t4 = a1 + b1 - c1;
170 return 32.0 * c1 / log(t1 * t1 / t4 / t4);
173 RealType getIncircleRadius() {
return 2.0 * getArea() / (a() + b() + c()); }
175 RealType getCircumcircleRadius() {
179 RealType t1 = a1 + b1 + c1;
180 RealType t2 = -a1 + b1 + c1;
181 RealType t3 = a1 - b1 + c1;
182 RealType t4 = a1 + b1 - c1;
183 return a1 * b1 * c1 / sqrt(t1 * t2 * t3 * t4);
186 Mat3x3d computeHydrodynamicTensor(RealType viscosity);
188 Vector3d cartesionToBarycentric(Vector3d p) {
189 RealType area = getArea();
191 Vector3d v0 = vertices_[0] - p;
192 Vector3d v1 = vertices_[1] - p;
193 Vector3d v2 = vertices_[2] - p;
196 RealType v = 0.5 *
cross(v0, v2).length() / area;
197 RealType w = 0.5 *
cross(v0, v1).length() / area;
199 return Vector3d(u, v, w);
202 Vector3d barycentricToCartesian(
const Vector3d& barycentric)
const {
203 return barycentric.
x() * vertices_[0] + barycentric.
y() * vertices_[1] +
204 barycentric.
z() * vertices_[2];
208 Mat3x3d hydro_tensor(
const Vector3d& ri,
const Vector3d& rj0,
209 const Vector3d& rj1,
const Vector3d& rj2, RealType s,
213 std::vector<StuntDouble*> vertexSD_;
215 Vector3d unitnormal_;
217 Vector3d vertices_[3];
220 Vector3d facetVelocity_;
225 bool HaveUnitNormal_;