48#include "math/Triangle.hpp"
53 normal_(V3Zero), centroid_(V3Zero), area_(0.0), mass_(0.0),
54 facetVelocity_(V3Zero), a_(V3Zero), b_(V3Zero), c_(V3Zero),
55 HaveArea_(false), HaveNormal_(false), HaveUnitNormal_(false),
56 HaveCentroid_(false) {}
58Triangle::Triangle(Vector3d P1, Vector3d P2, Vector3d P3) :
59 mass_(0.0), facetVelocity_(V3Zero), HaveArea_(false), HaveNormal_(false),
60 HaveUnitNormal_(false), HaveCentroid_(false) {
74void Triangle::addVertices(Vector3d P1, Vector3d P2, Vector3d P3) {
85RealType Triangle::computeArea() {
87 area_ = getNormal().
length() * 0.5;
91Vector3d Triangle::computeNormal() {
93 normal_ =
cross(a_, b_);
97Vector3d Triangle::computeUnitNormal() {
98 HaveUnitNormal_ =
true;
99 unitnormal_ =
cross(a_, b_);
100 unitnormal_.normalize();
104Vector3d Triangle::computeCentroid() {
105 HaveCentroid_ =
true;
106 centroid_ = (vertices_[0] + vertices_[1] + vertices_[2]) / RealType(3.0);
110Mat3x3d Triangle::computeHydrodynamicTensor(RealType viscosity) {
112 Vector3d v0 = centroid_ - vertices_[0];
116 Vector3d v1 = centroid_ - vertices_[1];
120 Vector3d v2 = centroid_ - vertices_[2];
124 H = hydro_tensor(centroid_, centroid_, vertices_[1], vertices_[0], s0,
126 hydro_tensor(centroid_, centroid_, vertices_[1], vertices_[2], s1,
128 hydro_tensor(centroid_, centroid_, vertices_[2], vertices_[0], s2,
133Mat3x3d Triangle::hydro_tensor(
const Vector3d& ri,
const Vector3d& rj0,
134 const Vector3d& rj1,
const Vector3d& rj2,
135 RealType s, RealType viscosity) {
136 Vector3d v2 = (rj0 + rj1 + rj2) / RealType(3.0);
137 Vector3d dr = ri - v2;
144 G *= 1.0 / (8.0 * 3.14159285358979 * viscosity);
SquareMatrix3< Real > inverse() const
Sets the value of this matrix to the inverse of itself.
static SquareMatrix< Real, Dim > identity()
Real length() const
Returns the length of this vector.
Real lengthSquare() const
Returns the squared length of this vector.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Vector3< Real > cross(const Vector3< Real > &v1, const Vector3< Real > &v2)
Returns the cross product of two Vectors.