06-06-2018 04:04 PM
06-06-2018 04:20 PM
First, show us what you've already tried....
In general:
06-07-2018 02:46 AM
To be honest I'm new at Labview programming, so I couldn't make anything. Thank you for your advice. I attach my programm below. It's main goal is to simulate the Freedericks transition and the drawing is only a part of it.
06-07-2018 08:07 AM - edited 06-07-2018 08:11 AM
You have fallen into a common "trap" regarding LabVIEW -- because it is graphical, and "anyone can draw pictures and make lines", many new users assume that they can just "start using it" without understanding the underlying ideas behind LabVIEW, and without knowing the importance of good Style in creating LabVIEW code that (a) is designed to accomplish the given task, (b) is easy to understand and grasp, and (c) actually works.
A good thing to do is to learn LabVIEW. At a bare minimum, spend half a day with the tutorials and other materials listed on the first page of this Forum. If there are exercises, do them all. Schor's Law -- you can't learn programming by reading a book, but you can learn it by writing Programs and getting them critiqued (and learning from your mistakes).
There are many ways to accomplish the task of "rotating a line" (whatever that means!). Here's one way:
Bob Schor
P.S. -- it is a good thing that this is only a small part of a bigger problem. Another Good Idea is to divide a Big Problem into smaller steps, and to tackle the smaller steps in isolation, and often first. The ideas outlined above, however, will also apply to the Main Task, with the added suggestion that breaking it up into sub-Tasks (and, ultimately, into sub-VIs) will greatly improve the likelihood that you will be able to (a) accomplish the coding (as you will be doing many simple things instead of one huge complex thing), (b) understand and be able to explain your code to someone else (a great help in finding bugs and errors), and (c) have your code work correctly.
06-07-2018 04:48 PM
Thank you very much for your help. I actually watched a tutorial which led to my solution. By rotating a line I meant changing its direction by a given angle. I attach my solution below which requires a matrix of angles and later on draws those "molecules" with a given orientation on a 2D plane. The only thing I can't change is to resize the 2D picture indicator to fit it to the size of the "matrix of molecules"
06-08-2018 03:32 PM
Great, you got something to work! Almost, if I understand your last Post.
I decided to "play" with this a little. I defined a Point as a Cluster of X, Y, and defined a Line as an Array of Points. In this example, the line has only 2 points. I wrote 5 very simple sub-VIs that did only one thing --
Here's a Demo that takes a line from 0, 0 to 4, 5 and plots it rotated by 8 multiples of pi/10. Here I plotted all of the lines so you could see it "statically" -- I can also plot it "dynamically" by moving the Graph indicator inside the For Loop, and see the line rotate.
The original line is in White.
A key to getting this to work with relatively little effort was breaking it up into such simple steps that "(almost) nothing can go wrong ...". Here, for example is Rotate about Centroid -- I'll leave the rest as an Exercise for the Reader.
One final note: instead of using Matrices, I used Complex arithmetic.
Bob Schor
P.S. -- now I'm starting to think about 3-D rotations (viewing a projection onto, say, the X-Y Plane) with rotation about the centroid of a "cloud of points" (a line is a "cloud" of two points, and the Specification of the Problem called for plotting lines, not points) about an arbitrarily-oriented axis (specified, say, by Azimuth and Elevation). It would be a little more complicated than this example, but not by an order of magnitude (provided you take is slow ...).
06-08-2018 03:44 PM
@Silly_student wrote:
How do I draw rotating matrix of lines, like in the picture, in real time?
Is this a static picture or an animation? ("Rotating" implies animation). To animate, you just need to redraw with new values at regular intervals.
Many years ago, I posted this example drawing arrows with variable length and color. It can easily be simplified dramatically for lines of single color and lenght. 😄
06-08-2018 04:16 PM
@Silly_student wrote:
By rotating a line I meant changing its direction by a given angle.
If you use complex datatype, you don't need any trigonometry (sin, cos, etc.). Here's a very quick rewrite of my mentioned old example that can hopefully give you some ideas. This really does not need much code at all.
06-08-2018 04:29 PM - edited 06-08-2018 04:57 PM
@Silly_student wrote:
To be honest I'm new at Labview programming, so I couldn't make anything.
Some comments on your original code:
06-08-2018 05:28 PM