help-octave
[Top][All Lists]
Advanced

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

Re: Difficulty with createLine


From: Juan Pablo Carbajal
Subject: Re: Difficulty with createLine
Date: Fri, 3 Jun 2016 00:15:10 +0200

On Thu, Jun 2, 2016 at 11:52 PM, Thomas D. Dean <address@hidden> wrote:
> relTgtPoist was created as an array of points.  I think Octave simplified
> this array.  In this call to createLine, I am passing an array with 4 values
> per row and createLine treats the 4 values as [x,y,dx,dy] when I thought I
> was passing [P1, P2].  sigh.
> I should call
>
> createLine(relTgtPosit(1,1),relTgtPosit(1,2),...
>  relTgtPosit(3,1)-relTgtPosit(1,1),...
>  relTgtPosit(3,2)-relTgtPosit(1,2))
> createLine(relTgtPosit(4,1),relTgtPosit(4,2),...
>  relTgtPosit(6,1)-relTgtPosit(4,1),...
>  relTgtPosit(6,2)-relTgtPosit(4,2))
>
> or, is this the best I can to to vectorize this?
> idx=[1;4]; ## how do I generalize this???
> createLine(relTgtPosit(idx,1),relTgtPosit(idx,2),...
>  relTgtPosit(idx+2,1)-relTgtPosit(idx,1),...
>  relTgtPosit(idx+2,2)-relTgtPosit(idx,2))

What information is in your array relTgtPosit? origin and direction?
or target position and source position?
Best way is to organize your complicated script/function such that the
ouput comes in the right format.

Anyways, it seems your array has positions so createLine(P1, P2)
should be the right call.
To organize the data you could do

P1_idx = [1 4];
P2_idx = [3 6];
P1       = relTgtPosit (P1_idx,:);
P2       = relTgtPosit (P2_idx,:);
L          = createLine (P1, P2);

There is no way to generalize the creation of the indexes, because you
only know that. If you build your array in a programamtic way, then
you already have your indexes. and this step is trivial.



reply via email to

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