help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Data Manipulation Problem - Vectorization


From: Juan Pablo Carbajal
Subject: Re: Data Manipulation Problem - Vectorization
Date: Tue, 5 Feb 2013 10:03:21 +0100

On Mon, Feb 4, 2013 at 11:27 PM, Thomas D. Dean <address@hidden> wrote:
> On 02/04/13 02:43, Juan Pablo Carbajal wrote:
>
>> If you use the geometry package you can calculate the distances
>> between your points and the polygon defining the square. Of course you
>> could do this by hand as well.
>>
>> Is this helping you?
>
>
> This is it, exactly.
>
> octave:29> A=load('20130202-run1.array');
> octave:30> P1=[0 0; 0 100; -100 100; -100 0; 0 0];
> octave:30> plot(distancePointPolygon([A(:,[5,6])],P1))
>
> Now, I just need to extract the polygon from A(:,[10,11]))
>
> octave5 > n=size(A,1);
> octave:6> idx=A(1:n-1,[10,11]) != A(2:n,[10,11]);
> octave:7> P1=A(2:n,[10,11]);
> octave:8> P1=P1(idx(:,1) != idx(:,2),:)
> ans =
>
>      0   100
>   -100   100
>   -100     0
>      0     0
>   -100     0
>   -100   100
>      0   100
>      0     0
>
> Thanks.
>
> Tom Dean
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

Tom,

Do not forget to answer at the bottom of the messages (local folklore).

If a polygon is sampled redundantly one should use the simplifypolygon
function form the geometry package to get a smaller (if not the
smallest) representation. For some reason I tested with the data in
A(:,[10 11]) and is not giving the expected results. If you want yo
can dig a littel bit inside this to identify if there is a bug.
Otherwise I will do it eventually.

Anyways, for the particular case you have at hand, you can recover the
vertices of the square with

[~, idx] = unique (A(:,[10 11]), "rows"); % Get the row indexes of the
unique elements
idx       = sort (idx);                             % Undo the order
given by unique
square = A (idx, [10 11])
drawPolygon (square, '-o')


reply via email to

[Prev in Thread] Current Thread [Next in Thread]