LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate random curves in picture control?

Solved!
Go to solution

Hi,

 

I am still in the process of learning LV. My current goal is having a circle drawn in picture control move while following the trajectory of a curved line. The catch is that I want that each time I run the VI a new different trajectory is programatically created for my circle.

 

I have no idea how to approach this problem.

 

In a similar VI, I had balls moving in linear fashion, so I simply added a speed component to the position component of my balls. I initially though to use the same design here, but I can't design a set of rules that would make the change in position result in a curved line trajectory. I think generating an array of the entire trajectory before each run would probably work better here, but I can't think of a function to do it either. Playing with basic trig resulted in sinusiodal or curved trajectory, but nothing really random aside from amplitude and period.

 

Ideally, I want as much variance in trajectory as possible (ex: a function that could give me S-shaped, U-shaped, spiral-shaped, loop-shaped, etc.) while still retaining control over certain parameters (lenght, position, max dX, etc.)

 

Anyone has an idea?

 

Thank you!

0 Kudos
Message 1 of 4
(3,174 Views)

Time is a "thing" in LabVIEW.  A Picture is an area of 2D space.  A point in this space can be described in Cartesian coordinates as [X(t), Y(t)], or in polar coordinates as [R(t), Theta(t)].

 

To make a point move in 2D space, express its coordinates (either Cartesian or Polar) as a function of t.  Change the function, you get a different curve.  For example R(t) = 1, Theta(t) = 2*pi*t will give you a point moving in a circle of radius 1 and going around once/second (assuming t is in seconds), while R(t) = t/20, Theta(t) = 2*pi*t will give you a spiral.

 

Bob Schor

0 Kudos
Message 2 of 4
(3,163 Views)
Hi Bob,

Thanks for your answer. I've thought about but what I want to generate is an "unpredictable" curved trajectory. So having one run be sinusoidal, another in spiral, etc is not satisfactory.

What I seek to generate is a trajectory with no apparent pattern, but that is easy to follow with a finger (hence having smooth curves instead of angular corners.

Giving it some more thought, I think having a vector that changes angle to but progressively over time would be the easiest to program. I'm still not sure to do that though. I'll see if I can come up with something tomorrow
0 Kudos
Message 3 of 4
(3,155 Views)
Solution
Accepted by topic author julmich

Sounds like a Random Walker.  Here's one I just made up.  At every time point (0.1 sec in this example), it takes a unit step in some direction, with the direction changing by a random amount within some angular range.  It can get pretty wild ...

Random Walker.png

Bob Schor

 

Message 4 of 4
(3,105 Views)