Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. /*
  2. File: fnc_spiral.sqf
  3. Author: ArseniyK
  4. Used scripts:
  5.  
  6. Description:
  7. Creating spiral
  8.  
  9. Parameter(s):
  10. _this select 0: position (Array)
  11. _this select 1: step (Number)
  12. (_this select 2) select 0: min radius (Number)
  13. _maxrad = (_this select 2) select 1: max radius
  14.  
  15. Returns:
  16. Array - format PositionASL
  17. */
  18. private ["_pos","_step","_minrad","_maxrad","_posx","_a","_posy","_x","_y","_arr","_debug","_r","_tx","_ty","_len","_k"];
  19.  
  20. _pos = _this select 0;
  21. _step = _this select 1;
  22. _minrad = (_this select 2) select 0;
  23. _maxrad = (_this select 2) select 1;
  24. _debug = false;
  25. //=============Creating spiral=============//
  26. step = _step;
  27. _a = -0.3* step;
  28. _posx = _pos select 0;
  29. _posy = _pos select 1;
  30. _x = _minrad;
  31. _y = 1;
  32. _arr=[];
  33. for [{_i=0},{true},{_i=_i+1}] do
  34. {
  35. _r = sqrt (_x*_x+_y*_y);
  36. _tx = _a*_x+_r*_y;
  37. _ty = _a*_y - _r*_x;
  38. _len = sqrt(_tx*_tx + _ty*_ty);
  39. _k = step/_len;
  40. _x = _x + _tx*_k;
  41. _y = _y + _ty*_k;
  42. _arr set [_i,[_x+_posx,_y+_posy,getTerrainHeightASL [_x+_posx, _y+_posy]]];
  43. if (((ASLToATL (_arr select _i)) distance _pos) >= _maxrad) exitwith {};
  44. };
  45. if _debug then
  46. {
  47. {
  48. call compile format ["
  49. _m%1 = createMarker[""markerRed%1"",[ _x select 0,_x select 1]];
  50. _m%1 setMarkerShape ""ICON"";
  51. _m%1 setMarkerType ""DOT"";
  52. _m%1 setmarkercolor ""Colorred""; ",_forEachIndex];
  53. } foreach _arr;
  54. };
  55. _arr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement