From 51040fd36416ddb81564defcceff23dbf9f37b74 Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Thu, 21 Apr 2005 12:24:41 +0000 Subject: [PATCH] added term to internal force in order to deny area=0 for each face. --- apps/test/segmentation3d/segmentator.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/test/segmentation3d/segmentator.h b/apps/test/segmentation3d/segmentator.h index 0ffed032..480b649b 100644 --- a/apps/test/segmentation3d/segmentator.h +++ b/apps/test/segmentation3d/segmentator.h @@ -105,6 +105,7 @@ public: public: bool intersected; float kdihedral; + ScalarType AreaRep; MyFace() { @@ -116,10 +117,8 @@ public: { __super::Init(k,mass); kdihedral=k_dihedral; - //if (!intersected) + AreaRep=((V(1)->RPos() - V(0)->RPos()) ^ (V(2)->RPos() - V(0)->RPos())).Norm(); SetS(); - /*if (QualityFace()<0.1f) - ClearS();*/ } bool IsActive() @@ -204,6 +203,19 @@ public: } } + ///area changing constrain penalize area goes to zero + CoordType m0=(V(0)->P()+V(1)->P())/2.f; + CoordType m1=(V(1)->P()+V(2)->P())/2.f; + CoordType m2=(V(2)->P()+V(0)->P())/2.f; + m0=(V(2)->P()-m0).Normalize();//directions + m1=(V(0)->P()-m1).Normalize(); + m2=(V(1)->P()-m2).Normalize(); + ScalarType FArea=AreaRep/Area()*_k; + V(0)->IntForce()+=m0*FArea/3.f; + V(1)->IntForce()+=m1*FArea/3.f; + V(2)->IntForce()+=m2*FArea/3.f; + ///end area constrain + return(__super::Update()); ///new //double stretch;