Programs: 
VECSUM 

Version: 
2.0, 19 January 2006 

Description: 
The VECSUM program forms the sum of a number of twodimensional vectors. Each vector may be described in either rectangular coordinates (X and Y) or polar coordinates (R and Theta). The sum is given in both rectangular coordinates and polar coordinates. 

Compatibility: 

The VECSUM program forms the sum of a number of twodimensional vectors. Each vector may be described in either rectangular coordinates (X and Y) or polar coordinates (R and Theta). The sum is given in both rectangular coordinates and polar coordinates.
This program uses the mathematical angle convention: angles are measured counterclockwise from the positive X axis or due East.
Other applications of the program include:
Enter the VECSUM program into the calculator, either using the calculator data cable or entering the program directly.
Choose a unit of linear measure, and convert all distances (X, Y, and R) into this unit. The distances in the sum (X, Y, and R) will be expressed in this unit.
Choose a unit of angular measure (degrees, grads, or radians), and convert all angles (Theta) into this unit. Use the calculator’s SET UP menu to set the calculator to use this unit. The angle in the sum will be expressed in this unit.
Run the program.
The program will report the unit of angular measurement in use, by displaying a message such as “Angles in degrees” or “Angles in radians.” Such a message is shown in the screen shot to the right. If the unit is incorrect, halt the program execution and return to choosing a unit of angular measure.
The program will display the prompt “0:Done 1:x,y 2:r,theta” and pause for you to input a code. The prompt is as shown above. If the first vector to be entered is in rectangular coordinates, enter 1 (the code for “x,y”). If the first vector to be entered is in polar coordinates, enter 2 (the code for “r,theta”). The entry you make here is modal: the choice of rectangular or polar coordinates affects all vectors you enter until you exit the mode. Instructions on exiting the mode are given in the next paragraphs.
If you are entering vectors in rectangular coordinates, the program will prompt for the X and Ycoordinates of the vector with “x?” and “y?”. Enter the Xcoordinate of the vector in response to the “x?” prompt and the Ycoordinate of the vector in response to the “y?” prompt. The entry of the vector (15.7, 12.3) is shown in the screen shot to the right. The program will continue to prompt you with “x?” and “y?” until you enter 0 for both the Xcoordinate and the Ycoordinate. When you enter the vector (0, 0), the program will return to the prompt “0:Done 1:x,y 2:r,theta.”
If you are entering vectors in polar coordinates, the program will prompt for the length (r) value with “r?” and for the angle (theta) value with “theta?”. Enter the vector length in response to the “r?” prompt, and the vector angle in response to the “theta?” prompt. The entry of the vector r=19.94, theta=141.92 is shown in the screen shot to the left. The program will continue to prompt you with “r?” and “theta?” until you enter 0 for the length (r) value. When you enter 0 for the length value, the program will return to the prompt “0: Done 1:x,y 2:r,theta.”
When the program has prompted you with “0:Done 1:x,y 2:r,theta?” you can choose 0 to indicate that you have entered all vectors. The program will then display the sum of the vectors you entered. The program will first display the sum in rectangular coordinates with the label “x,y=”, followed by the Xcoordinate of the sum, followed by the Ycoordinate of the sum. This is shown in the screen shot to the right. You must press the EXE key after the Xcoordinate is displayed and after the Ycoordinate is displayed.
After the sum of the vectors has been displayed in rectangular coordinates, it is displayed in polar coordinates with the label “r,theta=”, followed by the distance (r) value of the vector, followed by the angle (theta) value of the vector in the chosen angular units. This is shown in the screen shot to the left. You must press the EXE key after the distance value is displayed.
As with any time an angle is entered, you can enter the angle in any of degrees, grads, or radians, regardless of the angular measurement unit in use by the calculator. On the FX7400G, press OPTN, the right arrowhead key, and F2 (ANGL) to choose the angle menu. Enter the angle in degrees followed by F1 (°), or in radians followed by F2 (r), or in grads followed by F3 (g). On the CFX9950G, press OPTN, F6 (the right arrowhead), and F5 (ANGL) to choose the angle menu. Enter the angle in degrees followed by F1 (°), or in radians followed by F2 (r), or in grads followed by F3 (g). The screen shot to the left shows the entry of 141.92 degrees as 2.476971274 radians.
As with any time an angle in degrees is entered, you can enter the angle in degrees, minutes, and seconds. On the FX7400G, press OPTN, the right arrowhead key, and F2 (ANGL) to choose the angle menu, and the right arrowhead key. This displays the degree, minutes, and seconds menu. Enter the degrees part of the angle, followed by F1 (°’”), followed by the minutes part of the angle, followed by F1 (°’”), followed by the seconds part of the angle, followed by F1 (°’”). On the CFX9850G, press OPTN, F6 (the right arrowhead), and F5 (ANGL) to choose the angle menu. Enter the degrees part of the angle, followed by F4 (°’”), followed by the minutes part of the angle, followed by F4 (°’”), followed by the seconds part of the angle, followed by F4 (°’”). The use of this technique is indicated in the display by a superscript square, similar to the superscript degree sign. Note that you can combine this technique with the previous technique to enter an angle in degrees, minutes, and seconds, even when the unit of angular measurement is not degrees: follow the last press of the °’” key with the ° key (you may need to press the arrowhead key to get to the appropriate part of the menu). The screen shot to the right shows the entry of the angle 57°17’44.81” when the calculator is using radians.
As with any time a value in degrees is displayed, you can convert the value into degrees, minutes, and seconds. On the FX7400G, press OPTN, the right arrowhead key, F2 (ANGL) to choose the angle menu, the right arrowhead key, and F2 (°’” with a bar over it) to choose the inverse degrees, minutes, and seconds operation. On the CFX9850G, press OPTN, F6 (the right arrowhead), and F5 (ANGL) to choose the angle menu, and F5 (°’” with a bar over it) to choose the inverse degrees, minutes, and seconds operation. This converts the fractional degrees into minutes and seconds. This is shown in the screen shot to the right.
You can use the program to subtract vectors as well as add them. To form AB, where A and B are both vectors, add A and the negative of B. You form the negative of a vector expressed in rectangular coordinates by negating both the Xcoordinate value and the Ycoordinate value. You can form the negative of a vector expressed in polar coordinates either by negating its length (r) value, or by adding 180° to (or subtracting 180° from) its angle (theta) value.
You can figure the distance and bearing from a point A to a point B by computing BA. This gives you the vector needed to add to A (the origin) to move to B (the destination). The distance between the two points is the length (r) of the difference vector; the direction from A to B is the angle (theta) of the difference vector.
You can use the program to determine if a path is closed. Simply add together the vectors that measure the edges of the path. If the length of the sum of the vectors is zero, the path is closed. Note that the finite precision of measurements may result in a vector sum with a length that is close to zero, rather than zero exactly. If the length of the vector sum is “close enough” to zero, you can consider the path to be closed.
You can use the program to convert a vector from polar coordinates to rectangular coordinates, or from rectangular coordinates to polar coordinates. Run the program, and enter the single vector to be converted. The “sum” of the single vector will be the vector itself, which will be presented in both rectangular and polar coordinates. The form which was not the form in which you entered the vector is the vector converted to the other form.
The program is available in a ZIP file, or may be entered as shown below. Remember that this program is copyrighted; see the copyright issues page for limitations on redistribution.
Program VECSUM (362 bytes):
'VECSUM 2.0
"Angles in"
If 1°=1
Then "degrees"
Else If 1^{r}=1
Then "radians"
Else "grads"
IfEnd
IfEnd
0→A~E
Do
"0:Done"
"1:x,y"
"2:r,theta"?→A
If A=1
Then Do
"x"?→B
"y"?→C
B+D→D
C+E→E
LpWhile (B≠0)+(C≠0)
IfEnd
If A=2
Then Do
"r"?→B
If B≠0
Then "theta"?→C
Rec(B,C)
D+List Ans[1]→D
E+List Ans[2]→E
IfEnd
LpWhile B≠0
IfEnd
LpWhile A≠0
"x,y="
D
E
"r,theta="
If (D^{2}+E^{2})≠0
Then Pol(D,E)
List Ans[1]
List Ans[2]→A
If A<0
Then A+2π^{r}→A
IfEnd
A
Else 0
0
IfEnd
The program detects the angular units in use by the calculator by checking the results of an angular measurement conversion. The ° operator converts a value in degrees into the angular measure in use by the calculator. Thus, if 1° has the value 1, the calculator is set to use degrees; and similarly for the ^{r} operator, 1^{r}, and radians.
The program tests for multivariable conditions by using arithmetic on the results of comparison operations. The comparison operators return 0 for false conditions, and 1 for true conditions; the various control constructs regard zero as false and nonzero as true. This permits multiplication to be used as an equivalent to logical and, and addition to be used as an equivalent to logical or.
The program uses the Rec() function to convert usersupplied polar coordinates into rectangular coordinates. The Rec() function returns a twoelement List; the X coordinate is stored in [1], the Y coordinate in [2]. The program evaluates Rec() but does not store the result, so the result is available in List Ans.
The program uses the Pol() function to convert the rectangular coordinate of the sum into polar coordinates. The Pol() function returns a twoelement List; the R coordinate is stored in [1], the Theta coordinate in [2]. The Pol() function returns a Theta value between negative two right angles and positive two right angles; the program adds 2π^{r} (a whole circle in whatever angular measurement is in use) to negative angles to obtain the equivalent positive angle.
[ Previous page  Top of page  Next page ]
Copyright © 2006 Brian Hetrick
Page last updated 22 January 2006.