11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.6 Vector Field Plots • 263> makevectors := proc( F, r1, r2 )> local v1, v2;>> # Generate the numerical grid> # of components of the vectors.> v1 := convert( F[1], ’gridpoints’, r1, r2,> args[4 .. nargs] );> v2 := convert( F[2], ’gridpoints’, r1, r2,> args[4 .. nargs] );>> # The domain information is contained in first> # two operands of v1. The function values in> # the 3rd components of v1 and v2.> [ v1[1], v1[2], v1[3], v2[3] ]> end proc:Here is the new version of vectorfieldplot.> vectorfieldplot := proc(F, r1, r2)> local R1, R2, m, n, a, b, v1, v2, dx, dy, v;>> v := makevectors( F, r1, r2, args[4..nargs] );> R1 := v[1]; R2 := v[2]; v1 := v[3]; v2 := v[4];>> n := nops(v1); m := nops(v1[1]);> a,b,dx,dy := domaininfo(R1, R2, m, n);>> generateplot(v1, v2, m, n, a, b, dx, dy);> end proc:Test this procedure.> p := (x,y) -> cos(x*y):> q := (x,y) -> sin(x*y):> vectorfieldplot( [p, q], 0..Pi, 0..Pi,> grid=[3, 4] );32.521.510.500.5 1 1.5 2 2.5 3 3.5All the versions of vectorfieldplot so far have scaled each arrowso that each vector fits into a single grid box. No overlapping of arrowsoccurs. However, the arrows still vary in length. Often this results in

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!