Michielvsb

15 Reputation

4 Badges

10 years, 328 days

MaplePrimes Activity


These are questions asked by Michielvsb

Is it possible to change the order of which polygons are plot? I searched a lot on the internet but I don't find a useful answer. It seems to be logical that they are plot in the order they are given to the command "display", but it don't seem to work.

I try to plot different polygons, like you can see in the images below:

The red planes should form a pyramid but the black ground plane is front of it, so it should be plotted before the four red planed (polygons) are plotted.

In the code, the black plane (pp6) comes before the red planes (pp7->pp10) as input of the display command. If I change the order, nothing changes in the plot.

Is it possible to tell Maple that some polygons should be on the foreground and some on the background?

 Here is a link to the file if necessary: translatie_stn.mw

Thanks in advance!

The purpose is to display the projection of a 3D plane, defined by the points of P. "res" contains the points projected on a 2D plane and all variables beginning with "vlak" contain the points from res that should be connected to form a plane. The command polygonplot connects the points. Every time, it gives the error message "Error, (in plots:-polygonplot) points are not in the correct format". When I copy the code to a place outside the procedure, I discovered some variables are not defined.

restart:with(linalg):with(LinearAlgebra):with(VectorCalculus):with(plots): eerste:=proc(V,N,P) local M,M1,M2,I4,NT; NT:=Transpose(N); M1:=V.NT; I4:=IdentityMatrix(4); M2:=(N.V).I4; M:=M1-M2; M.P; end proc: tweede:=proc(OS,r,s,P1) local VC,K: K:=Matrix(4,3,[r,s,OS]); VC:=(MatrixInverse(Transpose(K).K)).Transpose(K); VC.P1; end proc: project:=proc(P,V,N,OS,r,s) local P1,P2,i,j,n: P1:=eerste(V,N,P); P2:=tweede(OS,r,s,P1); n:=ColumnDimension(P2); for i from 1 to n do for j from 1 to 2 do P2[j,i]:=P2[j,i]/P2[3,i]; end do: end do: DeleteRow(P2,3); end proc: P:=Matrix([[ 0 , 10 , 10 , 0 , 0 , 10 , 10 , 0 , 5 ], [ 0 , 0 , 10 , 10 , 0 , 0 , 10 , 10 , 5 ], [ 0 , 0 , 0 , 0 , 30 , 30 , 30 , 30 , 40 ], [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]]): V:=Vector([60,60,50,1]); N:=Vector([1,0,0,0]); OS:=Vector([10,10,0,1]); r:=Vector([0,1,0,0]); s:=Vector([0,0,1,0]); Vector[column](%id = 18446744073889448174) Vector[column](%id = 18446744073889448414) Vector[column](%id = 18446744073889448534) Vector[column](%id = 18446744073889448654) Vector[column](%id = 18446744073889448774) translatie:=t->Matrix([[ 1 , 0 , 0 , 1*t ], [ 0 , 1 , 0 , 1*t ], [ 0 , 0 , 1 , 0 ], [ 0 , 0 , 0 , 1 ]]); [1 0 0 VectorCalculus:-*(1, t)] [ ] [0 1 0 VectorCalculus:-*(1, t)] t -> [ ] [0 0 1 0 ] [ ] [0 0 0 1 ] f:=proc(t) local volgende,res,vlak_onder,vlak_links,vlak_voor,vlak_rechts,vlak_boven,vlak_achter,vlak1,vlak2,vlak3,vlak4,pp1,pp2,pp3,pp4,pp5,pp6,pp7,pp8,pp9,pp10: volgende:=MatrixMatrixMultiply(translatie(t),P): res:=project(volgende,V,N,OS,r,s): vlak_onder :=Transpose(Matrix([Column(res,1),Column(res,2),Column(res,3),Column(res,4)])): vlak_links :=Transpose(Matrix([Column(res,1),Column(res,2),Column(res,6),Column(res,5)])): vlak_voor :=Transpose(Matrix([Column(res,2),Column(res,3),Column(res,7),Column(res,6)])): vlak_rechts:=Transpose(Matrix([Column(res,3),Column(res,4),Column(res,8),Column(res,7)])): vlak_achter:=Transpose(Matrix([Column(res,1),Column(res,4),Column(res,8),Column(res,5)])): vlak_boven :=Transpose(Matrix([Column(res,5),Column(res,6),Column(res,7),Column(res,8)])): vlak1:=Transpose(Matrix([Column(res,8),Column(res,7),Column(res,9)])): vlak2:=Transpose(Matrix([Column(res,8),Column(res,7),Column(res,9)])); vlak3:=Transpose(Matrix([Column(res,8),Column(res,5),Column(res,9)])); vlak4:=Transpose(Matrix([Column(res,5),Column(res,6),Column(res,9)])); pp1:=polygonplot(vlak_onder): pp2:=polygonplot(vlak_links): pp3:=polygonplot(vlak_voor): pp4:=polygonplot(vlak_rechts): pp5:=polygonplot(vlak_achter): pp6:=polygonplot(vlak_boven); pp7:=polygonplot(vlak1); pp8:=polygonplot(vlak2); pp9:=polygonplot(vlak3); pp10:=polygonplot(vlak4); {pp1,pp2,pp3,pp4,pp5,pp6,pp7,pp8,pp9,pp10}: end proc: display(f(0),scaling=constrained); Error, (in plots:-polygonplot) points are not in the correct format

Above, you can see the code. When only pp1->pp7 is displayed, and pp8->pp10 is placed between commenting marks, it works fine. Otherwise it doesn't work, it looks like Maple does not define the variables pp8->pp10. I don't understand because there is no difference between pp7 and pp8.

Thanks in advance

Page 1 of 1