LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

interpolate 1D Array with a square

Solved!
Go to solution

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.

 

Download All
0 Kudos
Message 1 of 7
(2,497 Views)
Solution
Accepted by GregFreeman

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?

 

(Thanks Darin)

--
Tim Elsey
Certified LabVIEW Architect
Message 2 of 7
(2,477 Views)

For a square it is simple:

 

PointInSquare.png

 

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.

Message 3 of 7
(2,474 Views)

@elset191 wrote:

 How quickly we forget, eh?

 

(Thanks Darin)


Can't forget if I never knew! Smiley Very Happy 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.

0 Kudos
Message 4 of 7
(2,463 Views)

for(imstuck) wrote:

Can't forget if I never knew! Smiley Very Happy 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!

Message 5 of 7
(2,456 Views)

@for(imstuck) wrote:

for(imstuck) wrote:

Can't forget if I never knew! Smiley Very Happy 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.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 6 of 7
(2,453 Views)

@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. 

0 Kudos
Message 7 of 7
(2,440 Views)