LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get square corners

Solved!
Go to solution

This is the route I took to get 4 corners of a square if I have the center and the width/height. Is there a simpler way, or a VI that does this that I missed? Sometimes there are VIs that do similar things drawing palette and I'm wondering if it went overlooked.

 

0 Kudos
Message 1 of 8
(4,270 Views)

OpenG has a rectangle palette which exposes some vi.lib VIs to deal with rect sizes. I don't remember if they have this specific functionality or where they live in vi.lib (and, of course, you already have the functionality), but it's an option.

 

Another option which might work is to take the calculated distances and multiply them by combinations of -1 and 1 and add that to the center. This should probably allow you to get rid of the loop and simplify the code to a single multiplication and addition.

 

 


___________________
Try to take over the world!
0 Kudos
Message 2 of 8
(4,261 Views)

If it is a square, the width and height are the same, so we have redundant/conflicting information.

If it is not a  square, your angles are wrong.

 

Are you looking for rectangle solution?

0 Kudos
Message 3 of 8
(4,250 Views)
Solution
Accepted by GregFreeman

Here's what I would do. (I think tst had a similar idea).

 

You could even get rid of the /2 and simply add 0.5, -0.5, etc into the diagram constant.

 

 

 

(of course you don't need the graph code)

 

 

Message 4 of 8
(4,239 Views)

@altenbach wrote:

Here's what I would do. (I think tst had a similar idea).

 

You could even get rid of the /2 and simply add 0.5, -0.5, etc into the diagram constant.

 

 

 

(of course you don't need the graph code)

 

 


It's a square, but the VI might as well handle rectangles as well. Thanks!

0 Kudos
Message 5 of 8
(4,208 Views)

@GregFreeman wrote:
It's a square, but the VI might as well handle rectangles as well. Thanks!

The nice thing is that the LabVIEW polymorphism allows handing the simplified square code with a very small change 😄

 

 

0 Kudos
Message 6 of 8
(4,196 Views)

LOL and here I thought I was going to get tips on how to clean up your block diagram!  😉  (You know, "square corners.")

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 8
(4,160 Views)

@altenbach wrote:

Here's what I would do. (I think tst had a similar idea).


Yes, that was my second idea.

 

Looking at the OpenG palette, I see that my first idea was not as elegant. I didn't try hard, but this was the cleanest I managed with those VIs:

 

RectCenter.png

 

It might be cleaner to subtract half the size from the center and use a single subVI and no unbundling.

 

While these VIs are clearly not optimal for this particular task, it's probably worth knowing them for other things. They live in vi.lib\picture.


___________________
Try to take over the world!
0 Kudos
Message 8 of 8
(4,076 Views)