10-03-2011 03:41 PM
I know that to measure distance between a set of points the equation is SQRT((x2-x1)^2+(y2-y1)^2)
I want to double the length of a line a-b for a new line a-c. How do I solve for c? Is there something in vi.lib?
Solved! Go to Solution.
10-03-2011 03:47 PM
This stuff was a looonnng time ago for me, but assuming a is common, wouldn't c just be 2b-a (calculated on a per x and y basis), without needing the squares and roots?
Michael
10-03-2011 03:57 PM - edited 10-03-2011 04:00 PM
That might work but I think it falls apart with angled lines.
10-03-2011 04:30 PM - edited 10-03-2011 04:31 PM
10-03-2011 04:38 PM
So you have two points. A and B. They make a line segment AB and have length ||AB|| = sqrt ( (b_x - a_x) ^ 2 + (b_y - a_y ) ^ 2 ).
You want to make a second point C such that ||AC|| = 2 ||AB||.
Then you say some nonesense about angled lines. Solving for C seems pretty easy to me.
Just compute C = 2 * ( B - A ) + A. Where B and A are points (i.e. clusters with an X numeric and Y numeric).
Also, there is a function in IMAQ called IMAQ Point Distances which find N - 1 distances between a list of length N points.
10-03-2011 04:46 PM - edited 10-03-2011 04:47 PM
You did not really specify what datatype "points" are. (in my book I always use complex in 2D :))
The solution by majoris is basically the same as mine, except for the datatype. For the special case of "doubling", we can go even simpler. 😄
10-03-2011 04:50 PM
10-03-2011 05:33 PM
@majoris wrote:
So you have two points. A and B. They make a line segment AB and have length ||AB|| = sqrt ( (b_x - a_x) ^ 2 + (b_y - a_y ) ^ 2 ).
Then you say some nonesense about angled lines. Solving for C seems pretty easy to me.
Well maybe it is nonsense. Other than that thanks for your answer.
Who to give the accepted solution to? Darins was the smallest and simplest. In fact it is so simple that I regret asking
10-04-2011 07:18 AM
> That might work but I think it falls apart with angled lines.
Now why would you post something that proves my point? 🙂 (Sqrt of 200 is 14.142...)