Ronan

1172 Reputation

14 Badges

12 years, 186 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

Is there any to export a 3d plot so it could be used as a 3d pdf or some other document type?

Edit: uploaded Maple 3d plot.
 

 

 


 

Download Tetrahedron_Rat_Trig.mw

How should optional input parameters be handled for procedures. The example has three optional inputs 

vars:=[x,y]   ,  clr:="b"   and prnt:="y"  . if one wants to change prnt to"n", vars and clr values must be entered.

{vars:=[x,y]  } , { clr:="b" }  and{ prnt:="y"}  this is a good method because one just enteres prnt="n".  But have to remember the input parameter name prnt.

I have a 3rd option, but it is to complicated and probably unreliable to use in practice.  and with more than 3 optional inputs too difficult to code.

I am wondering  are the other approaches and what is the prefered methodology. I have about 30+ procedures to apply this to in a package.

Edit:-  I can change the prnt to boolean true, false instead of "y" , "n".  That would make the all the optional inputs different types.

In Test1 its should be vars::list:=[x,y] not vars::{list , `string`}:=[x,y]

restart

Geomclr := "b"

"b"

(1)

NULL

NULL

NULL

Test1 := proc (A, B, vars::{list, string} := [x, y], clr::string := Geomclr, prnt::string := "y") if vars::string then clr := vars; vars := [x, y] end if; if clr = "y" or clr = "n" then prnt := clr; clr := Geomclr end if; print(clr); if prnt = "y" then print("good") end if; A*vars[1]+B*vars[2] end proc

NULL

Test1(A, B)

A*x+B*y

(2)

Test1(A, B, [r, s], "n")

Error, (in Test1) invalid left hand side in assignment

 

Test1(A, B, "g")

Error, (in Test1) invalid left hand side in assignment

 

Test1(A, B, "n")

Error, (in Test1) invalid left hand side in assignment

 

Test1(A, B, [x, y], "b", "n")

A*x+B*y

(3)

 

 

NULL

``

NULL

 

NULL

Test2 := proc (A, B, { vars::{list} := [x, y], clr::string := Geomclr, prnt::string := "y" }) print(clr); if prnt = "y" then print("good") end if; A*vars[1]+A*vars[2] end proc

NULL

NULL

Test2(A, B)

A*x+A*y

(4)

Test2(A, B, clr = "r")

A*x+A*y

(5)

Test2(A, B, prnt = "n")

A*x+A*y

(6)

Test2(A, B, prnt = "n")

A*x+A*y

(7)

Test2(A, B, prnt = "n", clr = "green", l = [r, s])

A*x+A*y

(8)

``

 

# 3 This is possible but is a very complicated method of handling the optional inputs and difficult the handle altered sequence on inputs.

NULL

Test3 := proc (A, B, vars::{list, string} := [x, y], clr::string := Geomclr, prnt::string := "y") local varsl, clrl, prntl; global Geomclr; varsl := vars; clrl := clr; prntl := prnt; if vars::string then varsl := [x, y]; if vars = "y" or vars = "n" then prntl := vars; clrl := Geomclr elif vars = "r" or vars = "g" or vars = "b" then clrl := vars end if elif vars::list and clr = "y" or clr = "n" then prntl := clr; clrl := Geomclr end if; if clr = "y" or clr = "n" and vars::string then prntl := clr; clrl := vars end if; print("Colour print out ", clrl); if prntl = "y" then print("This is a test Message") end if; A*varsl[1]+B*varsl[2] end proc

NULL

Test3(A, B)

A*x+B*y

(9)

Test3(A, B, [r, s])

A*r+B*s

(10)

Test3(A, B, [r, s], "n")

A*r+B*s

(11)

Test3(A, B, "n")

A*x+B*y

(12)

Test3(A, B, [r, s], "r", "n")

A*r+B*s

(13)

Test3(A, B, "r", "n")

A*x+B*y

(14)

Test3(A, B, "n", "r")

A*x+B*y

(15)

NULL


 

Download Q_2024-02-25_Test_proc_Args.mw

Using textplot  is there anything that can be done to to increase the offest of alignI would like to raise  P3 at top of graph up a bit and S3 down. they are {centre, above} and {centre,below}. I know I can tie them to a different point  coordinate to begin with but that is messy to control inside a procedure.

I need to produce some diagrams for the help pages of my package. I trying to typeset the dot product "." on a plot but keep getting a % symbol. I have tried without typesetting but makes no differance.

restart

 

 

Sdim:=proc(A,B,C,clr::string,S:=NULL)
    description"plots spread symbol";
    uses plots,plottools;
    local aa,bb,c,d,e,f,g,h,k,p1,v1,v2,vab,vac;
    vab:=Vector(B-A);
    vac:=Vector(C-A);
    aa:=(B-A)/5;
    bb:=(C-A)/5;
    p1:=plottools:-point([A,B,C],symbol=solidcircle);
    c:= plottools:-line(A+aa,A+bb);
    d:=plottools:-line(A,B);
    e:=plottools:-line(A,C);
    f:=plots:-textplot([op(1.1*(A+(aa+bb)/2)+[1.5,0]), typeset(S)]);   #print S
    g:=plots:-textplot([op(.9*A), typeset([x[1],y[1]])]);  #[x1,y1]
    h:=plots:-textplot([op(1.1*B), typeset([x[2],y[2]])]);  #x2,y2]
    k:=plots:-textplot([op(1.05*C), typeset([x[3],y[3]])]);  #x3,y3]
    v1:=plots:-textplot([op(A+(B-A)/2+[.2,-.2]), typeset(`#mover(mi("v"),mo("⇀"))`[a])]);   # vector symbol
    v2:=plots:-textplot([op(A+(C-A)/2+[-.2,.2]), typeset(`#mover(mi("v"),mo("⇀"))`[b])]);   #vector symbol
    display(p1,c,d,e,f,g,h,k,v1,v2,axes=none,scaling=constrained,caption="Spread between two vectors");    #place title under diagram
end proc

 

proc (A, B, C, clr::string, S := NULL) local aa, bb, c, d, e, f, g, h, k, p1, v1, v2, vab, vac; description "plots spread symbol"; vab := Vector(B-A); vac := Vector(C-A); aa := (1/5)*B-(1/5)*A; bb := (1/5)*C-(1/5)*A; p1 := plottools:-point([A, B, C], symbol = solidcircle); c := plottools:-line(A+aa, A+bb); d := plottools:-line(A, B); e := plottools:-line(A, C); f := plots:-textplot([op(1.1*(A+(1/2)*aa+(1/2)*bb)+[1.5, 0]), typeset(S)]); g := plots:-textplot([op(.9*A), typeset([x[1], y[1]])]); h := plots:-textplot([op(1.1*B), typeset([x[2], y[2]])]); k := plots:-textplot([op(1.05*C), typeset([x[3], y[3]])]); v1 := plots:-textplot([op((1/2)*A+(1/2)*B+[.2, -.2]), typeset(`#mover(mi("v"),mo("⇀"))`[a])]); v2 := plots:-textplot([op((1/2)*A+(1/2)*C+[-.2, .2]), typeset(`#mover(mi("v"),mo("⇀"))`[b])]); plots:-display(p1, c, d, e, f, g, h, k, v1, v2, axes = none, scaling = constrained, caption = "Spread between two vectors") end proc

(1)

Spr:=S=1-(`#mover(mi("v"),mo("⇀"))`[b-a]%.`#mover(mi("v"),mo("⇀"))`[b-a])^2/(`#mover(mi("v"),mo("⇀"))`[a]%.`#mover(mi("v"),mo("⇀"))`[a])/(`#mover(mi("v"),mo("⇀"))`[b]%.`#mover(mi("v"),mo("⇀"))`[b]);

S = 1-`%.`(`#mover(mi("v"),mo("⇀"))`[b-a], `#mover(mi("v"),mo("⇀"))`[b-a])^2/(`%.`(`#mover(mi("v"),mo("⇀"))`[a], `#mover(mi("v"),mo("⇀"))`[a])*`%.`(`#mover(mi("v"),mo("⇀"))`[b], `#mover(mi("v"),mo("⇀"))`[b]))

(2)

Sdim([1,2],[5,1],[4,7],"blue",Spr);

 

 

 

Download Q_2024-02-15_Help_Spread_diagram.mw

is there a way to set conjugate=true  to false as a default for BilinearForm?  This would be used inside a package.

restart;
with(LinearAlgebra);

v := <x, y>;
BilinearForm(v, v);
BilinearForm(v, v, conjugate = false);

 

First 6 7 8 9 10 11 12 Last Page 8 of 32