Phil Lucht Math & Physics Archive
Home / Math and Physics Files / Math / Curvilinear Systems / Tensor Doc and Support / support notes and rejects

plotting coordinate lines

DOCX · 204.1 KB
Open DOCX file

Working notes by Phil (dated 10.29.11) on using Maple to plot coordinate grids, with two companion Maple worksheets. They treat polar and elliptical polar coordinates in two ways: squares in x-y space mapped to inverse coordinate lines in θ-r space, and squares in θ-r space mapped to forward coordinate lines (circles or ellipses and rays). Maple code and plot commands are included, with comments on patch counts.

AI-written summary; may contain errors.

Extracted text (machine-read; may contain errors)
Plotting coordinate lines in Maple PhL 10.29.11 There are two Maple files which go with this doc: Sections 1 and 2: polar grids.mws Sections 3 and 3: epolar grids.mws 1. Polar Coordinates, squares in x-y space 1 (a) Plot some vertical and horizontal lines in x,y space: 1 (b) Plot the inverse coordinate lines corresponding to the above grid 3 (c) The Combined Picture: 5 2. Polar Coordinates, squares in θ-r space 5 (a) Plot some vertical and horizontal lines in θ,r space: 6 (b) Plot the forward coordinate lines corresponding to the above grid 8 (c) The Combined Picture: 10 3. Elliptical Polar Coordinates, squares in x-y space 10 (a) Plot some vertical and horizontal lines in x,y space: 11 (b) Plot the inverse coordinate lines corresponding to the above grid 13 (c) The Combined Picture: 14 4. Elliptical Polar Coordinates, squares in θ,r space 15 (a) Plot some vertical and horizontal lines in θ,r space: 15 (b) Plot the forward coordinate lines corresponding to the above grid 17 (c) The Combined Picture 19 1. Polar Coordinates, squares in x-y space Here we make squares in x-y space then plot the inverse coordinate lines. Let's start with the math for polar coordinates: x = r cosθ y = r sinθ r = xi/cosθ These make the inverse coordinate lines r =yi/sinθ r2 = x2 + y2 tanθ = y/x y = These make the forward coordinate lines. y = x tanθi (a) Plot some vertical and horizontal lines in x,y space: Horizontal lines: yi = -N..N gives about 2N horizontal lines N := 10: hor := plot([seq(yi,yi=-N..N)],color = red):display(hor); Vertical lines. xi = -N..N gives about 2N vertical lines ver_pre := plot([seq(yi,yi=-N..N)],color=blue):display(ver_pre); This set of lines is identical to the above, but are made blue. Now we reflect them in the diagonal to get vertical lines: ver := reflect(ver_pre, [[0,0],[1,1]]):display(ver); Both: display(ver,hor); This is a grid of 400 squares for x-y space. (b) Plot the inverse coordinate lines corresponding to the above grid As noted above, the equations of interest here are r = xi/cosθ These make the inverse coordinate lines r = yi/sinθ xgrid := plot([seq(xi/(1*cos(theta)),xi=-10..10)],theta = .001..2*Pi-.001, color=blue, view = [0..2*Pi,0..10]): display(xgrid); ygrid := plot([seq(yi/(1*sin(theta)),yi=-10..10)],theta = .001..2*Pi-.001, color=red, view = [0..2*Pi,0..10]): display(ygrid); display(xgrid,ygrid); This thing has about 400 patches and matches the x-y grid in that regard. I like the count here because the above drawing then is "good". Fewer boxes or more would make it less good. So we are done with this job. (c) The Combined Picture: x'-space x-space 2. Polar Coordinates, squares in θ-r space Here we make squares in θ-r space then plot the forward coordinate lines. Let's start with the math for polar coordinates: x = r cosθ y = r sinθ r = xi/cosθ These make the inverse coordinate lines r =yi/sinθ r2 = x2 + y2 tanθ = y/x y = These make the forward coordinate lines. y = x tanθi (a) Plot some vertical and horizontal lines in θ,r space: Horizontal lines: ri = 0..Nh gives about N horizontal lines Nh := 10: // this will create Nh circles eventually unassign('x'); hor :=plot([seq(ri,ri=0..Nh)],theta=0..2*Pi, color=red): display(hor); Vertical lines. xi = 2π (i/N), i=0..Nv gives about Nv vertical lines Nv := 20: ver_pre :=plot([seq(2*Pi*i/Nv,i=0..Nv)],theta=0..Nv/2,color=blue, view = [0..Nv/2,0..2*Pi]): display(ver_pre); ver := reflect(ver_pre, [[0,0],[1,1]]):display(ver); And finally we display both at the same time: display(ver,hor); This is a grid of 200 squares for x-y space. (b) Plot the forward coordinate lines corresponding to the above grid As noted above, the equations of interest here are y = These make the forward coordinate lines. y = x tanθi Circles: We first make the upper half circles this way: Nc := 10:unassign('x'); > upper := plot([seq(Re(sqrt(ri^2-x^2)),ri=0..Nc)], x = -Nc..Nc, scaling=constrained, color=red): display(upper); The Re is needed because in the x scan, goes imaginary when we are out of range and this causes an error. Perhaps this causes red on the horizontal axis where Re=0 but I don't see it, fine. lower := plot([seq(-Re(sqrt(ri^2-x^2)),ri=0..Nc)], x = -Nc..Nc, scaling=constrained, color=red): display(lower); display(upper,lower); So here then are our Nc circles, finally. Rays: Next, we need to make the rays θi = 2π(i/N) Nr is the number of rays, while N is as it was earlier, (N,N) is upper right corner of x-y grid Nr := 20: N := 10: rays :=plot([seq(x*tan(2*Pi*(i+.0001)/Nr),i=1..Nr)], x = -N..N,scaling=constrained, color=blue, view = [-N..N,-N..N]): display(rays); Both: display(upper,lower,rays); This grid also has 200 patches, so matches the mesh earlier. (c) The Combined Picture: x'-space x-space 3. Elliptical Polar Coordinates, squares in x-y space Here we make squares in x-y space then plot the inverse coordinate lines in θ-r space. Let's start with the math for elliptical polar coordinates: x = aρcosθ x/a = ρcosθ => x2/a2 + y2/b2 = ρ2 y = bρ sinθ y/b = ρsinθ => tanθ = y/x ρ = xi/(acosθ) These make the inverse coordinate lines ρ = yi/(asinθ) ρ2= 2/a2 + y2/b2 tanθ = y/x y = b These make the forward coordinate lines. y = x tanθi (a) Plot some vertical and horizontal lines in x,y space: Horizontal lines: yi = -a*Nh/2..a*Nh/2 gives about 2N horizontal lines Nh := 20: a :=2: b := 1: hor := plot([seq(yi,yi=-Nh/2..Nh/2)],x = -Nh..Nh, color = red , scaling = constrained):display(hor); Vertical lines. xi = -Nv/2..Nv/2 gives about 2N vertical lines Nv:= 20; ver_pre := plot([seq(a*yi,yi=-Nv/2..Nv/2)],x = -Nv/2..Nv/2, color=blue ,scaling = constrained):display(ver_pre); Now we reflect them in the diagonal to get vertical lines: ver := reflect(ver_pre, [[0,0],[1,1]]):display(ver); Both: display(ver,hor); This is a grid of 400 squares for x-y space. (b) Plot the inverse coordinate lines corresponding to the above grid As noted above, the equations of interest here are r = xi/(acosθ) These make the inverse coordinate lines r = yi/(bsinθ) a :=2: b:= 1: x := plot([seq(xi/(1*(a*cos(theta))),xi=-10..10)],theta = .001..2*Pi-.001, color=blue, view = [0..2*Pi,0..10]): display(x); y := plot([seq(yi/(1*(b*sin(theta))),yi=-10..10)],theta = .001..2*Pi-.001, color=red, view = [0..2*Pi,0..10]): display(y); display(x,y); This thing has about 400 patches and matches the x-y grid in that regard. I like the count here because the above drawing then is "good". Fewer boxes or more would make it less good. So we are done with this job. (c) The Combined Picture: x'-space x-space 4. Elliptical Polar Coordinates, squares in θ,r space Here we make squares in θ-r space then plot the forward coordinate lines. Let's start with the math for elliptical polar coordinates: x = aρcosθ x/a = ρcosθ => x2/a2 + y2/b2 = ρ2 y = bρ sinθ y/b = ρsinθ => tanθ = y/x ρ = xi/(acosθ) These make the inverse coordinate lines ρ = yi/(asinθ) ρ2 = x2/a2 + y2/b2 tanθ = y/x y = b These make the forward coordinate lines. y = x tanθi (a) Plot some vertical and horizontal lines in θ,r space: Horizontal lines: ri = 0..Nh gives about N horizontal lines Nh := 10: // this will create Nh circles eventually unassign('x'); hor :=plot([seq(ri,ri=0..Nh)],theta=0..2*Pi, color=red): display(hor); Vertical lines. xi = 2π (i/N), i=0..Nv gives about Nv vertical lines Nv := 20: ver_pre :=plot([seq(2*Pi*i/Nv,i=0..Nv)],x=0..Nv/2,color=blue, view = [0..Nv/2,0..2*Pi]): display(ver_pre); ver := reflect(ver_pre, [[0,0],[1,1]]):display(ver); And finally we display both at the same time: display(ver,hor); This is a grid of 200 squares for x-y space. (b) Plot the forward coordinate lines corresponding to the above grid As noted above, the equations of interest here are y = b These make the forward coordinate lines. y = x tanθi Ellipses: We first make the upper half ellipses this way: Nc := 10:unassign('x'); > upper := plot([seq(b*Re(sqrt(ri^2-(x/a)^2)),ri=0..Nc)], x = -a*Nc..a*Nc, scaling=constrained, color=red): display(upper); The Re is needed because in the x scan, goes imaginary when we are out of range and this causes an error. Perhaps this causes red on the horizontal axis where Re=0 but I don't see it, fine. lower := plot([seq(-b*Re(sqrt(ri^2-(x/a)^2)),ri=0..Nc)], x = -Nc..Nc, scaling=constrained, color=red): display(lower); display(upper,lower); So here then are our Nc circles, finally. Rays: Next, we need to make the rays θi = 2π(i/N) Nr is the number of rays, while N is as it was earlier, (N,N) is upper right corner of x-y grid Nr := 20: N := 10: rays :=plot([seq(x*tan(2*Pi*(i+.0001)/Nr),i=1..Nr)], x = -a*N..a*N,scaling=constrained, color=blue, view = [-a*N..a*N,-N..N]): display(rays); Both: display(upper,lower,rays); This grid also has 200 patches, so matches the mesh earlier. (c) The Combined Picture x'-space x-space