You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 line
739 B

  1. #include <stdlib.h>
  2. #include <math.h>
  3. float vcoef(float av, float at, float bv, float bt)
  4. {
  5. float dv,dt;
  6. float f;
  7. #define K 500
  8. dv=av-bv;
  9. dt=at-bt;
  10. f=dv*dv+dt*dt;
  11. return (1.0/(1.0+K*f));
  12. }
  13. void dres(
  14. float av, float at, float bv, float bt,
  15. float cv, float ct, float dv, float dt,
  16. float *v , float *t)
  17. {
  18. float wab,wac,wda,wbc,wbd,wcd;
  19. wab=vcoef(av,at,bv,bt);
  20. wac=vcoef(av,at,cv,ct);
  21. wda=vcoef(dv,dt,av,at);
  22. wbc=vcoef(bv,bt,cv,ct);
  23. wbd=vcoef(bv,bt,dv,dt);
  24. wcd=vcoef(cv,ct,dv,dt);
  25. *v=(wab*(av+bv)+wac*(av+cv)+wda*(dv+av)+wbc*(bv+cv)+wbd*(bv+dv)+wcd*(cv+dv))/(2.0*(wab+wac+wda+wbc+wbd+wcd));
  26. *t=(wab*(at+bt)+wac*(at+ct)+wda*(dt+at)+wbc*(bt+ct)+wbd*(bt+dt)+wcd*(ct+dt))/(2.0*(wab+wac+wda+wbc+wbd+wcd));
  27. }