Sunteți pe pagina 1din 2

www.appliedmathematics.

info

Demonstration of Vector Geometry Operations using Matlab/Freemat/Octave


This document1 is a user-guide for the the set of open source m-files (Matlab/Freemat or Octave) for carrying out two- and threedimensional vector operations. The individual vector operations can be downloaded from the links in the table below and the m-file
containing the set of test problems can be downloaded from the link Geometry_Tests. The functions of vector geometry that are
demonstrated by the spreadsheet are introduced in the document Vector Geometry, using the similar examples. An Excel spreadsheet
GEOM.xlsm illustrates the test of the same operations (including in VBA) on the same test data. A user guide to Matlab (Freemat and
Octave) can be found throught the link www.freemat.info.
Once all the m-files are loaded into and Geometry_Tests is run from the command lin the result '2D Tests Passed' '3D Tests Passed' should
appear.

function

Interface
components
pa, pb row vectors,
vec column vector

Service

Test(s)

Finds the 2-vector vec linking point


pa to point pb and stores the result in
vec.

1
2D) pa=p1=(2,4), pb=p2= (3,9) vec=( )
5

dotproduct(veca,vecb)

veca, vecb column


vectors

Returns the dot product of the two 2vectors veca and vecb

size(vec)

vec column vector

Returns the modulus of the vector


vec

[vec]=vector(pa,pb)

http://www.appliedmathematics.info/software/GEOM_m.htm

7
3D) pa=p1= (1,-3,2), pb=p2= (8,-2,5) , vecb=vec=(1)
3
1
2
2D) veca=( ), vecb=( )dotproduct=-13
5
3
2
7
3D) veca =(2), vecb =(1) dotproduct =27
5
3
1
2D) vec=veca=( )size=26
5
2
3D) vec=veca=(2) size=33
5

www.appliedmathematics.info

ssize(vec)

vec column vector

Returns the square of the modulus of


the vector vec

dist(pa,pb)

pa, pb row vectors

Returns the distance between two


points pa and pb

[vecnor]=norm2(pa, pb)

pa, pb row vectors,


vecnor column
vector

Finds the unit normal to the line


between points pa and pb, pointing to
the 'left' and stores the result in vec.

[vec]= cross3(veca, vecb)

vec, veca, vecb


column vectors

Finds the cross product of the


vectors veca and vecb

[vec]= norm3(pa,pb,pc)

pa, pb, pc row


vectors, vec column
vector

Finds the normal to the triangle with


vertices pa, pb and pc

area(pa,pb,pc)

pa, pb, pc row


vectors

Returns the area of the triangle with


vertices pa, pb and pc

1
2D) vec=veca=( )ssize=26
5
2
3D) vec=veca=(2) ssize=33
5
2D) pa=p1=(2,4), pb=p2= (3,9) dist=26
3D) pa=p1= (1,-3,2), pb=p2= (3,-5,7) , dist=33
2D) pa= (2,4), pb= (3,9) vec=(

5/26
)
1/26

2
7
11
veca =(2), vecb =(1) cross3=( 29 )
5
3
16
pa=p1= (1,-3,2), pb=p2= (3,-5,7) , pc=p3= (8,-2,5)
11/1218
vec=( 29/1218 )
16/1218
pa=p1= (1,-3,2), ), pb=p2= (3,-5,7) pc=p3= (8,-2,5)
area=1218/2

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