From: <and...@us...> - 2008-08-31 21:02:58
|
Revision: 8734 http://plplot.svn.sourceforge.net/plplot/?rev=8734&view=rev Author: andrewross Date: 2008-08-31 21:02:59 +0000 (Sun, 31 Aug 2008) Log Message: ----------- ANR for Hezekiah Carty. Add ocaml versions of example 23 and 28. Note that example 23 does not currently work for me with ocaml 3.10.0 so I have disabled building and testing it. Modified Paths: -------------- trunk/bindings/ocaml/plplot_h trunk/bindings/ocaml/plplot_h.inc trunk/examples/ocaml/CMakeLists.txt trunk/examples/ocaml/Makefile.examples.in trunk/plplot_test/test_ocaml.sh.in Added Paths: ----------- trunk/examples/ocaml/x23.ml trunk/examples/ocaml/x28.ml Modified: trunk/bindings/ocaml/plplot_h =================================================================== --- trunk/bindings/ocaml/plplot_h 2008-08-31 17:13:04 UTC (rev 8733) +++ trunk/bindings/ocaml/plplot_h 2008-08-31 21:02:59 UTC (rev 8734) @@ -171,6 +171,9 @@ c_plgfnam(char *fnam); void +c_plgfont(PLINT *p_family, PLINT *p_style, PLINT *p_weight); + + void c_plglevel(PLINT *p_level); void @@ -405,6 +408,9 @@ void c_plsfnam(const char *fnam); + void +c_plsfont(PLINT family, PLINT style, PLINT weight); + /* void c_plshade(PLFLT **a, PLINT nx, PLINT ny, PLINT (*defined) (PLFLT, PLFLT), Modified: trunk/bindings/ocaml/plplot_h.inc =================================================================== --- trunk/bindings/ocaml/plplot_h.inc 2008-08-31 17:13:04 UTC (rev 8733) +++ trunk/bindings/ocaml/plplot_h.inc 2008-08-31 21:02:59 UTC (rev 8734) @@ -38,6 +38,7 @@ [mlname(plgfci)] void c_plgfci ( [out] unsigned int * pfci ); [mlname(plgfam)] void c_plgfam ( [out] int * p_fam, [out] int * p_num, [out] int * p_bmax ); [mlname(plgfnam)] void c_plgfnam ( [string, out, length_is(1024)] char * fnam ); +[mlname(plgfont)] void c_plgfont ( [out] int * p_family, [out] int * p_style, [out] int * p_weight ); [mlname(plglevel)] void c_plglevel ( [out] int * p_level ); [mlname(plgpage)] void c_plgpage ( [out] double * p_xp, [out] double * p_yp, [out] int * p_xleng, [out] int * p_yleng, [out] int * p_xoff, [out] int * p_yoff ); [mlname(plgra)] void c_plgra ( void ); @@ -102,6 +103,7 @@ [mlname(plsfam)] void c_plsfam ( int fam, int num, int bmax ); [mlname(plsfci)] void c_plsfci ( unsigned int fci ); [mlname(plsfnam)] void c_plsfnam ( [string] const char * fnam ); +[mlname(plsfont)] void c_plsfont ( int family, int style, int weight ); [mlname(plsmaj)] void c_plsmaj ( double def, double scale ); [mlname(plsmin)] void c_plsmin ( double def, double scale ); [mlname(plsori)] void c_plsori ( int ori ); Modified: trunk/examples/ocaml/CMakeLists.txt =================================================================== --- trunk/examples/ocaml/CMakeLists.txt 2008-08-31 17:13:04 UTC (rev 8733) +++ trunk/examples/ocaml/CMakeLists.txt 2008-08-31 21:02:59 UTC (rev 8734) @@ -45,6 +45,7 @@ "25" "26" "27" + "28" "29" "30" ) Modified: trunk/examples/ocaml/Makefile.examples.in =================================================================== --- trunk/examples/ocaml/Makefile.examples.in 2008-08-31 17:13:04 UTC (rev 8733) +++ trunk/examples/ocaml/Makefile.examples.in 2008-08-31 21:02:59 UTC (rev 8734) @@ -48,10 +48,12 @@ x20$(EXEEXT) \ x21$(EXEEXT) \ x22$(EXEEXT) \ + x23$(EXEEXT) \ x24$(EXEEXT) \ x25$(EXEEXT) \ x26$(EXEEXT) \ x27$(EXEEXT) \ + x28$(EXEEXT) \ x29$(EXEEXT) \ x30$(EXEEXT) \ Added: trunk/examples/ocaml/x23.ml =================================================================== --- trunk/examples/ocaml/x23.ml (rev 0) +++ trunk/examples/ocaml/x23.ml 2008-08-31 21:02:59 UTC (rev 8734) @@ -0,0 +1,369 @@ +(* + + Displays Greek letters and mathematically interesting Unicode ranges + Copyright (C) 2005,2008 Alan Irwin + Copyright (C) 2005,2008 Andrew Ross + Copyright (C) 2008 Hezekiah M. Carty + + + This file is part of PLplot. + + PLplot is free software; you can redistribute it and/or modify + it under the terms of the GNU General Library Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PLplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with PLplot; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*) + +open Plplot +open Printf + +(* + * Displays Greek letters and mathematically interesting Unicode ranges + *) + +let greek = [| + "#gA";"#gB";"#gG";"#gD";"#gE";"#gZ";"#gY";"#gH";"#gI";"#gK";"#gL";"#gM"; + "#gN";"#gC";"#gO";"#gP";"#gR";"#gS";"#gT";"#gU";"#gF";"#gX";"#gQ";"#gW"; + "#ga";"#gb";"#gg";"#gd";"#ge";"#gz";"#gy";"#gh";"#gi";"#gk";"#gl";"#gm"; + "#gn";"#gc";"#go";"#gp";"#gr";"#gs";"#gt";"#gu";"#gf";"#gx";"#gq";"#gw"; +|] + +let type1 = [| + 0x0020;0x0021;0x0023;0x0025;0x0026; + 0x0028;0x0029;0x002b;0x002c;0x002e; + 0x002f;0x0030;0x0031;0x0032;0x0033; + 0x0034;0x0035;0x0036;0x0037;0x0038; + 0x0039;0x003a;0x003b;0x003c;0x003d; + 0x003e;0x003f;0x005b;0x005d;0x005f; + 0x007b;0x007c;0x007d;0x00a9;0x00ac; + 0x00ae;0x00b0;0x00b1;0x00d7;0x00f7; + 0x0192;0x0391;0x0392;0x0393;0x0394; + 0x0395;0x0396;0x0397;0x0398;0x0399; + 0x039a;0x039b;0x039c;0x039d;0x039e; + 0x039f;0x03a0;0x03a1;0x03a3;0x03a4; + 0x03a5;0x03a6;0x03a7;0x03a8;0x03a9; + 0x03b1;0x03b2;0x03b3;0x03b4;0x03b5; + 0x03b6;0x03b7;0x03b8;0x03b9;0x03ba; + 0x03bb;0x03bc;0x03bd;0x03be;0x03bf; + 0x03c0;0x03c1;0x03c2;0x03c3;0x03c4; + 0x03c5;0x03c6;0x03c7;0x03c8;0x03c9; + 0x03d1;0x03d2;0x03d5;0x03d6;0x2022; + 0x2026;0x2032;0x2033;0x203e;0x2044; + 0x2111;0x2118;0x211c;0x2122;0x2126; + 0x2135;0x2190;0x2191;0x2192;0x2193; + 0x2194;0x21b5;0x21d0;0x21d1;0x21d2; + 0x21d3;0x21d4;0x2200;0x2202;0x2203; + 0x2205;0x2206;0x2207;0x2208;0x2209; + 0x220b;0x220f;0x2211;0x2212;0x2215; + 0x2217;0x221a;0x221d;0x221e;0x2220; + 0x2227;0x2228;0x2229;0x222a;0x222b; + 0x2234;0x223c;0x2245;0x2248;0x2260; + 0x2261;0x2264;0x2265;0x2282;0x2283; + 0x2284;0x2286;0x2287;0x2295;0x2297; + 0x22a5;0x22c5;0x2320;0x2321;0x2329; + 0x232a;0x25ca;0x2660;0x2663;0x2665; + 0x2666; +|] + +let title = [| + "#<0x10>PLplot Example 23 - Greek Letters"; + "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (a)"; + "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (b)"; + "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (c)"; + "#<0x10>PLplot Example 23 - Number Forms Unicode Block"; + "#<0x10>PLplot Example 23 - Arrows Unicode Block (a)"; + "#<0x10>PLplot Example 23 - Arrows Unicode Block (b)"; + "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (a)"; + "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (b)"; + "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (c)"; + "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (d)"; +|] + +let lo = [| + 0x0; + 0x0; + 0x40; + 0x80; + 0x2153; + 0x2190; + 0x21d0; + 0x2200; + 0x2240; + 0x2280; + 0x22c0; +|] + +let hi = [| + 0x30; + 0x40; + 0x80; + 0xA6; + 0x2184; + 0x21d0; + 0x2200; + 0x2240; + 0x2280; + 0x22c0; + 0x2300; +|] + +let nxcells = [| + 12; + 8; + 8; + 8; + 8; + 8; + 8; + 8; + 8; + 8; + 8; +|] + +let nycells = [| + 8; + 8; + 8; + 8; + 8; + 8; + 8; + 8; + 8; + 8; + 8; +|] + +(* non-zero values Must be consistent with nxcells and nycells. *) +let offset = [| + 0; + 0; + 64; + 128; + 0; + 0; + 0; + 0; + 0; + 0; + 0; +|] + +(* 30 possible FCI values. *) +let fci_combinations = 30 + +let fci = [| + 0x80000000; + 0x80000001; + 0x80000002; + 0x80000003; + 0x80000004; + 0x80000010; + 0x80000011; + 0x80000012; + 0x80000013; + 0x80000014; + 0x80000020; + 0x80000021; + 0x80000022; + 0x80000023; + 0x80000024; + 0x80000100; + 0x80000101; + 0x80000102; + 0x80000103; + 0x80000104; + 0x80000110; + 0x80000111; + 0x80000112; + 0x80000113; + 0x80000114; + 0x80000120; + 0x80000121; + 0x80000122; + 0x80000123; + 0x80000124; +|] + +let family = [| + "sans-serif"; + "serif"; + "monospace"; + "script"; + "symbol"; +|] + +let style = [| + "upright"; + "italic"; + "oblique"; +|] + +let weight = [| + "medium"; + "bold"; +|] + +let () = + ignore (plparseopts Sys.argv [|PL_PARSE_FULL|]); + + plinit (); + + for page = 0 to 10 do + pladv 0; + + (* Set up viewport and window *) + plvpor 0.02 0.98 0.02 0.90; + plwind 0.0 1.0 0.0 1.0; + let xmin, xmax, ymin, ymax = plgspa () in + plschr 0.0 0.8; + let ycharacter_scale = 1.0 /. (ymax -. ymin) in + + (* Factor should be 0.5, but heuristically it turns out to be larger. *) + let chardef, charht = plgchr () in + let yoffset = 1.0 *. charht *. ycharacter_scale in + + (* Draw the grid using plbox *) + plcol0 2; + let deltax = 1.0 /. float_of_int nxcells.(page) in + let deltay = 1.0 /. float_of_int nycells.(page) in + plbox "bcg" deltax 0 "bcg" deltay 0; + plcol0 15; + let length = hi.(page) - lo.(page) in + let slice = ref 0 in + for j = nycells.(page) - 1 downto -1 do + let y = (0.5 +. float_of_int j) *. deltay in + for i = 0 to nxcells.(page) - 1 do + let x = (0.5 +. float_of_int i) *. deltax in + if !slice < length then ( + let cmdString = + match page with + 0 -> sprintf "#%s" greek.(!slice) + | 1 + | 2 + | 3 -> sprintf "##[0x%.4x]" type1.(offset.(page) + !slice) + | _ -> sprintf "##[0x%.4x]" (lo.(page) + !slice); + in + let cmdString' = + String.sub cmdString 1 (String.length cmdString - 1) + in + plptex x (y +. yoffset) 1.0 0.0 0.5 cmdString'; + plptex x (y -. yoffset) 1.0 0.0 0.5 cmdString; + ); + incr slice; + done + done; + + plschr 0.0 1.0; + + (* Page title *) + plmtex "t" 1.5 0.5 0.5 title.(page); + done; + + (* Demonstrate methods of getting the current fonts *) + let fci_old = plgfci () in + let ifamily, istyle, iweight = plgfont () in + printf "For example 23 prior to page 12 the FCI is 0x%x\n" fci_old; + printf "For example 23 prior to page 12 the font family, style and weight are %s %s %s\n" + family.(ifamily) style.(istyle) weight.(iweight); + + for page = 11 to 15 do + let dy = 0.030 in + (* + int family_index, style_index, weight_index; + /* Must be big enough to contain the prefix strings, the font-changing + * commands, and the "The quick brown..." string. */ + char string[200]; + *) + + pladv 0; + plvpor 0.02 0.98 0.02 0.90; + plwind 0.0 1.0 0.0 1.0; + plsfci 0; + let () = + match page with + 11 -> + plmtex "t" 1.5 0.5 0.5 + "#<0x10>PLplot Example 23 - Set Font with plsfci"; + | 12 -> + plmtex "t" 1.5 0.5 0.5 + "#<0x10>PLplot Example 23 - Set Font with plsfont"; + | 13 -> + plmtex "t" 1.5 0.5 0.5 + "#<0x10>PLplot Example 23 - Set Font with ##<0x8nnnnnnn> construct"; + | 14 -> + plmtex "t" 1.5 0.5 0.5 + "#<0x10>PLplot Example 23 - Set Font with ##<0xmn> constructs"; + | 15 -> + plmtex "t" 1.5 0.5 0.5 + "#<0x10>PLplot Example 23 - Set Font with ##<FCI COMMAND STRING/> constructs"; + in + plschr 0.0 0.75; + for i = 0 to fci_combinations - 1 do + let family_index = i mod 5 in + let style_index = (i / 5) mod 3 in + let weight_index = ((i / 5) / 3) mod 2 in + let text_string = + match page with + 11 -> + plsfci fci.(i); + sprintf + "Page 12, %s, %s, %s: The quick brown fox jumps over the lazy dog" + family.(family_index) + style.(style_index) + weight.(weight_index); + | 12 -> + plsfont family_index style_index weight_index; + sprintf + "Page 13, %s, %s, %s: The quick brown fox jumps over the lazy dog" + family.(family_index) + style.(style_index) + weight.(weight_index); + | 13 -> + sprintf + "Page 14, %s, %s, %s: #<0x%x>The quick brown fox jumps over the lazy dog" + family.(family_index) + style.(style_index) + weight.(weight_index) + fci.(i); + | 14 -> + sprintf + "Page 15, %s, %s, %s: #<0x%1x0>#<0x%1x1>#<0x%1x2>The quick brown fox jumps over the lazy dog" + family.(family_index) + style.(style_index) + weight.(weight_index) + family_index + style_index + weight_index; + | 15 -> + sprintf + "Page 16, %s, %s, %s: #<%s/>#<%s/>#<%s/>The quick brown fox jumps over the lazy dog" + family.(family_index) + style.(style_index) + weight.(weight_index) + family.(family_index) + style.(style_index) + weight.(weight_index); + in + plptex 0.0 (1.0 -. (float_of_int i +. 0.5) *. dy) 1.0 0.0 0.0 text_string; + done; + plschr 0.0 1.0; + done; + + (* Restore defaults *) + plcol0 1; + + plend (); + () + Property changes on: trunk/examples/ocaml/x23.ml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/examples/ocaml/x28.ml =================================================================== --- trunk/examples/ocaml/x28.ml (rev 0) +++ trunk/examples/ocaml/x28.ml 2008-08-31 21:02:59 UTC (rev 8734) @@ -0,0 +1,363 @@ +(* $Id$ + + plmtex3, plptex3 demo. + + Copyright (C) 2007 Alan W. Irwin + Copyright (C) 2008 Hezekiah M. Carty + + This file is part of PLplot. + + PLplot is free software; you can redistribute it and/or modify + it under the terms of the GNU General Library Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PLplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with PLplot; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*) + +open Plplot + +let pi = atan 1.0 *. 4.0 + +(* Choose these values to correspond to tick marks. *) +let xpts = 2 +let ypts = 2 +let nrevolution = 16 +let nrotation = 8 +let nshear = 8 + +(*--------------------------------------------------------------------------*\ + * Demonstrates plotting text in 3D. +\*--------------------------------------------------------------------------*) +let () = + let xmin = 0.0 in + let xmax = 1.0 in + let xmid = 0.5 *. (xmax +. xmin) in + let xrange = xmax -. xmin in + let ymin = 0.0 in + let ymax = 1.0 in + let ymid = 0.5 *. (ymax +. ymin) in + let yrange = ymax -. ymin in + let zmin = 0.0 in + let zmax = 1.0 in + let zmid = 0.5 *. (zmax +. zmin) in + let zrange = zmax -. zmin in + (* p1string must be exactly one character + the null termination + character. *) + let p1string = "O" in + let pstring = + "The future of our civilization depends on software freedom." + in + (* Allocate and define the minimal x, y, and z to insure 3D box *) + let x = + Array.init xpts ( + fun i -> + xmin +. float_of_int i *. (xmax -. xmin) /. float_of_int (xpts - 1) + ) + in + let y = + Array.init ypts ( + fun j -> + ymin +. float_of_int j *. (ymax -. ymin) /. float_of_int (ypts - 1) + ) + in + let z = Array.make_matrix xpts ypts 0.0 in + + (* Parse and process command line arguments *) + ignore (plparseopts Sys.argv [|PL_PARSE_FULL|]); + + plinit (); + + (* Page 1: Demonstrate inclination and shear capability pattern. *) + pladv 0; + plvpor (-0.15) 1.15 (-0.05) 1.05; + plwind (-1.2) 1.2 (-0.8) 1.5; + plw3d 1.0 1.0 1.0 xmin xmax ymin ymax zmin zmax 20.0 45.0; + + plcol0 2; + plbox3 "b" "" (xmax -. xmin) 0 + "b" "" (ymax -. ymin) 0 + "bcd" "" (zmax -. zmin) 0; + + plschr 0.0 1.0; + for i = 0 to nrevolution - 1 do + let omega = 2.0 *. pi *. float_of_int i /. float_of_int nrevolution in + let sin_omega = sin omega in + let cos_omega = cos omega in + let x_inclination = 0.5 *. xrange *. cos_omega in + let y_inclination = 0.5 *. yrange *. sin_omega in + let z_inclination = 0.0 in + let x_shear = -0.5 *. xrange *. sin_omega in + let y_shear = 0.5 *. yrange *. cos_omega in + let z_shear = 0.0 in + plptex3 + xmid ymid zmin + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.0 " revolution"; + done; + + plschr 0.0 1.0; + for i = 0 to nrevolution - 1 do + let omega = 2.0 *. pi *. float_of_int i /. float_of_int nrevolution in + let sin_omega = sin omega in + let cos_omega = cos omega in + let x_inclination = 0.0 in + let y_inclination = -0.5 *. yrange *. cos_omega in + let z_inclination = 0.5 *. zrange *. sin_omega in + let x_shear = 0.0 in + let y_shear = 0.5 *. yrange *. sin_omega in + let z_shear = 0.5 *. zrange *. cos_omega in + plptex3 + xmax ymid zmid + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.0 " revolution"; + done; + + plschr 0.0 1.0; + for i = 0 to nrevolution - 1 do + let omega = 2.0 *. pi *. float_of_int i /. float_of_int nrevolution in + let sin_omega = sin omega in + let cos_omega = cos omega in + let x_inclination = 0.5 *. xrange *. cos_omega in + let y_inclination = 0.0 in + let z_inclination = 0.5 *. zrange *. sin_omega in + let x_shear = -0.5 *. xrange *. sin_omega in + let y_shear = 0.0 in + let z_shear = 0.5 *. zrange *. cos_omega in + plptex3 + xmid ymax zmid + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.0 " revolution"; + done; + (* Draw minimal 3D grid to finish defining the 3D box. *) + plmesh x y z 3; + + (* Page 2: Demonstrate rotation of string around its axis. *) + pladv 0; + plvpor (-0.15) 1.15 (-0.05) 1.05; + plwind (-1.2) 1.2 (-0.8) 1.5; + plw3d 1.0 1.0 1.0 xmin xmax ymin ymax zmin zmax 20.0 45.0; + + plcol0 2; + plbox3 "b" "" (xmax -. xmin) 0 + "b" "" (ymax -. ymin) 0 + "bcd" "" (zmax -. zmin) 0; + + plschr 0.0 1.0; + let x_inclination = 1.0 in + let y_inclination = 0.0 in + let z_inclination = 0.0 in + let x_shear = 0.0 in + for i = 0 to nrotation - 1 do + let omega = 2.0 *. pi *. float_of_int i /. float_of_int nrotation in + let sin_omega = sin omega in + let cos_omega = cos omega in + let y_shear = 0.5 *. yrange *. sin_omega in + let z_shear = 0.5 *. zrange *. cos_omega in + plptex3 + xmid ymax (zmax -. (zmax -. 0.2) *. float_of_int i /. float_of_int (nrotation - 1)) + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.5 "rotation for y = y#dmax#u"; + done; + + plschr 0.0 1.0; + let x_inclination = 0.0 in + let y_inclination = -1.0 in + let z_inclination = 0.0 in + let y_shear = 0.0 in + for i = 0 to nrotation - 1 do + let omega = 2.0 *. pi *. float_of_int i /. float_of_int nrotation in + let sin_omega = sin omega in + let cos_omega = cos omega in + let x_shear = 0.5 *. xrange *. sin_omega in + let z_shear = 0.5 *. zrange *. cos_omega in + plptex3 + xmax ymid (zmax -. (zmax -. 0.2) *. float_of_int i /. float_of_int (nrotation - 1)) + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.5 "rotation for x = x#dmax#u"; + done; + + plschr 0.0 1.0; + let x_inclination = 1.0 in + let y_inclination = 0.0 in + let z_inclination = 0.0 in + let x_shear = 0.0 in + for i = 0 to nrotation - 1 do + let omega = 2.0 *. pi *. float_of_int i /. float_of_int nrotation in + let sin_omega = sin omega in + let cos_omega = cos omega in + let y_shear = 0.5 *. yrange *. cos_omega in + let z_shear = 0.5 *. zrange *. sin_omega in + plptex3 + xmid (ymax -. (ymax -. 0.2) *. float_of_int i /. float_of_int (nrotation - 1)) zmin + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.5 "rotation for z = z#dmin#u"; + done; + (* Draw minimal 3D grid to finish defining the 3D box. *) + plmesh x y z 3; + + (* Page 3: Demonstrate shear of string along its axis. *) + (* Work around xcairo and pngcairo (but not pscairo) problems for + shear vector too close to axis of string. (N.B. no workaround + would be domega = 0.) *) + let domega = 0.05 in + pladv 0; + plvpor (-0.15) 1.15 (-0.05) 1.05; + plwind (-1.2) 1.2 (-0.8) 1.5; + plw3d 1.0 1.0 1.0 xmin xmax ymin ymax zmin zmax 20.0 45.0; + + plcol0 2; + plbox3 "b" "" (xmax -. xmin) 0 + "b" "" (ymax -. ymin) 0 + "bcd" "" (zmax -. zmin) 0; + + plschr 0.0 1.0; + let x_inclination = 1.0 in + let y_inclination = 0.0 in + let z_inclination = 0.0 in + let y_shear = 0.0 in + for i = 0 to nshear - 1 do + let omega = domega +. 2.0 *. pi *. float_of_int i /. float_of_int nshear in + let sin_omega = sin omega in + let cos_omega = cos omega in + let x_shear = 0.5 *. xrange *. sin_omega in + let z_shear = 0.5 *. zrange *. cos_omega in + plptex3 + xmid ymax (zmax -. (zmax -. 0.2) *. float_of_int i /. float_of_int (nshear - 1)) + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.5 "shear for y = y#dmax#u"; + done; + + plschr 0.0 1.0; + let x_inclination = 0.0 in + let y_inclination = -1.0 in + let z_inclination = 0.0 in + let x_shear = 0.0 in + for i = 0 to nshear - 1 do + let omega = domega +. 2.0 *. pi *. float_of_int i /. float_of_int nshear in + let sin_omega = sin omega in + let cos_omega = cos omega in + let y_shear = -0.5 *. yrange *. sin_omega in + let z_shear = 0.5 *. zrange *. cos_omega in + plptex3 + xmax ymid (zmax -. (zmax -. 0.2) *. float_of_int i /. float_of_int (nshear - 1)) + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.5 "shear for x = x#dmax#u"; + done; + + plschr 0.0 1.0; + let x_inclination = 1.0 in + let y_inclination = 0.0 in + let z_inclination = 0.0 in + let z_shear = 0.0 in + for i = 0 to nshear - 1 do + let omega = domega +. 2.0 *. pi *. float_of_int i /. float_of_int nshear in + let sin_omega = sin omega in + let cos_omega = cos omega in + let y_shear = 0.5 *. yrange *. cos_omega in + let x_shear = 0.5 *. xrange *. sin_omega in + plptex3 + xmid (ymax -. (ymax -. 0.2) *. float_of_int i /. float_of_int (nshear - 1)) zmin + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.5 "shear for z = z#dmin#u"; + done; + (* Draw minimal 3D grid to finish defining the 3D box. *) + plmesh x y z 3; + + (* Page 4: Demonstrate drawing a string on a 3D path. *) + pladv 0; + plvpor (-0.15) 1.15 (-0.05) 1.05; + plwind (-1.2) 1.2 (-0.8) 1.5; + plw3d 1.0 1.0 1.0 xmin xmax ymin ymax zmin zmax 40.0 (-30.0); + + plcol0 2; + plbox3 "b" "" (xmax -. xmin) 0 + "b" "" (ymax -. ymin) 0 + "bcd" "" (zmax -. zmin) 0; + + plschr 0.0 1.2; + (* domega controls the spacing between the various characters of the + string and also the maximum value of omega for the given number + of characters in pstring. *) + let domega = 2.0 *. pi /. float_of_int (String.length pstring) in + let omega = 0.0 in + (* 3D function is a helix of the given radius and pitch *) + let radius = 0.5 in + let pitch = 1.0 /. (2.0 *. pi) in + for i = 0 to String.length pstring - 1 do + let omega = 0.0 +. float_of_int i *. domega in + let sin_omega = sin omega in + let cos_omega = cos omega in + let xpos = xmid +. radius *. sin_omega in + let ypos = ymid -. radius *. cos_omega in + let zpos = zmin +. pitch *. omega in + (* In general, the inclination is proportional to the derivative of + the position wrt theta. *) + let x_inclination = radius *. cos_omega in + let y_inclination = radius *. sin_omega in + let z_inclination = pitch in + (* The shear vector should be perpendicular to the 3D line with Z + component maximized, but for low pitch a good approximation is + a constant vector that is parallel to the Z axis. *) + let x_shear = 0.0 in + let y_shear = 0.0 in + let z_shear = 1.0 in + let p1string = String.sub pstring i 1 in + plptex3 + xpos ypos zpos + x_inclination y_inclination z_inclination + x_shear y_shear z_shear + 0.5 p1string; + done; + + (* Draw minimal 3D grid to finish defining the 3D box. *) + plmesh x y z 3; + + (* Page 5: Demonstrate plmtex3 axis labelling capability *) + pladv 0; + plvpor (-0.15) 1.15 (-0.05) 1.05; + plwind (-1.2) 1.2 (-0.8) 1.5; + plw3d 1.0 1.0 1.0 xmin xmax ymin ymax zmin zmax 20.0 45.0; + + plcol0 2; + plbox3 "b" "" (xmax -. xmin) 0 + "b" "" (ymax -. ymin) 0 + "bcd" "" (zmax -. zmin) 0; + + plschr 0.0 1.0; + plmtex3 "xp" 3.0 0.5 0.5 "Arbitrarily displaced"; + plmtex3 "xp" 4.5 0.5 0.5 "primary X-axis label"; + plmtex3 "xs" (-2.5) 0.5 0.5 "Arbitrarily displaced"; + plmtex3 "xs" (-1.0) 0.5 0.5 "secondary X-axis label"; + plmtex3 "yp" 3.0 0.5 0.5 "Arbitrarily displaced"; + plmtex3 "yp" 4.5 0.5 0.5 "primary Y-axis label"; + plmtex3 "ys" (-2.5) 0.5 0.5 "Arbitrarily displaced"; + plmtex3 "ys" (-1.0) 0.5 0.5 "secondary Y-axis label"; + plmtex3 "zp" 4.5 0.5 0.5 "Arbitrarily displaced"; + plmtex3 "zp" 3.0 0.5 0.5 "primary Z-axis label"; + plmtex3 "zs" (-2.5) 0.5 0.5 "Arbitrarily displaced"; + plmtex3 "zs" (-1.0) 0.5 0.5 "secondary Z-axis label"; + (* Draw minimal 3D grid to finish defining the 3D box. *) + plmesh x y z 3; + + (* Clean up. *) + plend (); + () + Property changes on: trunk/examples/ocaml/x28.ml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/plplot_test/test_ocaml.sh.in =================================================================== --- trunk/plplot_test/test_ocaml.sh.in 2008-08-31 17:13:04 UTC (rev 8733) +++ trunk/plplot_test/test_ocaml.sh.in 2008-08-31 21:02:59 UTC (rev 8734) @@ -23,7 +23,7 @@ # $options, and possibly $verbose_test defined. # Do the standard non-interactive examples. -for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 15 16 18 19 20 21 22 24 25 26 27 29 30; do +for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 15 16 18 19 20 21 22 24 25 26 27 28 29 30; do if [ "$verbose_test" ]; then echo "x${index}ocaml" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |