Ronan

1197 Reputation

14 Badges

12 years, 194 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

@acer Ok so what I have here with the procedure is outside of the package. So that may be affecting things.

I have altered the parameter names annotated in in the worksheet. Now `clr` is changed to `colour` that causes a clash. `Colour` works. `points` changed to `Point` not working. I can solve the problem. I was just trying to come up with sensible names. I was concerned about my capatilised names conflicting with other packages also I wasnted to keep them lower case if possible. @Carl Love indicated that this would not be a problem inside a package.

I will probably settle on names such as pointdata, linedata, message::boolean =true instead of prnt="y" 

2024-03-09_Example_parm_names_changed.mw

@acer Basically I don't know using nicer, parameter names suck as line, point, and colour, and print (I am sure print clashes)will clash.  Hopefully this will demonstrate sufficiently.  


 

restart

 

Prntmsg:="y"; Geomclr:="Blue";

"y"

 

"Blue"

(1)

Qdim := proc(P1, P2, {Q:=[ NULL,align={left}]},
                     {vec1::list:=[NULL,align={below,right}]},
                     {scl::{list,numeric}:=1},
                     {leader::{-1,0,1}:= 1},
                     {dimofset::{1,2,3,4,5,6}:=1},
                     {points::list:=[color = blue, symbol = solidcircle, symbolsize = 8]},
                     {linetype::list:=[thickness=3]},
                     {clr::`string`:=Geomclr},
                     {prnt:=Prntmsg})
description " plots Quadrance symbol and value (Q)";
uses plottools; # RationalTrigonometry;
local a,  f,g,h,v1,delta,mp, BoxQ,Qsymbol,pt1,pt2,pt3,pt4,Scl,ptxtp1,ptxtp2,txtplt1,txtplt2,plttyp,thk,l12,pts12;

if P1[1]::{list, Vector[row]} then
   pt1:=`if`(P1[1]::Vector[row],convert(P1[1],list),P1[1]);
   plttyp:=`if`(nops(pt1)=3,3,2); # print(pt1,plttyp);
   ptxtp1:=[op(pt1),op(P1[2..-1])];
   txtplt1:=true;  
 else
   pt1:=`if`(P1::Vector[row],convert(P1,list),P1);#print(pt1);
   plttyp:=nops(pt1);
   txtplt1:=false;
end if;    

if P2[1]::{list, Vector[row]} then
   pt2:=`if`(P2[1]::Vector[row],convert(P2[1],list),P2[1]);#print(pt2);
   if plttyp<>nops(pt2) then error `different dimension in inputs`end if;
   ptxtp2:=[op(pt2),op(P2[2..-1])];
   txtplt2:=true;
 else
   pt2:=`if`(P2::Vector[row],convert(P2,list),P2);#print(pt2);
   if plttyp<>nops(pt2) then error `different dimension in inputs`end if;
   txtplt2:=false;
end if;

#if scl::numeric then
    Scl:=scl;
 #else
  # pt3:=`if`(scl[1]::Vector[row],convert(scl[1],list),scl[1]);
   #pt4:=`if`(scl[2]::Vector[row],convert(scl[2],list),scl[2]);
    #if plttyp = 2 then
     #  Scl:=evalf(sqrt(Quadrance(pt3,pt4,"b","n")/Quadrance(pt1,pt2,"b","n")));
     #else
      # Scl:=evalf(sqrt(Quadrance(pt3,pt4,"n")/Quadrance(pt1,pt2,"n")));
   # end if;
#end if;
if plttyp =2 then
     a :=Scl* dimofset*0.1*leader*[-pt2[2]+pt1[2], pt2[1]-pt1[1]]; #dimension leader lines
  else
     a :=Scl* dimofset*0.1*leader*[-pt2[2]+pt1[2], pt2[1]-pt1[1],pt2[3]-pt1[3]]; #dimension leader lines
end if;
delta:=Scl*(pt2-pt1);
mp:=(1-1/2)*pt1+1/2*pt2;  #midpoint of line
#print(Scl,a,delta,mp);
if plttyp = 2 then
    BoxQ:=[[a[1]+mp[1]+.05*delta[1]-.01*delta[2],a[2]+mp[2]+.05*delta[2]+.01*delta[1]],
           [a[1]+mp[1]-.05*delta[1]-.01*delta[2],a[2]+mp[2]-.05*delta[2]+.01*delta[1]],
           [a[1]+mp[1]-.05*delta[1]+.01*delta[2],a[2]+mp[2]-.05*delta[2]-.01*delta[1]],
           [a[1]+mp[1]+.05*delta[1]+.01*delta[2],a[2]+mp[2]+.05*delta[2]-.01*delta[1]]];
 else
    BoxQ:=[[a[1]+mp[1]+.05*delta[1]-.01*delta[2],a[2]+mp[2]+.05*delta[2]+.01*delta[1],a[3]+mp[3]+.05*delta[3]],
           [a[1]+mp[1]-.05*delta[1]-.01*delta[2],a[2]+mp[2]-.05*delta[2]+.01*delta[1],a[3]+mp[3]-.05*delta[3]],
           [a[1]+mp[1]-.05*delta[1]+.01*delta[2],a[2]+mp[2]-.05*delta[2]-.01*delta[1],a[3]+mp[3]-.05*delta[3]],
           [a[1]+mp[1]+.05*delta[1]+.01*delta[2],a[2]+mp[2]+.05*delta[2]-.01*delta[1],a[3]+mp[3]+.05*delta[3]]];
end if;

if leader<>0  then
   thk:=thickness=0
 elif linetype<>[] then
   thk:=linetype[op(ListTools:-Search(op(select(has,linetype,thickness)),linetype))];
 else
   thk:=thickness=0;
end if;

Qsymbol:= [line(pt1,pt1+a,thickness=0,_rest),
           line(pt1+a,mp-.05*delta+a,thk,_rest),
           line(op([BoxQ[1],BoxQ[2]]),thickness=0,_rest),
           line(op([BoxQ[2],BoxQ[3]]),thickness=0,_rest),
           line(op([BoxQ[3],BoxQ[4]]),thickness=0,_rest),
           line(op([BoxQ[4],BoxQ[1]]),thickness=0,_rest),
           line(pt2+a,mp+.05*delta+a,thk,_rest),
           line(pt2,pt2+a,thickness=0,_rest)];
    
if points<>[]then           
pts12:=point([pt1,pt2],op(points));  #end points
else
pts12:=NULL;
end if;
if linetype<>[] then
l12:=line(pt1,pt2,op(linetype));
  else
  l12:=NULL;
  end if;
if plttyp = 2 then
    f := plots:-textplot([op((pt1+pt2)/2+1*(a)),op(Q)]);  #Quadrance text
   if txtplt1 then
      g := plots:-textplot( ptxtp1);
    else
      g:=NULL;
   end if;
   if txtplt2 then
      h := plots:-textplot( ptxtp2);
    else
     h:= NULL;
   end if;
    v1:=plots:-textplot([op((pt1+pt2)/2), op(vec1)]);#`#mover(mi("v"),mo("&rharu;"))`[1,2]   {below,right}
 else

   f := plots:-textplot3d([op((pt1+pt2)/2+1*(a)),op(Q)]);
   if txtplt1 then
         g := plots:-textplot3d( ptxtp1);
      else
         g:=NULL;
   end if;
   if txtplt2 then
         h := plots:-textplot3d( ptxtp2);
      else
         h:=NULL;
   end if;
    v1:=plots:-textplot3d([op(pt1+pt2)/2,op(vec1)]);#`#mover(mi("v"),mo("&rharu;"))`[1,2]   {below,right}
end if;
#print("pltyp" , plttyp)  ;
if prnt="y" then print(cat("Quadrance symbols  ",clr,"  geometry")); end if;
if leader = 0 then    
    plots:-display(pts12,f,g,h,Qsymbol,axes=none,scaling=constrained);
 else       
         plots:-display(pts12,l12,f,g,h,Qsymbol,axes=none,scaling=constrained);     
end if;
end proc:

 

 

P1:=[2,3,6]:
P2:=[1,5,7]:
P3:=P1+1/3*(P2-P1)

[5/3, 11/3, 19/3]

(2)

plt1:=Qdim([P1,typeset("P1=",P1),align=below],[P2,P2,align=right ],dimofset=2,Q=["Q12\n",align =above],colour=black); use of _rest, colour=black

 

"Quadrance symbols  Blue  geometry"

 

 

Error, missing operator or `;`

 

plt2:=Qdim([P1,typeset("P1=",P1),align=below],[P3,P3,align=right ],scl=2,Q=["Q13\n",align =above],prnt="n") ; #scl affects the linine up of dimesion lines prnt="n" no message displayed

 

plt3:=Qdim(P3,P2,scl=1,Q=["Q23\n",align =above],points=[],linetype=[],clr="RED"); #doesn't plot points and line. shows use of `clr`

 

 

"Quadrance symbols  RED  geometry"

 

 

plots:-display(plt1,plt2,plt3)

 

P5:=[1,2]:P6:=[-1,4]:

Qdim([P5,"P5   ",align={below,left}],[P6,"   P6",align={right}], Q=[typeset("\nQ[5,6]"),align={below,left}],points=[symbolsize=18])

"Quadrance symbols  Blue  geometry"

 

 

Qdim([P5,"P5   ",align={below,left}],[P6,"   P6",align={right}], leader=0,Q=[typeset("\nQ[5,6]"),align={below,left}],points=[symbolsize=18])

"Quadrance symbols  Blue  geometry"

 

 

 


 

Download 2024-03-09_Example_parm_names.mw

@acer  Oh yes that is nicer using infix.  Really sometimes I miss the obvious. I have being using plottools:-line for the past two weeks. 

@dharr  Thank you. Not a problem entring the curves seperately. Probably makes things easier to track and debug in general.

@erik10 Did you ever get this to work for you? I want to embed a plot in 3D format into a 3D PDF.

I have found some data on line about doing this this but it is all 10-14 years old.

@erik10 Did you ever get this to work for you? I want to embed a plot in 3D format into a 3D PDF.

I have found some data on line about doing this this but it is all 10-14 years old.

@Carl LoveThis looks to be a best pratical option in general. It might be a day or two before I get back to this. Is _rest the required name, i.e something specified inside Maple. Could a name such as Additionaloptions be be used? 

A 3d pdf is attached. It is from a CAD systen. You can rotate the image like you can do with a 3D plot in Maple. Adobe will give you a warning when opening this.

I will look into the  EPS export.

CAD_3D_bolt.zip

@Kitonum @Carl Love @Preben Alsholm ​​​​​​​@sand15 these are all great answers. 

@sand15 That deserves a vote up.

@Carl Love I like that.

@Carl Love I find sometimes it works and sometimes not. About 50-50. I find it useful because it scrolls directly to the response clicked on.

 

@acer   That is precisely what I was trying to achieve.

@rlopez That is good to know. I never think of using the the Student Package.

5 6 7 8 9 10 11 Last Page 7 of 29