LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Knob Eyeballs

Solved!
Go to solution

Hello All,

Anyone who went to NI week and watched the fastest LabVIEW developer championship knows exactly what it is I am referring to when I say Knob Eyeballs.  The task was to create a VI that had two Indicator knobs.  These knobs were supposed to represent eyballs.  Their purpose, to appear as though they are following the mouse cursor's movement.  So where the mouse went, the knobs were to appear as though they were looking at and followed it's every movement.  Both developers approached this the exact same way (which is probably really the only way) where they created an event structure and the event was mouse movement.  From there, the event structure supplies both the vertical and horizontal values.  However, the winner (sorry man, I forgot your name so I'll call you Person A) only supplied the horizontal to the knobs and when asked display, naturally he only moved his mouse form left to right.  Thus the knobs did indeed follow the mouse, but only left to right.  But the knobs can only do that to a small amount of accuracy before they are no longer "looking at the cursor."  Say you move your mouse to the edge of the screen where the value will be 0, the knobs will be "looking down."   Anyways, I have been putting way too much thought into this and I figured I'd allow the LabVIEW community take a stab it.  I say props to the winner, but the other guy (Person B) was trying to incorporate both x and y coordinates into his knobs and may have been unfairly beaten (Person B ended up winning the whole thing anyways, so w/e).  Can you do 360 degree knobs?  Anyone got a much better and a lot more accurate way to do this?

0 Kudos
Message 1 of 34
(7,436 Views)

My initial thoughts to all this is to use the x,y coords to calculate circle coords using sin,cos etc.  But then it hit me, the problem is that the knobs are single dimension 0-n values.  Is it possible to make the knobs dual choord dependent?  Operate them on a x-y plane?

0 Kudos
Message 2 of 34
(7,378 Views)

Adjust range of nobs to [0, 2pi].

Use property nodes to find center of nob (top left corner, control size)

Find position of mouse.

Use center of nob as origin, take screen coordinate system into account and find correct vector. 

Find sin or cos of angle, invert for angle (in radians)

Write value to knob with property node.

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
0 Kudos
Message 3 of 34
(7,374 Views)

Here you go (2009). I cheated a bit by placing the knob on the origin. If you want it to be in an arbitrary position, you need to get its center and subtract that from the coords.

 

Knob Eyes.png


___________________
Try to take over the world!
Message 4 of 34
(7,362 Views)
Solution
Accepted by topic author DailyDose

I went ahead and completed the entire thing.  Two eyeballs that follow the cursor and a mouth to stop it.  🙂

Message 5 of 34
(7,329 Views)

Not sure if it's what you wanted, but I did this in 12 minutes.

 

Had to fix two bugs: I needed to convert the properties to I32 to better do arithmetic, and had swapped X and Y on one of the SUBTRACT functions.

 

But it operates as two independent eyeballs.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 6 of 34
(7,319 Views)

I was "Person B". 🙂 Multiple people have approached me saying they thought Robert's (Person A) solution wasn't complete. Thankfully, it didn't affect the final result of the contest. In truth, I'm glad he put me out of my misery on that question, since I had absolutely no idea how to solve it with both X/Y coordinates...it never even occurred to me to use trig to solve it. Which is kind of sad, given how much I loved trig in high school.

 

Kudos to all the math whizzes on this thread. 🙂

Message 7 of 34
(7,272 Views)

Yes, using complex math is the way to go for a minimalist approach. Here's my quick attempt at all this. 😄

 

 

(Of course the FOR loop could be folded into a two-element complex array constant once the FP layout is finalized)

 

 

Download All
Message 8 of 34
(7,240 Views)

@altenbach wrote:

Yes, using complex math is the way to go for a minimalist approach. Here's my quick attempt at all this. 😄


@ Altenbach... bow.gifbow.gifbow.gifbow.gifbow.gifbow.gifbow.gif


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 9 of 34
(7,220 Views)

Of course, the real question is what would happen if it came to a duel?
Who would be the fastest? Maybe this VI (8.0) helps with that question?


___________________
Try to take over the world!
Message 10 of 34
(7,201 Views)