Programs - Vectors


Aim

The reason for writing this program was that we were currently learning about vectors in physics and the method that I was using seemed to be very laborious - you worked out the xy components of the two vectors, added them and then worked out the resultant from that. Now for a computer this would be very quick and easy, so why do it manually?

Method

Most of my graphical programs where you can interact usefully are written in Visual Basic, this is just because a lot less work has to be done about looking after the graphics, Windows does it for you.

There are two windows, one with the vectors and the other showing all the information about them. The information window shows: the length and bearing of the line, as well as its x and y displacements.

The vectors windows consists of three lines (to show the vectors), and three small boxes at the end of the lines (to move the lines about). The third line, the resultant, is red that’s just to show the difference. Only two of the boxes are visible at once, the line with out the box is calculated and therefore can’t be moved. The line to be calculated can easily be changed just right click on one of the visible boxes and it becomes the worked out line.

The way to computer works out all of this is that it remembers the x and y co-ordinates as you move the lines around and just adds it to the other line that isn’t worked out, then it moves the calculated line to the correct position. The hard part it working out the length and bearing of the line to display it, for this a whole function was written to take the x and y and convert it to r and q so that it can be displayed in the information window.

As an added bonus it is possible to restrict one of the the vector lines so that one of these properties never changes, i.e. it always has the same length or same bearing. This makes it easier to work out problems that need a certain magnitude or bearing to be achived. This program will not help with all vector problems, but it certainally makes some of them a lot easier.