Jump to content

Sign in to follow this  
dimon

Construction of direct lines bresenham's algorithm.

Recommended Posts

Construction of direct lines bresenham's algorithm.

func_line_algorithm

  Reveal hidden contents

example

arr = [];
mark = [markerpos "m2",markerpos "m3",markerpos "m3_1",markerpos "m3_2",markerpos "m3_3",markerpos "m3_4" ,markerpos "m2"];
arr = [mark,10,0,nil ,nil,nil,nil,nil] call func_line_algorithm;

arr = [];
mark = [markerpos "m2",markerpos "m3",markerpos "m3_1",markerpos "m3_2",markerpos "m3_3",markerpos "m3_4" ];
arr = [mark,10,0,nil ,nil,nil,nil,nil] call func_line_algorithm;

7aceeba0ed3a8301aad331ba0ce59b70.jpeg

8a77dfdc712863e7df976d0ebf34491a.jpeg

Share this post


Link to post
Share on other sites

2. Autor VVL99

the 2nd method is more easier, more economical and more practical:

there is one marker of the rectangle with width 0 and with the right rotation between points.

http://www.flashpoint.ru/attachments/arma2rft-2015-03-24-00-24-11-361-jpg.54285/ (300 kB)

fnc_line = {
#define gpa(a,b,c) (((getpos a select c)+(getpos b select c))/2)
*** ***private ["_ob1","_ob2","_mm"];
*** *** _ob1 = _this select 0;
*** *** _ob2 = _this select 1;
*** *** _mm = _this select 2;
*** *** _mm setMarkerShape "RECTANGLE";
*** *** _mm setMarkerBrush "border";
*** *** _mm setMarkerColor "ColorRed";
*** *** _mm setMarkerDir ([_ob1, _ob2] call BIS_fnc_DirTo);
*** *** _mm setmarkerpos [gpa(_ob2,_ob1,0),gpa(_ob2,_ob1,1),0];
*** *** _mm setMarkerSize [0,(_ob1 distance _ob2)/2];
};
_mm = createMarker ["mm",getpos player];
[s1,s2,"mm"] call fnc_line;

s1 - object, s2 - object, "mm" - marker

example

Share this post


Link to post
Share on other sites

rewrote the function

fnc_line = {
   fnc_line1 = {
   #define gpa(a,b,c) (((a select c)+(b select c))/2)
       private ["_ob1","_ob2","_m"];

       _ob1 = if ( typename (_this select 0) == "OBJECT" ) then {getpos (_this select 0)} else {if (typename (_this select 0) == "STRING") then {markerpos  (_this select 0) }else{_this select 0};};
       _ob2 = if ( typename (_this select 0) == "OBJECT" ) then {getpos (_this select 1)} else {if (typename (_this select 1) == "STRING") then {markerpos  (_this select 1) }else{_this select 1};};
       _color = _this select 2;
       _m = createMarker [str random(10000),[0,0]];
       _m setMarkerShape "RECTANGLE";
       _m setMarkerBrush "border";
       _m setMarkerColor _color;
       _m setMarkerDir ([_ob1, _ob2] call BIS_fnc_DirTo);
       _m setmarkerpos [gpa(_ob2,_ob1,0),gpa(_ob2,_ob1,1),0];
       _m setMarkerSize [0,(_ob1 distance _ob2)/2];
   };

   _arr1 = [];
   {
       if (_forEachIndex != ((count (_this select 0)) - 1)) then {
           _arr1 set [count _arr1,([_x, ((_this select 0) select (_forEachIndex +1)),_this select 1] call fnc_line1)];          
       };
   } foreach (_this select 0);
   _arr1
};


mark = ["m1","m2","m4","m3","m1"];
//mark = [s1,s2,s3,s4];
[mark,"ColorRed"] call fnc_line;

  • Like 1

Share this post


Link to post
Share on other sites
  On 3/25/2015 at 5:08 AM, dimon said:

rewrote the function

fnc_line = {
    fnc_line1 = {
    #define gpa(a,b,c) (((a select c)+(b select c))/2)
        private ["_ob1","_ob2","_m"];

        _ob1 = if ( typename (_this select 0) == "OBJECT" ) then {getpos (_this select 0)} else {if (typename (_this select 0) == "STRING") then {markerpos  (_this select 0) }else{_this select 0};};
        _ob2 = if ( typename (_this select 0) == "OBJECT" ) then {getpos (_this select 1)} else {if (typename (_this select 1) == "STRING") then {markerpos  (_this select 1) }else{_this select 1};};
        _color = _this select 2;
        _m = createMarker [str random(10000),[0,0]];
        _m setMarkerShape "RECTANGLE";
        _m setMarkerBrush "border";
        _m setMarkerColor _color;
        _m setMarkerDir ([_ob1, _ob2] call BIS_fnc_DirTo);
        _m setmarkerpos [gpa(_ob2,_ob1,0),gpa(_ob2,_ob1,1),0];
        _m setMarkerSize [0,(_ob1 distance _ob2)/2];
    };

    _arr1 = [];
    {
        if (_forEachIndex != ((count (_this select 0)) - 1)) then {
            _arr1 set [count _arr1,([_x, ((_this select 0) select (_forEachIndex +1)),_this select 1] call fnc_line1)];          
        };
    } foreach (_this select 0);
    _arr1
};


mark = ["m1","m2","m4","m3","m1"];
//mark = [s1,s2,s3,s4];
[mark,"ColorRed"] call fnc_line;

 

Nice one!

 

This will save me many, MANY hours marking out AO's.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×