Advertisement
federgraph

federgraph-special-sample-scilab-3D

Oct 16th, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 1.27 KB | None | 0 0
  1. //federgraph-special-sample-scilab-3D.sce
  2. //this file contains code for scilab 5.5.1
  3.  
  4. //the sample contains the special case, see federgraph.blogspot.de
  5.  
  6. funcprot(0)
  7. function z = f(x, y)
  8. //the terms under the root    
  9. a1 = (x-x1)^2 + (y-y1)^2;
  10. a2 = (x-x2)^2 + (y-y2)^2;
  11. a3 = (x-x3)^2 + (y-y3)^2;
  12. //actual length of springs
  13. t1 = sqrt(a1);
  14. t2 = sqrt(a2);
  15. t3 = sqrt(a3);
  16. //expansion of springs
  17. f1 = (t1-l);
  18. f2 = (t2-l);
  19. f3 = (t3-l);
  20. //x-components of force
  21. u1 =f1 * (x-x1) / t1;
  22. u2 =f2 * (x-x2) / t2;
  23. u3 =f3 * (x-x3) / t3;
  24. //y-components of force
  25. v1 = f1 * (y-y1) / t1;
  26. v2 = f2 * (y-y2) / t2;
  27. v3 = f3 * (y-y3) / t3;
  28. //sum of components
  29. u = u1 + u2 + u3;
  30. v = v1 + v2 + v3;
  31. //absolute value of resultant force
  32. z = sqrt(u^2 + v^2);
  33. endfunction
  34. funcprot(0)
  35.  
  36. //de.wikipedia.org/wiki/Gleichseitiges_Dreieck
  37. //setup of the constant equilateral triangle
  38. a = 100; //side length
  39. w3 = sqrt(3); //Wurzel 3
  40. h = w3/2 * a; //height
  41. ro = w3/3 * a; //radius of outer circle
  42. ri = w3/6 * a; //radius of inner circle
  43.  
  44. //coordinates of the triangle, where the springs are attached
  45. x1 = -a/2;  
  46. x2 =  a/2;  
  47. x3 = 0;
  48. y1 = -ri;
  49. y2 = -ri;
  50. y3 = ro;
  51.  
  52. l = h;
  53.  
  54. clf()
  55. n = 128; //number of points
  56. x=linspace(-100,100,n);
  57. y=linspace(-100,100,n);
  58. z=feval(x,y,f)';
  59. surf(x, y, z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement