Produces a simple cut flower, with a stem and leaves. The idea comes from G. K. Klimek and M. Klimek's book, Discovering Curves and Surfaces with Maple , Springer-Verlag (1997).
Probably the most difficult part is organising the functions that describe a petal and the stem. The leaves are simple variations of the petals. The slight curve of the stem was particularily difficult to get just right.
The packages plots and plottools contain the essential features of the drawing. The setoptions commands, from plots, effectively, set the scene for the drawing. The multiple use of fractions of Pi are redefined, perhaps from my older programming principles; to gain a time advantage from Maple, it would be necessary to evaluate the Pi terms as floating point numbers using, say, evalf(Pi/3). The style removes any gridlines that might interfer. The projection and light specifics are a matter of personal taste; one might use the models lightmodel=light1 to light4 supplied with Maple.
> with(plots): with(plottools):
Warning, the name changecoords has been redefined
> Pi2:=Pi/2: Pi3:=Pi/3: Pi6:=Pi/6: Pi9:=Pi/9:
> rnge:= x=-Pi..Pi,y=-Pi2..Pi2:
The algorithm consists of products of sines and cosines to give the right effect. Rotation and translation is the secret. The generation of a 3D image allows that all sides can be viewed. Rotations and translations place the petals and leaves and stem in the right place.
> osy := 1+sin(y):
translate(%,0,.3,-2); leaves:=%: # into the right place
The petal looks a little 'out of sorts' but, of course, the default angles and light don't give a true view. The effects and defaults as exhibited here suggest 'green' petals, whereas the completed flower has red petals.
> Xp:=Xl: Yp:=Yl/2: Zp:=Zl+2:
> plot3d([Xp,Yp,Zp],rnge); # one petal
The arguments for the rotation are combined into one variable argt and, indirectly, inserted into a sequence of a sequence. Multiple petals are designated with k representing the anglar rotation about the vertical (or stem) and l representing an increase in the vertical. This 'fills in' the petals to make a full bloom.
Of particular note is the procedure p( ) with arguments k and l. The symbolism allows the unassigned variables k and l to be the uultimate arguments of the procedure, carrying through from the first line, following. This sort of construct is easy to see and follow and exhibits one of the best features of symbolic manipulation.
> p :=(k,l)->plot3d(rotation,rnge,
> petals:= display([seq(seq(p(k,l),k=0..5),l=0..3)]):
The stem, and fitting the stem to the leaves and flower, is tricky. A stem that is a straight tubeplot( ) just doesn't look right. The slight curve is hard to match to the leaves.
With the petals, the leaves and the stem make up the flower. The routine, below, makes the cutflower ion, used as a linked button, as a .gif file, in html.
The flower icon seems OK but, in fact, it is not placed together correctly. Clock on the figure, drag it around so that the full 3D picture is clear. The flower has its parts, but they are not joined properly, they are rather disassembled.
A trial and error use of translate( ) allows one to relocate the pieces and make a proper 3D, joined cutflower. Including the labels and the frame helps to keep the spatial organisation, while remembering which axis is the x-axis and which is the y-axis.
Again, click on the figure. Grab it and rotate it about. You can see how much the petals and the leaves need to be rotated and moved to complete the flower. The rotate( ) command positions the petals and the leaves with the appropriate angle along the stem; the translate( ) command slides the petals and leaves into the right position on the stem.
Note that this is a very crude way! It is better to use the version of rotate( ) that designates the line of rotation by a list of lists (a listlist) of two separate 3D points, a line that lyes along the stem. These points would, notionally, be the points at which the petals and leaves join the stem. Then, separate rotations of the petal and leaf images should not affect the joining positions. The fitting should be smooth and logical, like a starship joining a space station!
> rotate(petals,Pi/12,0,0): translate(%,-2.6,-.5,6):
> rotate(leaves,0,Pi/10,0): translate(%,-4.3,-1.8,6.5):