[R] Enumerating unit cell traversals Re: Interpolate? a line

Rainer M Krug r.m.krug at gmail.com
Wed Sep 15 15:30:07 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 15/09/10 15:23, David Winsemius wrote:
> 
> On Sep 15, 2010, at 8:58 AM, Rainer M Krug wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 15/09/10 14:46, Michael Bedward wrote:
>>> Nice posts David. I like the way that 'simple' problems such as this
>>> one give rise to an interesting assortment of approaches and gotchas
>>> :)
>>>
>>> Michael
>>>
>>> On 15 September 2010 22:41, David Winsemius <dwinsemius at comcast.net>
>>> wrote:
>>>>
>>>> On Sep 15, 2010, at 7:55 AM, David Winsemius wrote:
>>>>
>>>>>
>>>>> On Sep 15, 2010, at 7:24 AM, David Winsemius wrote:
>>>>>
>>>>>> Replacing context:
>>>>>>
>>>>>>>> Hello everyone.
>>>>>>>> I have created a 100*100 matrix in R.
>>>>>>>> Let's now say that I have a line that starts from (2,3) point
>>>>>>>> and ends
>>>>>>>> to the
>>>>>>>> (62,34) point. In other words this line starts at cell (2,3) and
>>>>>>>> ends
>>>>>>>> at cell
>>>>>>>> (62,34).
>>>>>>>>
>>>>>>>> Is it possible to get by some R function all the matrix's cells
>>>>>>>> that
>>>>>>>> this line
>>>>>>>> transverses?
>>
>> This is a known problem in computer graphics and the algorythm used to
>> identify these cells is the "Bresenham's Line Drawing Algorithm"
>>
>> You can check out one version at
>>
>> http://www.falloutsoftware.com/tutorials/dd/dd4.htm
>>
>> or
>>
>> http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
> 
> After viewing the Wikipedia description and the illustration I think
> that may not be the same problem. Note that the cells traversed only at
> their very outer corners do not get chosen. The goal is to "approximate
> a line" rather than to enumerate traversals.

You might actually be right.

Cheers,

Rainer
> 


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:        +33 - (0)9 53 10 27 44
Cell:       +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:      Rainer at krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyQyl8ACgkQoYgNqgF2egpdnACfS3zQX3MUAPraxIm5ExbFcnQu
bdYAn0vpYs3Gy2XmutNoJQKaVVZ+hnYH
=ByN/
-----END PGP SIGNATURE-----



More information about the R-help mailing list