Joe Riel

9660 Reputation

23 Badges

20 years, 12 days

MaplePrimes Activity


These are replies submitted by Joe Riel

Could you describe where this example exists?  Is it in a help page?  If so, what is the "path" to it, as shown in the title bar of the help window.

A suggestion.  Enter the equations here as text, rather than as a image, we could then copy and paste them into Maple without having to retype them. Alternately, upload a Maple worksheet with the equations (using the green arrow).

It would be helpful if the equation was accessible.  Consider uploading a worksheet that assigns it, or entering it as text.

Executing the worksheet in Maple 15 returns the solution.

@matematik There is a help page for ?Frenet.  It is a definition page, but has links to the vectors that interest you (torsion, binormal, tangent, etc), for which there are exports in the ?VectorCalculus package.

@matematik There is a help page for ?Frenet.  It is a definition page, but has links to the vectors that interest you (torsion, binormal, tangent, etc), for which there are exports in the ?VectorCalculus package.

@PatrickT I'm wondering why the CleanPlot routine I suggested doesn't work here. It uses ?subsindets, which doesn't depend on the external structure. That is, it should have separately cleaned each of the Arrays in the structure.

@PatrickT I'm wondering why the CleanPlot routine I suggested doesn't work here. It uses ?subsindets, which doesn't depend on the external structure. That is, it should have separately cleaned each of the Arrays in the structure.

@PatrickT In that case, the simplest approach is probably to convert the Array structure to a listlist and hope that the plot structure is still valid (it should be). We do so because it is easier to remove elements from a listlist structure than from an Array.

Here I've added that functionality to the procedure; the first call to subsindets replaces an Array of float[8]'s to a listlist structure. The reason for specifying the type (datatype=float[8]) is that some plot structures use Arrays to "partition" plots and we want to leave those intact.

CleanPlot := proc(p)
local P;
    P := subsindets(p, 'Array(datatype=float[8])', convert, listlist);
    subsindets( P
                , 'list({numeric,undefined})'
                , L -> if hastype(L,'undefined') then NULL else L end if
              ) ;
end proc:

@PatrickT In that case, the simplest approach is probably to convert the Array structure to a listlist and hope that the plot structure is still valid (it should be). We do so because it is easier to remove elements from a listlist structure than from an Array.

Here I've added that functionality to the procedure; the first call to subsindets replaces an Array of float[8]'s to a listlist structure. The reason for specifying the type (datatype=float[8]) is that some plot structures use Arrays to "partition" plots and we want to leave those intact.

CleanPlot := proc(p)
local P;
    P := subsindets(p, 'Array(datatype=float[8])', convert, listlist);
    subsindets( P
                , 'list({numeric,undefined})'
                , L -> if hastype(L,'undefined') then NULL else L end if
              ) ;
end proc:

The key is knowing to use traperror; this is mentioned in the ?stoperror help page.  Careful study of that help page can pay dividends.

The key is knowing to use traperror; this is mentioned in the ?stoperror help page.  Careful study of that help page can pay dividends.

@Bruce Scranton The default location is automatically added to ?libname. Alternatively, you could create a catch-all directory, say, ~/maple/toolbox/mystuff/lib and put it there. 

Modifying the directory structure of a program's installation is usually not a great thing to do.  Also, the location you gave won't automatically be added to libname, though you could change it slightly to have it work:  Maple 15/toolbox/whatever/lib should work. 

This appears to have an effect only with the maplet plot driver.  It does nothing with the postscript or x11 plot drivers.

I have gv rather than gsview; the former doesn't have an option to print the bounding box when hovering over it, however, it did not appear to be incorrect. Note that the difference between the four lists of integers is that one is rotated right be one place.  I'm thinking that you changed to landscape view when used gsview's bounding box viewer, that is precisely what would happen.  That is, in shifting between landscape and portrait, the bounding box changes from [x1,y1,x2,y2] to [y2,x1,y1,x2].

To remove all white space, use the noborder option.  To add some back in, the bounding box needs to be adjusted.  I added a margin option to the procedure; it increases the bounding box by that amount.

To use it, do

myPlotPS(testplot
         , plotoptions="color=rgb,landscape,noborder,axiswidth=480pt,axisheight=360pt"
         , margin = 20
         , thin = 4
         , medium = 8
         , boundarythick = 1
         , fonttype = "Times"
         , fontsize = 80
        ) ;

Here is the modified procedure

myPlotPS := proc( plt
                  , { margin :: integer := 0 }
                  , { plotoutput :: string := "plotfile.eps" }
                  , { thin :: posint := 3 }
                  , { medium :: posint := 7 }
                  , { thick :: posint := 16 }
                  , { boundarythick :: integer := 20 }
                  , { fonttype :: string := "Helvetica" }
                  , { fontsize :: posint := 133 }
                  , { plotoptions :: string := "" }
                  , { tmpfile :: string := "plotfile.mpl" }
                )
local cmd, fd, str, llx, lly, urx, ury, all, bb, regex;
uses FT = FileTools, ST = StringTools;

    if IsWorksheetInterface() then
        ### Create temporary file
        fd := fopen(tmpfile, 'WRITE', 'TEXT');
        fprintf(fd, "plotsetup('ps', 'plotoutput = %a', 'plotoptions' = %a);\n"
                , plotoutput
                , plotoptions
               );
        fprintf(fd, "print(%a);\n", plt);
        fclose(fd);

        ### Pass temporary file to maple tty executable
        if kernelopts('platform') = "unix" then
            cmd := "maple";
        else
            cmd := cat(kernelopts('bindir','dirsep'),"cmaple");
        end if;
        cmd := sprintf("%s %s", cmd, tmpfile);
        ssystem(cmd);
    else
        plotsetup('ps', _options['plotoutput'], _options['plotoptions']);
        print(plt);
        plotsetup('default');
    end if;

    ### Modify the generated postscript file
    str := FT:-Text:-ReadFile(plotoutput);
    fclose(plotoutput);

    ### keyword "thin" controls axis tickmark thickness
    str := ST:-RegSubs("\n/thin ([0-9]+) def" = sprintf("\n/thin %d def", thin), str);
    ### keyword "medium" controls axis line thickness
    str := ST:-RegSubs("\n/medium ([0-9]+) def" = sprintf("\n/medium %d def", medium), str);
    ### keyword "thick" is unused in examples I tried
    str := ST:-RegSubs("\n/thick ([0-9]+) def" = sprintf("\n/thick %d def", thick), str);
    ### keyword "boundarythick" controls border thickness, if any
    str := ST:-RegSubs("\n/boundarythick ([0-9]+) def" = sprintf("\n/boundarythick %d def", boundarythick), str);
    ### keyword "fontsize" controls both title and label font sizes, see /defaultFont and /defaultTitleFont
    str := ST:-RegSubs("findfont ([0-9]+) scalefont setfont" = sprintf("findfont %d scalefont setfont", fontsize), str);
    ### keyword "fonttype" controls both title and label font types, see /defaultFont and /defaultTitleFont
    str := ST:-RegSubs("Helvetica" = sprintf("%s", fonttype), str);
    ### Remove Postscript DSC error
    str := ST:-RegSubs("\n%%Pages:  ([0-9]+)" = "", str);

    # Adjust bounding box
    if margin <> 0 then
        regex := "(\n%%BoundingBox: )([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)";
        if not ST:-RegMatch(regex,str,'all,bb,llx,lly,urx,ury') then
            error "problem matching bounding box";
        end if;
        bb := map(parse,[llx,lly,urx,ury]);
        bb := bb + [-margin,-margin,+margin,+margin];
        str := ST:-RegSubs(regex = sprintf("\\1 %d %d %d %d", op(bb)), str);
    end if;

    FT:-Text:-WriteString(plotoutput, str);
    fclose(plotoutput);

end proc:


First 67 68 69 70 71 72 73 Last Page 69 of 195