[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Difficulty with createLine
From: |
Thomas D. Dean |
Subject: |
Re: Difficulty with createLine |
Date: |
Thu, 2 Jun 2016 14:52:41 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 |
On 06/02/2016 01:41 PM, Thomas D. Dean wrote:
I have two scripts that create lines, using the same data, but different
calls and I get different lines when I think I should be getting the
same line.
The first set of data comes from a complicated calculation.
octave:1027> relTgtPosit
relTgtPosit =
95.0000 16.0000
80.2279 -3.8953
65.4558 -23.7906
53.4611 -31.3488
29.4717 -46.4653
5.4823 -61.5818
relTgtLeg =
createLine([relTgtPosit(1,:),relTgtPosit(3,:);relTgtPosit(3,:),relTgtPosit(6,:)])
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))
The second set of data comes from direct assignment
T1 = [95.0000 16.0000]
T2 = [80.2279 -3.8953]
T3 = [65.4558 -23.7906]
lineT = createLine(T1,T3);
In this call to createLine, I am passing two points and createLine does
the right thing.
figure; hold on; axis([0 120 -80 20]);
grid
drawLine(relTgtLeg(1,:), 'color', 'b')
drawLine(lineT, 'color', 'c')
hold off