Maple 7 Questions and Posts

These are Posts and Questions associated with the product, Maple 7

Letter_V_kaput.mwsLetter_V_working.mws

The two attached programs are such that the "kaput" version uses a procedure to draw the letter V, with the option of a flat top or pointed top.  The last parameter, s, takes on values "p" or "f" for pointed or flat respectively. - but I get error messages.  The Letter_V_working programdoes not use a proc, but works.  Where is the error?

  Thanks in advance for any help.

   .  .

cone_rail_track_Maple.mws

The attached program is of a point moving along a conical path of a cone, then doing a descent back to the start.   For values R=60, r=20, h=10 the animation seems to work reasonably well.  However when r=19 - only a small change - the development plot of the cone is only partially shown?   Also, I have some variables nameP1, nameP2 which I would like to alter the color of.  Howdo I do this?

  Any comments or help most appreciated. 

# About twenty years ago Joe Riel posted 

#printing_just_for_fun.mws   by Joe Riel 30-6-‘98

#As part of this he had:

 d_string:="D*e*v*o*u*r*e*r":

#eta:=symb(217):

print(cat(`Does `,d_string,` = `));

eta;
#Is it possible to put the eta symbol on the same line?

#   Yes,  …but without the comma??  And…
 printf("Does %s = %a\n",d_string, eta);

#  does not give the Greek letter eta, but just eta,  while

eta;

print(eta);
#...both give the Greek letter

#  Is it possible to use printf (or similar?) to obtain output 

#  of:  Does D*e*v*o*u*r*e*r = h  

#  Oops!  In Word the h was a Greek letter eta!

#  ...and lastly, can it be done in Maple 7?

LettR_curvefitting.mws

Am in the process of trying to addsome animation to a 2D letter R, namely to make the 'stalk' move.  I lost the output and managed to retrieve it by adding  verboseproc=0, and printlevel:=5.  However printlevel:=5 gives an excessive amount of output and anything less than 5 doesn't give enough output.  The code is messy asI've been experimenting with general curve fitting.

   Any help gratefully received. 

CurveFitting.mws

Splines and BSplines etc for curve fitting.

The attached short program uses with(CurveFitting) and BS:=BSpline(2,x);  outputs four expressions, the third being 

2-x, x<2.  I'd like to be able to access this, and plot it. but plots[display](BS[3], x=1..2); comes up with an error message.

Thanks in advance for any help. 

cutin.mws

Am trying to learn about commands in Maple 7 I have not come across before - namely cutin, cutout and project.  Am I correct in thinking these commands are for use in three dimensions, and won't work in two dimensions?  Examples in the Help section seem to be confined to 3D.

  In the attached program I created a triangle (triag)using the polygon feature, then used project(triag, [[0,0.5],[2,2]]) to see what the resultant plot would be.  It was a line segment with length of the triangle - as if it was the shadow of the triangle.  Am I right in thinking a 3D object would give a 2D shape using this project command?

Thanks, David 

E_dislocated_bar.mws

I wish to make the letter E from a previous program of the letter F - which seemed to work perfectly.  I've added the base arm to the F - with it looking like the letter Fand trailing base.  Further comments in the program.  Tags are polygon, patchnogrid, LINE, animation  Help please. 

Lett_L_rot_AL_MapleQuestion.mws

If the attached program is run, at the end are two animation outputs.  One is of two letters A; the other of the single second A being animated.   The second letter A animation works fine, but in the former it "blips" on Continuous animation, and on 'single cycle' the A totally disappears.  I'm using the same number of frames, 48, for each. 
   Prior to that is the letter L which is meant to give the illusion of it rotating, and the letters A getting out of the way.

   Any help on ridding the "blip" most appreciated. 

Color_letterD.mws

The attached program shows a convex shape viz the letter D made of an implicit curve and a straight upright line.  I'd like to color the interior.  I was thinking of trying to make a polygon from the points of the curve - but I don't know how to access them.  If I could access them I could put the coordinates in a list L:=[[x1,y1],[x2,y2]...[xn,yn]]  and then just use plots( polygon(L).).

Any suggestions appreciated.   ...and please keep it simple - I'm only using Maple 7.

Lett_K_etc_Coloring.mws

In the attached program the letters K, M, H are drawn.  These are examples of concave polygons.  (The fact that they happen to be letters is immaterial here.)  I'm interested in the coloring in process.  I experimented with simple shapes, like the letters I and L, which have a small number of points - and the letter I is convex.  These polygons colored in without a hitch.  It seems a general rule is:

    Color the first half dozen points given, then head home towards the first point - then return to the next point.  Does it color in by separating the polygon into pentagons, or hexagons?  

   I'm aware of how to draw & color shapes by splitting them into a smaller number of polygons, so please don't waste time improving my code.   I'dd appreciate my hunch being verified, or a reference to more information.  TIA

Letter_Lrotate2D.mws

   I've asked a similar question before, and got the letters to rotate in 3D using the rotate command.  The resulting size in a 3D plot is relatively small..  The program gives a plotted letter L.  I wish to get some animation of it being rotated about the y-axis - but remaining in 2D.  ie looking at the letter it appears to be rotating.  To do thisI have multiplied the x-coords by the cosine of the angle of rotation.   

   In the for loop towards the end of the program there is a variable c1 which is incremented by one in the loop - yet it remains at 2, regardless of the angle increments.   Why is that?

  Again, any help or comments much appreciated.

Letter_L_rotate.mws

The attached program is of the letter L rotating.  about an axis which is the outer side of the 'upright' of the L.  I want to give the illusion that the letter L is rotating about a y-axis, where the x, y axes are in the plane of the screen, with the x-axis going from left to right.  The program at present 'works', in the sense that the letter L is rotating about an axis.  ...but it's not quite what I want.  My eventual aim is to plot the letters A and L side by side, AL, and as the letter L rotates the leg of the L would bump into the A,  so I want the A to rise in sync with movement of the letter L.   ...but that's a long way off!  For the moment I just want to know how to orientate the letter L, so that it is in its usual L state

   I think I have two options: either to change the coordinate positions of L, (long and tedious..) or quicker might be to change the axis of rotation.  Any suggestions on making the animation smoother would also be appreciated.

Thanks, David

 .

Lesson_on_functions.mws

As the title says, a lesson on functions:  eg the -> operator, f(2), eval, evalf etc 

LetterA_Axes_query.mws

  The attached shows animation of the letter A. The animation works fine, and in the plot diagram of the large letter A, the axes are shown.  However, in the second plot (animated), the axes are not being shown, despite clicking on Axes in the animation.  The choices here are Boxed, Framed, Normal or None.

  In the Maple 7 documentation on Axes it states "From the Axes menu choose Ranges...."   ...but I can't see Ranges. 

Any reasons for this?

 This post is similar to an earlier post of mine about an artist drawing the letter A as a hole in line paper.  Replicating that in Maple I have put in the 'too hard' basket for now.  I decided to draw the capital letters of the alphabet.  I started with the letter A, not just because it is the first letter, but that that I thought it was of intermediate difficulty.   (...as well as having lady friends with names starting  with B!:-))  Easier letters would be I and L.   One can draw these using the polygon command.  'A' is harder as it has inner regions which must be catered for viz the triangle and trapezium base.  There are about ten letters of the alphabet with curves:  {B, D, P, R, S} and  { J. G, C  O }.   They all have curved portions, but the former set have curves which "bulge out to the right", (with the possible exception of letter S.)  I decided to dive in and tackle the letter B.  I'd heard of Bezier curves and tried to learn about these.  (More later).  Owing to the bulging B, I decided I'd try to liken that part to an ellipse.  I was not happy with the curvature, so tried modifying the equation, involving powers of 4.  After quite a lot of time I managed to get the upper part of the letter  B.  There were difficulties in coloring the letter and I am indebted to Carl (Love aka DeVore) who I recalled mentioned about the order of displaying the various sections of the letter: that saved me hours of anguish!  At this stage the resulting output was that of the letter D, and I was getting tired.  I did a copy and paste of this code into the program below, to compare the output with my previous letter A.  I was disappointed  as the output for the D was almost non-existent.  Initially I thought there may be differences in the values used for A and D and changed x0, y0 for x0D, y0D - but to no effect.  The cut and paste section of D is between the # # # # .

   The output of the rotated letter A, has 'worked' but it looks unusual - I'm not sure if I suffer from slight astigmatism, or there's a bug in my code!  Comments on this please.  I'm not expecting a close inspection of the code - that may be like finding a needle in a haystack. Any ideas as to why there is little output for D?.  

Bezier Curves

         Restarting from my previous comment on letters C. J etc these have curves which are orientated something akin to y=x^2 - or in maths lingo, their base curves can be represented by functions.  I found sparse mention of Bezier curves on the Maple site, but there are many sites now describing how to construct these.  I'll just constrict talk to quadratic Bezier curves.  A Bez quad curve can be obtained by multiplying PMT - (nothing to do with women's problems!) - where (I think) P is a 1x3 row vector ( P0 P1 P2), M is a 3x3 matrix <1  -2   1,  -2  2  0,  1  0  0> and T is a 3x1 column vector <t^2, t, 1>  and 0<t<1.

  On multiplying this out it comes to something like:

C(t) =(P0-2P1+P2)t^2+ (-2P0+2P1)t +P0

   This is the equation of a quadratic, or parabola, but I'm not sure how to apply it:-(  I believe the P are related to coords of  "control points" , and when t=0 the parabolashould pass through one's begining point, and similarly when t=1 it should correspond to the end point of one's desired curve.

  I'd appreciate some feedback on whether my ideas are correct.  What are P0,P1,P2 ?  Numbers, vectors?  How are they related to the control points?  ...and the coords of initial & last points of one's curve.  It seems to me there is still a lot of trial and error work to do, but I suppose in a GUI environment the user is using a device to view the curve and can quickly choose the appropriate one.

     Thanks for reading this long missive, and again any feedback is much appreciated.

David    

 

restart:

# # # # # # # # # # # #  # # # # # # # #

# Second attempt at the letter A: earlier working version was

# letterA_Art_trick.mws

# Functional operators.  Use of ->

# to find coords of rotated points.

 

#To Do: 

#Rotate Trig through phi

#   "   trapezL

# Orientation looks wrong

#  Check - then put in a proc

# non-numeric vertex in trigArL

# # # # # # # # # # # #  # # # # # # # #

with(plots):

with(plottools):

# Following are parameters for A : to later put in proc(...)

# phi rotates the A through that angle about the origin/

l:=12:w:=2:thet:=Pi/2.7:topl:=2:x0:=2:y0:=5:phi:=3*Pi/4:

 h := (x, y) -> [x*cos(phi)-y*sin(phi), x*sin(phi)+y*cos(phi)]:

 

#Alist is list of coords for letter A

Alist:=[[x0,y0],[x0+l*cos(thet),y0+l*sin(thet)],[x0+l*cos(thet)+topl,y0+l*sin(thet)],[x0+2*l*cos(thet)+topl,y0], [x0+2*l*cos(thet)+topl-w,y0],[x0+5*l*cos(thet)/3+topl-w,y0+l*sin(thet)/3],[x0+l*cos(thet)/3+w,y0+l*sin(thet)/3], [x0+w,y0]]:

#outA:=polygon([[x0,y0],[x0+l*cos(thet),y0+l*sin(thet)],[x0+l*cos(thet)+topl,y0+l*sin(thet)],[x0+2*l*cos(thet)+topl,y0], [x0+2*l*cos(thet)+topl-w,y0],[x0+5*l*cos(thet)/3+topl-w,y0+l*sin(thet)/3],[x0+l*cos(thet)/3+w,y0+l*sin(thet)/3], [x0+w,y0]]):

 

#trigA is small inner triangle of letter A - not rotated

 

eps:=3*w/4:

corr:=.3*w:

#trigA:=polygon([[x0+(2*l*cos(thet)+topl)/2, #y0+l*sin(thet)-eps],[x0+w+(l/3+corr*w)*cos(thet), #y0+(l/3+corr*w)*sin(thet)],[x0+2*l*cos(thet)+topl-w-(l/3+corr*w)*cos(thet)#, y0+(l/3+corr*w)*sin(thet)]], color=white):

 

trigA_L:=[[x0+(2*l*cos(thet)+topl)/2, y0+l*sin(thet)-eps],[x0+w+(l/3+corr*w)*cos(thet), y0+(l/3+corr*w)*sin(thet)],[x0+2*l*cos(thet)+topl-w-(l/3+corr*w)*cos(thet), y0+(l/3+corr*w)*sin(thet)]]:

trigArL:=[]:

for i from 1 to 3 do

  #Get coords from trigA_L

x:=trigA_L[i][1]:

y:=trigA_L[i][2]:

 

# Add coords to new rotated list trigAr

#L := [op(L),x[5]];

trigArL:=[op(trigArL), h(x,y)]:

end do:

#trigArL;

trigAr := polygon(trigArL, color=white, linestyle=1, thickness=1):

#plots[display](trigAr);

 

#Read coords of Alist into another list after first transforming the #coords using func op h.  Angle of rot is phi.  thet is inclination of #letter A

#Main Outline of letter - but NOT the convex hull

Alistr:=[]:

#  h := (x, y) -> [x*cos(phi)-y*sin(phi), x*sin(phi)+y*cos(phi)]:

for i from 1 to 8 do

  #Get coords from Alist

x:=Alist[i][1]:

y:=Alist[i][2]:

 

# Add coords to new rotated list Alistr

#L := [op(L),x[5]];

Alistr:=[op(Alistr), h(x,y)]:

end do:

l2 := polygon(Alistr, color=wheat, linestyle=1, thickness=1):

 

# # # # # # # # # # # # # # # # #

#plots[display](trigAr,l2);

#plots[display](trigAr,trapezL, l2);

#trigAr,

 

#thet:=Pi/3:

# Rotation by thet  anti-clockwise about the origin

#h := (x, y) -> [x*cos(thet)-y*sin(thet), x*sin(thet)+y*cos(thet)]:

#h(sqrt(3), 1);

 

# To find a polygon (trapezium EFGH??) which is the shape of he base of A.

# This is necessary as this portion is colored same as rest of A.

#trapezr:=polygon([[(x0+2*l*cos(thet)+topl-w)*cos(phi)-y0*sin(phi),(x0+2*l*#cos(thet)+topl-w)*sin(phi)+y0*cos(phi)],[(x0+5*l*cos(thet)/3+topl-w)*cos(p#hi)-(y0+l*sin(thet)/3)*sin(phi),(x0+5*l*cos(thet)/3+topl-w)*sin(phi)+(y0+l#*sin(thet)/3)*cos(phi)],[(x0+l*cos(thet)/3+w)*cos(phi)-(y0+l*sin(thet)/3)*#sin(phi),(x0+l*cos(thet)/3+w)*sin(phi)+(y0+l*sin(thet)/3)*cos(phi)],[(x0+w#)*cos(phi)-y0*sin(phi),(x0+w)*sin(phi)+y0*cos(phi)]],color=white,filled=tr#ue,  linestyle=DOT):

 

#trapezL is a list of coords of the base trapezium

#THESE coords have not been rotated.  Repeat previous procedure to obtain #rotated coords

trapezr:=[]:

for i from 5 to 8 do

  #Get coords from Alist

x:=Alist[i][1]:

y:=Alist[i][2]:

 

# Add coords to rotated list trapezr

trapezr:=[op(trapezr), h(x,y)]:

end do:

#trap2 := polygon(trapezr, color=wheat, linestyle=1, thickness=1):

 

#trapezL:=polygon([[x0+2*l*cos(thet)+topl-w,y0],[x0+5*l*cos(thet)/3+topl-w,y0+l*sin(thet)/3],[x0+l*cos(thet)/3+w,y0+l*sin(thet)/3], [x0+w,y0]], color=red):

trapezL:=polygon(trapezr, color=white):

 

# lbase is an unseen line at base of the trapezium of A.  Colored white # as needed to be hidden

lbase:=line([(x0+2*l*cos(thet)+topl-w)*cos(phi)-y0*sin(phi),(x0+2*l*cos(thet)+topl-w)*sin(phi)+y0*cos(phi)], [(x0+w)*cos(phi)-y0*sin(phi),(x0+w)*sin(phi)+y0*cos(phi)], color=white):

 

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Letter D  (or top part of B!)

a := .6: b := .5: x0D := 1: y0D:=7:

c1:=15:n:=4:

pl1:=plot([x, y0D+b^2*sqrt(c1-(x-x0D)^n/a^2), x=1..2.6], scaling=constrained, color=wheat,filled=true):

pl2:=plot([x, y0D-b^2*sqrt(c1-(x-x0D)^n/a^2), x=1..2.6], scaling=constrained, color=red, filled=true):  #was white

pl3:=plot([x, y0D+b^2*sqrt(c1/2-(x-x0D)^n/a^2), x=1.3..3], scaling=constrained, color=blue,filled=true):  #was white

pl4:=plot([x, y0D-b^2*sqrt(c1/2-(x-x0D)^n/a^2), x=1.3..3], scaling=constrained,color=wheat, filled=true):

x:=1.3:

#Create & Draw inner up line of D

ylow:=eval(y0D-b^2*sqrt(c1/2-(x-x0D)^n/a^2)):

yhigh:=eval(y0D+b^2*sqrt(c1/2-(x-x0D)^n/a^2)):

l_up_in:=line([x,ylow], [x,yhigh], color=wheat):

#Create & Draw outer up line of D

x:=1:

ylow:=eval(y0D-b^2*sqrt(c1-(x-x0D)^n/a^2)):

yhigh:=eval(y0D+b^2*sqrt(c1-(x-x0D)^n/a^2)):

l_up_out:=line([x,ylow], [x,yhigh], color=white):

plots[display]( pl2,pl4,pl3,l_up_in,l_up_out,pl1, scaling=constrained, view=[1..2.6, 6..8.1]);

# removed l_up_in, before l_up_out - no difference

# # # # # # # # # # # # # # # # # # # # # # # # - End of letter D - # # # #

# Display letter A

plots[display](trigAr,lbase,trapezL, l2);

1 2 3 4 Page 2 of 4