LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I rotate a box?

I have a rectangle that yellow and red lines create. I want to rotate this box in any direction, is that possible?캡처.PNG

Download All
0 Kudos
Message 1 of 8
(4,044 Views)

Check out if there is any option called transpose in your graph !!

0 Kudos
Message 2 of 8
(4,019 Views)

Do you want to rotate the data enclosed in the box or do you want to rotate the lines, selecting a rectangle that is not aligned with the axes?

 

Cursors cannot have arbitrary angles, but you can use the plot images tools to draw any lines you want. (Start here)

0 Kudos
Message 3 of 8
(3,989 Views)

So, looking at this it seems you want to graph the data of an arbitrarily rotated rectangle on the top graph. Using the plot images overlay, you can draw a box and using mouse downe/move, etc. events (or external controls) you can manipulate its position and angle. You still have the problem that the pixels form a rectangular grid, so for rotations that are not quantized to right angles, you need to do e.g. a bilinear interpolations.

 

In the meantime, simplify your code. Do the cursors change during the run? If not, all the cursor math (except the subset) belong before the loop. Index array is resizeable., unbundle by name is resizeable, etc.

 

Here's a literal simplification of your code. Think about taking the cursor math before the loop, though.

SImplify.png

 

Of course it is not efficient to read and process each file twice in a row, so here's what you could do instead:

 

PictureSubset.png

0 Kudos
Message 4 of 8
(3,933 Views)

@altenbach wrote:

So, looking at this it seems you want to graph the data of an arbitrarily rotated rectangle on the top graph

here's a hacky, probably not very efficent, implementation for arbitrary rectangles:

hacky_generic_rect.png

0 Kudos
Message 5 of 8
(3,913 Views)

Here's a simplified version that shows the general idea of "plot images". (selection square is defined by one side (i.e. two cursors), interpolation is "nearest", graph is sized for 1:1 data/pixel avoiding scaling, etc.).

 

Of course in real code we would use an event structure and only do the calculations and updates when something changes. (Not shown).

 

It is easy to expand to arbitrary scaling and more complicated shapes (e.g. rectangle, circle, etc)

 

ArbitrarySquareSelection.png

Message 6 of 8
(3,899 Views)

Note that we can simplify the code if we invert the Y axis, placing 0,0 in the top left corner. (you still need to implement scaling if the pixesl and array elements are not 1:1, of course. Not shown).

 

ArbitrarySquareSelection3.png

Message 7 of 8
(3,867 Views)

@altenbach wrote:

(you still need to implement scaling if the pixesl and array elements are not 1:1, of course. Not shown).

 

 


0# conveniently, this approach is independent from the origin of the Frontpanel.

so for the proper scaling:

1# I set the x-max to the number of rows, and the y-max to the number of columns

2# then multiply the 4 square points by the quotient of Plot Area size and 2d Array size (width;hight) / (rows/columns)

(oh, I realize I could do the multiplication outside of the for loop ... Smiley Frustrated)

2019-10-21_193731_scaling-applied.png

 

 

0 Kudos
Message 8 of 8
(3,776 Views)