Ronan

1376 Reputation

16 Badges

13 years, 270 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

 Yes this whole Deleted thing has become a pain. As said by someone else it clutters valid threads. So is it a site bug or somebodies intention?

Basically my feeling is the site needs a good overhaul. I see the Art gallery has been added. That is a nice touch. But that does not fix the long standing issues that have been complained about. 
Who is actually responsible for the maintenance and development of this site? 
@janhardo  No. I don't think it is wrong if you decide to delete your own answer.

Edit: On deleted questions with answers. If such are deleted, which really irritates the responders, does that stick around as deleted?

@acer  I dedided to have a manually adjustable scale factor in the arctan of the angle. This is a a bit fiddly to use but it does work quite well. The procedure also prevents the text from turning upsidedown. It needs more work but it proves out the concept. 

Basically in the package  I have 5 plotting procedures that can all use the same global variables so they work together. I have just inckuded part of the text plotting one here, Some function in it might not work here.

Really what I am using it for it making technical diagrams for the help pages.

Download 2024-10-21_A_Mnaual_scale_adjustment.mw

@acer @nm Thank you for the information.

Acer, I will come back to you on the rotated text question. It might take a few nights. Am stretched a bit thin at the moment. 

@mmcdara Thank you for your good examples. I have to study to Image Tools commands to understand what you have done properly. I think saving  text to an image is probably is to difficult to use in my application. But I will keep the concept in mind. 

@mmcdara Ah.. that question. That was to to do with aligning/rotating text in 3D which currently can't be done.

Really what I trying to find out. Is there a way to access what Maple calculates as a scaling ratio when plots:-display(.....) is unconstrained.

@Christopher2222 Could you do a quick example of using text as a picture element?

@Scot Gould Nice.

@Kitonum @Rouben Rostamian Thank you both for you answers. I decided to go with 

with(LinearAlgebra):
if ((l1 &x l2) . (l1 &x l2)) =0 then....

because this also handles the case of one vector being a multiple of the other. I was looking at the vectors being equal but parallel is more appropiate description.

This works and it handles one vector being a multiple of the other.

with(LinearAlgebra):
((l1 &x l2) . (l1 &x l2))

@acer This is the complete procedure. You actually did a lot of work on it a few months ago. 
maplemint is only showing typeset as an undeclarel global variable. Do I just add
global typeset;

The shift seems to work well. What I did find is, have to count from 2nd item in the lists eval(':-shift',Q[2..-1])::float  because the text being the first  my not have an `=`.

I copied in other examples too to give an insight as to what the other parametes do.

 

 

restart

 


Qdim := proc(P1, P2, {Q:=[ ]},
                     {corp::{"cart","proj"}:="cart"},#cartesian or projective
                     {shift::float:=0.5},
                     {vec::list:=[]},
                     {scale::{list,integer}:=1},
                     {leader::{-1,0,1}:= 1},
                     {dimoffset::{1/6,1/5,1/4,3/4,2/3,1/2,1/3,1,3/2,2,3,4,5,6}:=1},
                     {point::list:=['color' = ':-blue', symbol = ':-solidcircle', 'symbolsize' = 12]},
                     {line::list:=['thickness'=3]},
                     {plopts::list:=[]})
description " plots Quadrance symbol and value (Q)";
uses pl=plots, pt=plottools ;#, RationalTrigonometry;

local a,f,g,h,v1,delta,mp, BoxQ,Qsymbol,ldr,pt1,pt2,pt3,pt4,Scl,xpsn,ypsn,zpsn,
      ptxtp1,ptxtp2,txtplt1,txtplt2,plttyp,thk,l12,pts12,perp::boolean:=false,qshift,vshift;
global Projective_Z_Position;
if Projective_Z_Position=1 then   
     xpsn:=2;
     ypsn:=3;
     zpsn:=1;
     else  
     xpsn:=1;
     ypsn:=2;
     zpsn:=3;  
end if;
if P1::{list} and P1[1]::{list,'Vector[row]'(3)} then
   if P1[1]::'Vector[row]'(3) then
      pt1:=[P1[1][xpsn]/P1[1][zpsn],P1[1][ypsn]/P1[1][zpsn]];#print(pt1);
    elif  P1[1]::list then
      pt1:=P1[1];
   end if;     
   plttyp:=`if`(nops(pt1)=3,3,2); # print(pt1,plttyp);
   ptxtp1:=[op(pt1),op(P1[2..-1])];
   txtplt1:=true;  
 else
   if P1::'Vector[row]'(3) then
        pt1:=[P1[xpsn]/P1[zpsn],P1[ypsn]/P1[zpsn]];
    else
        pt1:=P1;
   end if;
   plttyp:=nops(pt1);
   txtplt1:=false;
end if;    

if P2::{list}  and P2[1]::{list,'Vector[row]'(3)} then
   if P2[1]::'Vector[row]'(3)  then
      pt2:=[P2[1][xpsn]/P2[1][zpsn],P2[1][ypsn]/P2[1][zpsn]];

    elif  P2[1]::list then
      pt2:=P2[1];
   end if;     
   plttyp:=`if`(nops(pt2)=3,3,2); # print(pt2,plttyp);
   ptxtp2:=[op(pt2),op(P2[2..-1])];
   txtplt2:=true;  
   
 else
   if P2::'Vector[row]'(3)then
      pt2:=[P2[xpsn]/P2[zpsn],P2[ypsn]/P2[zpsn]];
 
    else
      pt2:=P2;
   end if;
   plttyp:=nops(pt2);
   txtplt2:=false;
end if;
#print(Projective_Z_Position,xpsn,ypsn,zpsn);   


if type(scale,'numeric') then
    Scl:=scale;
 else
   if scale[1]::Vector[row](3) then
        pt3:=   [scale[1][xpsn]/scale[1][zpsn],scale[1][ypsn]/scale[1][zpsn]];
    
     else
        pt3:=scale[1];
    end if;
   if scale[2]::Vector[row](3) then
        pt4:=  [scale[2][xpsn]/scale[2][zpsn],scale[2][ypsn]/scale[2][zpsn]];
    
     else
        pt4:=scale[2];
    end if;
    if plttyp = 2 then
       Scl:=evalf(sqrt(((pt3[1]-pt4[1])^2+(pt3[2]-pt4[2])^2)/((pt1[1]-pt2[1])^2+(pt1[2]-pt2[2])^2)));#:-print(Scl);
    
     else
       Scl:=evalf(sqrt(((pt3[1]-pt4[1])^2+(pt3[2]-pt4[2])^2)/((pt1[1]-pt2[1])^2+(pt1[2]-pt2[2])^2)));#:-print(Scl);
  
    end if;
end if;
#print(Scl,pt1,pt2,pt3,pt4);
if plttyp =2 then
     a :=Scl* dimoffset*0.1*leader*[-pt2[2]+pt1[2], pt2[1]-pt1[1]]; #dimension leader 2d lines
  else
     a :=Scl* dimoffset*0.1*leader*[-pt2[2]+pt1[2], pt2[1]-pt1[1],pt2[3]-pt1[3]]; #dimension leader 3d lines
end if;
delta:=Scl*(pt2-pt1);
if Q<>[] and eval(':-shift',Q[2..-1])::float then
         qshift := eval(':-shift',Q[2..-1]);
       else
         qshift := shift;
      end if;
      print("qshift=",qshift);

  if vec<>[] and eval(':-shift',vec[2..-1])::float then
    vshift := eval(':-shift',vec[2..-1]);
  else
    vshift := shift;
  end if;
 print("vshift=",vshift);
 
mp:=(1-qshift)*pt1+qshift*pt2;  #midpoint of line
#:-print(Scl,a,delta,mp);
if plttyp = 2 then
#coorfinates of the sqnbol corners
    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  #3D
    BoxQ:=[[a[1]+mp[1]+.05*delta[1]-.01*delta[2],a[2]+mp[2]+.05*delta[2]+.05*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]+.05*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]-.05*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]-.05*delta[1],a[3]+mp[3]+.05*delta[3]]];
end if;

if leader<>0  then
   thk:='thickness'=0
 elif line<>[] then
   thk:=line[op(ListTools:-Search(op(select(has,line,'thickness')),line))];
 else
   thk:='thickness'=0;
end if;
if corp="cart" then
   Qsymbol:=[pt:-line(pt1,pt1+1.05*a,'thickness'=0,plopts[]),
             pt:-line(pt1+a,mp-.05*delta+a,thk,plopts[]),
             pt:-line(op([BoxQ[1],BoxQ[2]]),'thickness'=0,plopts[]),
             pt:-line(op([BoxQ[2],BoxQ[3]]),'thickness'=0,plopts[]),
             pt:-line(op([BoxQ[3],BoxQ[4]]),'thickness'=0,plopts[]),
             pt:-line(op([BoxQ[4],BoxQ[1]]),'thickness'=0,plopts[]),
             pt:-line(pt2+a,mp+.05*delta+a,thk,plopts[]),
             pt:-line(pt2,pt2+1.05*a,'thickness'=0,plopts[])];
  elif (Q[1])=1 or Q[1]::specfunc(typeset) and ormap(is, [op(Q[1])], 1)  and corp="proj"   then
      if leader=0 or leader=1 then ldr:=1 else ldr:=-1 end if;
   Qsymbol:=[pt:-line(mp-.05*delta*dimoffset,mp+ldr*.05*[-delta[2],delta[1]]*dimoffset,thk,plopts[]),
             pt:-line(mp+ldr*.05*[-delta[2],delta[1]]*dimoffset,mp+.05*delta*dimoffset,thk,plopts[])];
             perp:=true;
  else
   Qsymbol:=[pt:-line(pt1,pt1+1.05*a,'thickness'=0,plopts[]),
             pt:-line(pt1+a,mp-.05*delta+a,thk,plopts[]),
             pt:-line(op([BoxQ[1],BoxQ[2]]),'thickness'=0,plopts[]),
             pt:-line(op([BoxQ[2],BoxQ[3]]),'thickness'=0,plopts[]),
             pt:-line(op([BoxQ[3],BoxQ[4]]),'thickness'=0,plopts[]),
             pt:-line(op([BoxQ[4],BoxQ[1]]),'thickness'=0,plopts[]),
             pt:-line(pt2+a,mp+.05*delta+a,thk,plopts[]),
             pt:-line(pt2,pt2+1.05*a,'thickness'=0,plopts[])];
end if;
if point<>[]then           
pts12:=pt:-point([pt1,pt2],point[]);  #end points
else
pts12:=NULL;
end if;

 


if line<>[] then
l12:=pt:-line(pt1,pt2,line[]);
  else
  l12:=NULL;
  end if;
 if plttyp = 2  then
   if perp=false then
     
      f := pl:-textplot([op(((1-qshift)*pt1+qshift*pt2)+1*(a)),op(Q)]);  #Quadrance text
    else
      f:=NULL;    #dont plot value with perp symbol
   end if;
   if txtplt1 then
      g := pl:-textplot( ptxtp1);
    else
      g:=NULL;
   end if;
   if txtplt2 then
      h := pl:-textplot( ptxtp2);
    else
     h:= NULL;
   end if;
   if vec <> [] then
      v1:=pl:-textplot([op(((1-vshift)*pt1+vshift*pt2)), op(vec)]);#`#mover(mi("v"),mo("&rharu;"))`[1,2]   {':-below',':-right'}
    else
      v1:=NULL;
   end if;
 else
   if perp=false then
      f := pl:-textplot3d([op(((1-qshift)*pt1+qshift*pt2)+1*(a)),op(Q)]);
    else
      f:=NULL;    #dont plot value with perp symbol
   end if;
   if txtplt1 then
         g := pl:-textplot3d( ptxtp1);
      else
         g:=NULL;
   end if;
   if txtplt2 then
         h := pl:-textplot3d( ptxtp2);
      else
         h:=NULL;
   end if;
   if vec <> [] then
    
         v1:=pl:-textplot3d([op(((1-vshift)*pt1+vshift*pt2)),op(vec)]);#`#mover(mi("v"),mo("&rharu;"))`[1,2]   {':-below',':-right'}
     else
         v1:=NULL;
   end if;
end if;
#:-print("pltyp" , plttyp)  ;

if leader = 0 then    
      pl:-display(pts12,f,g,h,v1,Qsymbol,'axes'=':-none','scaling'=':-constrained');
 else       
      pl:-display(pts12,l12,f,g,h,v1,Qsymbol,'axes'=':-none','scaling'=':-constrained');     
end if;
end proc:

 

maplemint(Qdim);

Procedure Qdim( P1, P2, { Q := [], corp::{"cart", "proj"} := "cart",
    dimoffset::{1, 2, 3, 4, 5, 6, 1/2, 1/3, 1/4, 1/5, 1/6, 2/3, 3/2, 3/4} :=
    1, leader::{-1, 0, 1} := 1, line::list := ['thickness' = 3], plopts::list
    := [], point::list := ['color' = ':-blue', symbol = ':-solidcircle',
    'symbolsize'
= 12], scale::{integer, list} := 1, shift::float := .5,
    vec::list := [] } )
  These names were used as global names but were not declared:  typeset

 

Projective_Z_Position:=3:

pp1:=<1|3|2>:pp2:=<2|3/2|1/2>:#projective points

P5:=[1,0]:P6:=[5,2]:

 

#default value of shift=0.5
Qdim([pp1,typeset("P1 ",pp1),align={below, right},color=magenta],pp2,dimoffset=3,Q=[typeset("Q=",3),align=[below,right]],vec=[(\n`#mover(mi("v"),mo("&rharu;"))`[1,2]),align={above,left},font=["century",14]],plopts=[color=blue])

 

 

 

 

 

 

"qshift=", .5

 

"vshift=", .5

 

 

#shift =0.8
Qdim([pp1,typeset("P1 ",pp1),align=[below,right],color=magenta],pp2,dimoffset=3,Q=[typeset("Q=",3),align=[below,right]],vec=[(\n`#mover(mi("v"),mo("&rharu;"))`[1,2]),align={above,left},font=["century",14]],shift=0.8,plopts=[color=blue])

"qshift=", .8

 

"vshift=", .8

 

 

#individual shift values for Q and vec override main shift value
Qdim([P5,typeset("P5 ",P5),align=[below,right],color=magenta],[P6,typeset("P6 ",P6),color="Green",align=right],dimoffset=3,Q=[typeset("Q=",20),colour=blue,align=[below,right],shift=0.35],vec=[(\n`#mover(mi("v"),mo("&rharu;"))`[5,6]),align={above,left},font=["century",14]],shift=0.8,plopts=[color=indigo],line=[thickness=2,linestyle=dash])

"qshift=", .35

 

"vshift=", .8

 

 

P1:=[4,5]:P2:=[-1,3]:P3:=[2,-5/2]:
P4:=(1-3/10)*P1+3/10*P2:
P5:=(1-6/10)*P1+6/10*P2:

# Stacking dimensions by using scale, leader and dimoffset. Plus use of colour.
plt7:=Qdim([P1,typeset("  P1=",P1),align=[right],colour=red],[P2,typeset("P2=",P2,"  "),align=[left,above]] ,Q=[typeset("Q12=",29),align =[above,left]] ,leader=-1,dimoffset=5, point=[symbolsize=12,symbol=solidcircle,colour=blue]):
plt8:=Qdim(P1,[P4,typeset("P4=",P4,"   "),align=[left,above]] ,Q=[typeset("Q14=",261/100),align =[above,left]] ,scale=[P1,P2],leader=-1,dimoffset=1, point=[symbolsize=12,symbol=solidcircle,colour=blue]):
plt9:=Qdim(P1,[P5,typeset("P5=",P5,"   "),align=[below,right] ] ,Q=[typeset("Q15=",261/25),align =[above,left]] ,scale=[P1,P2],dimoffset=3,leader=-1,point=[symbolsize=12,symbol=solidcircle,colour=blue],plopts=[colour=blue]):
plots:-display(plt7,plt8,plt9)

 

"qshift=", .5

 

"vshift=", .5

 

"qshift=", .5

 

"vshift=", .5

 

"qshift=", .5

 

"vshift=", .5

 

 

# Form a triangle. More use of colour and leader=0.
plt10:=Qdim(P1,[P3,typeset("P3=",P3),align=[right,below]],leader=0,Q=[typeset("   Q13=",241/4),align =[right]],plopts=[colour=purple]):
plt11:=Qdim(P2,P3,Q=[typeset("Q23=",157/4,"  "),align =[left]],leader=-1,point=[symbolsize=12,symbol=solidcircle,colour=blue],line=[colour="Green",thickness=2],plopts=[colour=purple]):
plots:-display(plt7,plt8,plt9,plt10,plt11,size=[750,750])

"qshift=", .5

 

"vshift=", .5

 

"qshift=", .5

 

"vshift=", .5

 

 

# A diagram with default dimension formats.
plt1:=Qdim([P1,typeset("  P1=",P1),align=[right],colour=red],[P2,typeset("P2=",P2),align=[left,above]] ,Q=[typeset("Q12=",29),align =[below,right]] , point=[symbolsize=12,symbol=solidcircle,colour=blue]):
plt2:=Qdim(P1,[P4,typeset("P4=",P4),align=[left,above]] ,Q=[typeset("Q14=",261/100),align =[below,right]] , point=[symbolsize=12,symbol=solidcircle,colour=blue]):
plt3:=Qdim(P2,P4 ,Q=[typeset("Q24=",1421/100," "),align =[below,right]] , point=[]):
plots:-display(plt1,plt2,plt3,size=[600,600])

"qshift=", .5

 

"vshift=", .5

 

"qshift=", .5

 

"vshift=", .5

 

"qshift=", .5

 

"vshift=", .5

 

 

# Using scale, leader and dimoffset to create a clearer diagram.
plt4:=Qdim([P1,typeset("P1=",P1),align=[right],colour=red],[P2,typeset("P2=",P2),align=[left,above]] ,Q=[typeset("Q12=",Q29),align =[below,right]] , point=[symbolsize=12,symbol=solidcircle,colour=blue]):
plt5:=Qdim(P1,[P4,typeset("P4=",P4,"   "),align=[left,above]] ,Q=[typeset("Q14=",261/100),align =[above,left]] ,scale=[P1,P2],leader=-1,dimoffset=2, point=[symbolsize=12,symbol=solidcircle,colour=blue]):
plt6:=Qdim(P2,P4 ,Q=[typeset("Q24=",1421/100),align =[above,left]] ,scale=[P1,P2],dimoffset=2, point=[]):
plots:-display(plt4,plt5,plt6)

"qshift=", .5

 

"vshift=", .5

 

"qshift=", .5

 

"vshift=", .5

 

"qshift=", .5

 

"vshift=", .5

 

 

 


 

Download 2024-9-18-QA_Applifation.mw

@mmcdara Very Nice. You should convert it to an asnwer. It is much less brute force than mine.

@acer I use the VS code editor with the Maple addin. Is there a difference between mint and maplemint. The code editor can run the command line version of maple and maplemint, which is very useful.
I don't find maplemint much good inside maple though.

@Kitonum I was bored at work.I didn't see that one. I was looking at you solution too.

On vectors v1,v2, I would use the determinat of the vector matrix as gives the signed area of a rectangle (so could be negative).

 

M:=<v2|v1> #
S1:=LinearAlgebra:-Determinant(M)/2;
simplify(S1, {a*b=24}); # The answer

 

@Carl Love @Kitonum Thank you for your answers. I often struggle with the has select I never knew about primpart. I have two applications for simplifying one internal insde a packake and the other a commmand in another package. In the internal case I don not need to know the factors so primpart will be very useful there. Can you explain "searched for (disjunctively)"

On the command version the factors are be useful to have returned. 

@acer Thank you. I had to look at that eval(colour, styles1) for a couple of minutes befor it dawned on me why! Very Nice.

2 3 4 5 6 7 8 Last Page 4 of 32