10-24-2011 01:34 PM - edited 10-24-2011 01:41 PM
I am using interpolate 1D array with a square to determine if a point is within that square or outside of it (take xi,yi pair -> interpolate for xi using the array to draw the square, get interpolated y, check if abs(yi) < abs(y)) If there is a better method than this, please let me know. Anyways, the only problem with this is the interpolate 1D array VI it seems will only return the first result it finds, even if there are multiple results. For instance, a square, circle, oval, etc will have 2 y points for any given x point. Any thoughts on ways around this?
Also, I can't just negate the result and check that because I can't guarantee the square will always be centered around 0. The snippet shows what I have so far, without checking against the second limit.
Edit: Stupid snippet tool isn't working. Time to cave in and get the CCT. Anyways, I have attached the VI.
Solved! Go to Solution.
10-24-2011 01:56 PM - edited 10-24-2011 01:57 PM
Hidden inside vi.lib there are VIs called Point in Rect and Point in Oval. I think this might apply to you? How quickly we forget, eh?
10-24-2011 02:02 PM - edited 10-24-2011 02:05 PM
For a square it is simple:
You only need to specify two diagonal points of the square (the rest is gravy).
Edit: This is a slightly cleaner and floating point implementation of the VI that Tim mentions.
10-24-2011 03:18 PM - edited 10-24-2011 03:19 PM
@elset191 wrote:
How quickly we forget, eh?
Can't forget if I never knew! I chose Elset's as the solution because somehow he read my mind and I actually have an oval and square on my plot and whichever is "inside" of the other one at a particular x coordinate is the limit.
10-24-2011 03:26 PM
for(imstuck) wrote:Can't forget if I never knew! I chose Elset's as the solution because somehow he read my mind and I actually have an oval and square on my plot and whichever is "inside" of the other one at a particular x coordinate is the limit.
Scratch that....I actually responded to his nugget. I guess I did know!
10-24-2011 03:27 PM - edited 10-24-2011 03:28 PM
@for(imstuck) wrote:
for(imstuck) wrote:Can't forget if I never knew! I chose Elset's as the solution because somehow he read my mind and I actually have an oval and square on my plot and whichever is "inside" of the other one at a particular x coordinate is the limit.
Scratch that....I actually responded to his nugget. I guess I did know!
Ha, yeah, that's what I was getting at. Oh and I read your mind, because I read your text first, where you mentioned circles and ovals.
10-24-2011 03:57 PM - edited 10-24-2011 03:59 PM
@elset191 wrote:
Oh and I read your mind, because I read your text first, where you mentioned circles and ovals.
True.
Anyways, I realized I was overcomplicating things by trying to figure which line (oval or rectangle) was innermost when it came to determining the limit to look at for a specific coordinate. A simple AND took care of the problem. See below, and please excuse the slight spaghetti.. Thanks again, would have spent a lot of time if I wasn't redirected to these VIs.