Austin Schuh | 405fa6c | 2015-09-06 18:13:55 -0700 | [diff] [blame^] | 1 | (******************************************************************* |
| 2 | This file was generated automatically by the Mathematica front end. |
| 3 | It contains Initialization cells from a Notebook file, which |
| 4 | typically will have the same name as this file except ending in |
| 5 | ".nb" instead of ".m". |
| 6 | |
| 7 | This file is intended to be loaded into the Mathematica kernel using |
| 8 | the package loading commands Get or Needs. Doing so is equivalent |
| 9 | to using the Evaluate Initialization Cells menu command in the front |
| 10 | end. |
| 11 | |
| 12 | DO NOT EDIT THIS FILE. This entire file is regenerated |
| 13 | automatically each time the parent Notebook file is saved in the |
| 14 | Mathematica front end. Any changes you make to this file will be |
| 15 | overwritten. |
| 16 | ***********************************************************************) |
| 17 | |
| 18 | Off[General::spell1];Off[General::spell] |
| 19 | |
| 20 | |
| 21 | (* Russell Towle's codes to create projections (zonotopes) of |
| 22 | hypercubes. *) |
| 23 | |
| 24 | cross[ {ax_, ay_, az_}, {bx_, by_, bz_} ] := (*cross product*) |
| 25 | {ay bz - az by, az bx - ax bz, ax by - ay bx} |
| 26 | |
| 27 | mag[v_]:= Sqrt[Plus@@(v^2)] (*magnitude of a vector*) |
| 28 | |
| 29 | unit[v_]:= v/Sqrt[v.v] (*make unit vector*) |
| 30 | |
| 31 | tolerance=0.000001; |
| 32 | collinear[ v1_, v2_ ] := (*test for collinearity*) |
| 33 | Apply[And, Map[Abs[#]<tolerance&, cross[v1,v2]]] |
| 34 | |
| 35 | setStar[vlist_] := (*discard collinear vectors*) |
| 36 | Module[{selected={}}, |
| 37 | Scan[Function[v, If[v!={0,0,0} && |
| 38 | Select[selected, |
| 39 | collinear[v,#]&]=={}, |
| 40 | AppendTo[selected,v]] ], |
| 41 | vlist]; |
| 42 | |
| 43 | Print[Length[selected]," zonal directions."]; |
| 44 | gStar=selected] (*gStar is global, list of non-collinear vectors*) |
| 45 | |
| 46 | |
| 47 | |
| 48 | (* Here I set to a directory where I store |
| 49 | the packages I need *) |
| 50 | |
| 51 | SetDirectory["~/Math"] |
| 52 | |
| 53 | cddml=Install["~/Math/cddmathlink"] |
| 54 | |
| 55 | Needs["ExtendGraphics`View3D`"]; |
| 56 | |
| 57 | <<UnfoldPolytope.m |
| 58 | |
| 59 | <<Combinatorica5.m |
| 60 | |
| 61 | <<PolytopeSkeleton.m |
| 62 | |
| 63 | <<IOPolyhedra.m |
| 64 | |
| 65 | (*the vectors which determine an n-merous polar zonohedron*) |
| 66 | (*3<=n, 0<=pitch<=90 degrees*) |
| 67 | |
| 68 | vectors[n_Integer,pitch_]:= |
| 69 | Table[N[{Cos[Degree pitch] Cos[2Pi i/n], |
| 70 | Cos[Degree pitch] Sin[2Pi i/n], |
| 71 | -Sin[Degree pitch]},15], |
| 72 | {i,n}] (* modified by KF, precision 15 added *) |
| 73 | |
| 74 | (*the pitch at which a polar zonohedron is |
| 75 | an isometric shadow of an n-cube*) |
| 76 | |
| 77 | N[1/Degree * ArcTan[(1/2)^(1/2)],15]; |
| 78 | |
| 79 | |
| 80 | (*Here, we obtain the vectors for an isometric projection of |
| 81 | a d-cube into cyclic symmetry*) |
| 82 | |
| 83 | dim=8; |
| 84 | gen=Zonotope[vectors[dim, N[ 1/Degree * ArcTan[(1/2)^(1/2)],15 ] ] ]; |
| 85 | genc = Chop[gen,10^(-12)]; |
| 86 | |
| 87 | extlist=Map[Prepend[#,1]&,genc]; |
| 88 | {n,d}=Dimensions[extlist] |