From 3a018d380395889059bf582015fb2935a9a20fb0 Mon Sep 17 00:00:00 2001 From: mihaf <miha.fosnaric@gmail.com> Date: Thu, 27 Feb 2014 14:55:13 +0000 Subject: [PATCH] Bug found and removed: polys now also translated when origin moves to the center of mass. All seems OK after firt testing. :) --- src/energy.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/energy.c b/src/energy.c index 4d93753..440f319 100644 --- a/src/energy.c +++ b/src/energy.c @@ -20,6 +20,14 @@ } +inline ts_bool bond_energy(ts_bond *bond,ts_poly *poly){ +//TODO: This value to be changed and implemented in data structure: + ts_double d_relaxed=1.0; + bond->energy=poly->k*pow(bond->bond_length-d_relaxed,2); + return TS_SUCCESS; +}; + + inline ts_bool energy_vertex(ts_vertex *vtx){ // ts_vertex *vtx=&vlist->vertex[n]-1; // Caution! 0 Indexed value! // ts_triangle *tristar=vtx->tristar-1; @@ -28,7 +36,7 @@ ts_uint jjp,jjm; ts_vertex *j,*jp, *jm; ts_triangle *jt; - ts_double s=0,xh=0,yh=0,zh=0,txn=0,tyn=0,tzn=0; + ts_double s=0.0,xh=0.0,yh=0.0,zh=0.0,txn=0.0,tyn=0.0,tzn=0.0; ts_double x1,x2,x3,ctp,ctm,tot,xlen; ts_double h,ht; for(jj=1; jj<=vtx->neigh_no;jj++){ @@ -72,7 +80,9 @@ #endif tot=ctp+ctm; tot=0.5*tot; + xlen=vtx_distance_sq(j,vtx); +/* #ifdef TS_DOUBLE_DOUBLE vtx->bond[jj-1]->bond_length=sqrt(xlen); #endif @@ -84,7 +94,7 @@ #endif vtx->bond[jj-1]->bond_length_dual=tot*vtx->bond[jj-1]->bond_length; - +*/ s+=tot*xlen; xh+=tot*(j->x - vtx->x); yh+=tot*(j->y - vtx->y); -- Gitblit v1.9.3