Sunteți pe pagina 1din 4

www.appliedmathematics.

info

Demonstration of Vector Geometry Calculations using Microsoft Excel and/or VBA


This document is a user-guide for the Excel spreadsheet GEOM.xlsm, which calculates geometrical functions, both using the spreadsheet
functions directly and by using visual basic.
The spreadsheet consists of three sheets. The first sheet Introduction gives the introduction to the spreadsheet, with links to supporting
documentation. The second sheet 2D Geometry routines contains examples of two-dimensional vector geometrical functions and the
sheet 3D geometry routines contains examples of three-dimensional vector geometrical functions. The functions of vector geometry that
are demonstrated by the spreadsheet are introduced in the document Vector Geometry, using the similar examples.
2D Geometry routines
The sheet will initially look like this.

Going along the top row, P1, P2 and P3 are three points in two-dimensions. The coordinates of the three points are in the yellow boxes,
these should be the only cells in the spreadsheet that the user may change. The next two columns contain the vectors a and b; a being the
vector
1 2 and b being the vector
1 3.

www.appliedmathematics.info

If you wish to work from vectors directly (e.g. you are only intrested in vector functions) then set 1 equal to (0,0), and 2 and 3 having
coordinates representing the x- and y- components of a and b respectively. For example the same results are obtained by carrying this
technique out on the data above, as shown in the following snapshot.

Clicking the button Run Tests runs the functions in module GEOM2D (click on Developer tab, followed by Visual Basic and then on the
module GEOM2D). The following services are tested.
Module
Sub vec2(Pa,Pb,vec)
Function dot2(veca,vecb)
Function size2(vec)
Function ssize2(vec)
Function dist2(Pa,Pb)
Sub norm3(Pa, Pb, vecnor)

Interface components
Pa(2), Pb(2), vec(2) As Double
veca(2), vecb(2), dot2 As Double
vec(2), size2 As Double
vec(2), ssize2 As Double
Pa(2), Pb(2), dist2 As Double
Pa(2), Pb(2), vecnor(2) As Double

Service
Finds the 2-vector vec linking point Pa to point Pb
Returns the dot product of the two 2-vectors veca and vecb
Returns the modulus of the 2-vector vec
Returns the square of the modulus of the 2-vector vec
Returns the distance between two points Pa and Pb
Finds the unit normal to the line between points Pa and Pb, pointing to the 'left'

The following results then appear in the green cells and these should reproduce the results in the blue cells directly above. Should the
results in the blue and green cells be the same then the result All tests passed should appear.

As suggested earlier, the data in yellow may be changed to find the results relating to other points and vectors. The tests may also be run
on new data.

www.appliedmathematics.info

3D Geometry routines
The sheet will initially look like this.

Going along the top row, P1, P2 and P3 are three points in three-dimensions. The coordinates of the three points are in the yellow boxes,
these should be the only cells in the spreadsheet that the user may change. The next two columns contain the vectors a and b; a being the
vector
1 2 and b being the vector
1 3.
If you wish to work from vectors directly (e.g. you are only intrested in vector functions) then set 1 equal to (0,0,0), and 2 and 3 having
coordinates representing the x- and y- components of a and b respectively. For example the same results are obtained by carrying this
technique out on the data above, as shown in the following snapshot.

www.appliedmathematics.info

Clicking the button Run Tests runs the functions in module GEOM3D (click on Developer tab, followed by Visual Basic and then on the
module GEOM3D). The following services are tested.
Module
Sub vec3(Pa,Pb,vec)
Function dot3(veca,vecb)
Function size3(vec)
Function ssize3(vec)
Function dist3(Pa,Pb)
Sub cross3(veca, vecb, cross)
Sub norm3(Pa, Pb, Pc, vecnor)
Function area(Pa,Pb,Pc)

Interface components
Pa(3), Pb(3), vec(3) As Double
veca(3), vecb(3), dot3 As Double
vec(3), size3 As Double
vec(3), ssize3 As Double
Pa(3), Pb(3), dist3 As Double
veca(3), vecb(3), cross(3) As Double
Pa(3), Pb(3), Pc(3), vecnor(2) As Double
Pa(3), Pb(3), Pc(3), area As Double

Service
Finds the vector vec linking point Pa to point Pb
Returns the dot product of the two 3-vectors veca and vecb
Returns the modulus of the 3-vector vec
Returns the square of the modulus of the 3-vector vec
Returns the distance between two points Pa and Pb
Finds the cross product of the vectors veca and vecb
Finds the normal to the triangle with vertices Pa, Pb and Pc
Returns the area of the triangle with vertices Pa, Pb and Pc

The following results then appear in the green cells and these should reproduce the results in the blue cells directly above. Should the
results in the blue and green cells be the same then the result All tests passed should appear.

As suggested earlier, the data in yellow may be changed to find the results relating to other points and vectors. The tests may also be run
on new data.

S-ar putea să vă placă și