Previous page Next page Navigation bar

Programs

Physics Programs

Two-Dimensional Vector Sum

Summary Description

Programs:

VECSUM

Version:

2.0, 19 January 2006

Description:

The VECSUM program forms the sum of a number of two-dimensional 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:

Is compatible CFX-9850G

Compatible with CFX-9850G

Is compatible FX-7400G

Compatible with FX-7400G

Detailed Description

The VECSUM program forms the sum of a number of two-dimensional 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:

Usage

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.

Screen shot 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.

Screen shot If you are entering vectors in rectangular coordinates, the program will prompt for the X- and Y-coordinates of the vector with “x?” and “y?”. Enter the X-coordinate of the vector in response to the “x?” prompt and the Y-coordinate 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 X-coordinate and the Y-coordinate. When you enter the vector (0, 0), the program will return to the prompt “0:Done 1:x,y 2:r,theta.”

Screen shot 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.”

Screen shot 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 X-coordinate of the sum, followed by the Y-coordinate of the sum. This is shown in the screen shot to the right. You must press the EXE key after the X-coordinate is displayed and after the Y-coordinate is displayed.

Screen shot 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.

Usage Variations

Entering Angles In Other Angular Units

Screen shot 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 FX-7400G, 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 CFX-9950G, 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.

Entering Angles In Degrees, Minutes, and Seconds

Screen shot As with any time an angle in degrees is entered, you can enter the angle in degrees, minutes, and seconds. On the FX-7400G, 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 CFX-9850G, 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.

Displaying Degrees, Minutes, and Seconds

Screen shot As with any time a value in degrees is displayed, you can convert the value into degrees, minutes, and seconds. On the FX-7400G, 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 CFX-9850G, 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.

Subtracting Vectors

You can use the program to subtract vectors as well as add them. To form A-B, 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 X-coordinate value and the Y-coordinate 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.

Distance and Bearing

You can figure the distance and bearing from a point A to a point B by computing B-A. 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.

Determining If A Path Is Closed

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.

Coordinate Conversion

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.

Program

Source Code

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.0End of line operator
"Angles in"End of line operator
If 1°=1End of line operator
Then "degrees"End of line operator
Else If 1r=1End of line operator
Then "radians"End of line operator
Else "grads"End of line operator
IfEndEnd of line operator
IfEndEnd of line operator
0→A~EEnd of line operator
DoEnd of line operator
"0:Done"End of line operator
"1:x,y"End of line operator
"2:r,theta"?→AEnd of line operator
If A=1End of line operator
Then DoEnd of line operator
"x"?→BEnd of line operator
"y"?→CEnd of line operator
B+D→DEnd of line operator
C+E→EEnd of line operator
LpWhile (B≠0)+(C≠0)End of line operator
IfEndEnd of line operator
If A=2End of line operator
Then DoEnd of line operator
"r"?→BEnd of line operator
If B≠0End of line operator
Then "theta"?→CEnd of line operator
Rec(B,C)End of line operator
D+List Ans[1]→DEnd of line operator
E+List Ans[2]→EEnd of line operator
IfEndEnd of line operator
LpWhile B≠0End of line operator
IfEndEnd of line operator
LpWhile A≠0End of line operator
"x,y="End of line operator
DDisplay operator
EDisplay operator
"r,theta="End of line operator
If (D2+E2)≠0End of line operator
Then Pol(D,E)End of line operator
List Ans[1]Display operator
List Ans[2]→AEnd of line operator
If A<0End of line operator
Then A+2πr→AEnd of line operator
IfEndEnd of line operator
AEnd of line operator
Else 0Display operator
0End of line operator
IfEnd

Programming Notes

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, 1r, and radians.

The program tests for multi-variable 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 non-zero 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 user-supplied polar coordinates into rectangular coordinates. The Rec() function returns a two-element 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 two-element 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 ]

Previous page Top of page Next page Navigation bar

Copyright © 2006 Brian Hetrick
Page last updated 22 January 2006.

Brian’s Casio Calculator Corner

Home

Programs

Index

Linkage Conventions

Mathematics

Finance

Physics

Index

Vector Sum

Right Triangle

Newton’s Law

Uniform Acceleration

Ohm’s Laws

Utility

Tutorial

Puzzles

Site Information

Your Privacy

Site Map

E-mail

Site Technical Data