MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Question of function for hexahedron

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23580] Re: [mg23562] Question of function for hexahedron
  • From: BobHanlon at aol.com
  • Date: Sun, 21 May 2000 18:12:50 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In my initial reply I stated:
>
>In a message dated 5/20/2000 3:35:53 AM, khs at procd.sogang.ac.kr writes:
>
>>I want to find out the function that will generate hexahedron,however
>I
>>heard there are some founctions related to 'hexahedron' like 'Cubid' or
>>'Ployhedron'. But I want to generate hexahedron for given eight numbers.
>>
>>for example
>>
>>  (0.0057    0.0052    0.0052)
>>  (-0.0057    0.0063    0.0051)
>> ( 0.0057   -0.0052    0.0062)
>> ( 0.0057   -0.0063    0.0063)
>> ( 0.0057   -0.0063   -0.0051)
>> (-0.0057   -0.0052   -0.0052)
>> (-0.0057    0.0063   -0.0063)
>>  (0.0057    0.0052   -0.0062)
>>
>
> vert = {{0.0057,    0.0052,    0.0052}, {-0.0057,    0.0063,    0.0051},
>{ 
>        0.0057,   -0.0052,    0.0062}, { 0.0057,   -0.0063,    0.0063},
>{ 
>        0.0057,   -0.0063,   -0.0051}, {-0.0057,   -0.0052,   -0.0052},
>\
>{-0.0057,    0.0063,   -0.0063}, {0.0057,    0.0052,   -0.0062}};
>
>Checking the location of the vertices
>
>Show[Graphics3D[{RGBColor[1, 0, 0], Line[vert]}]];
>
>There appears to be a mistake in defining the vertices. The third point
>should have a negative x value.
>
> vert = {{0.0057,    0.0052,    0.0052}, {-0.0057,    0.0063,    
>        0.0051}, { -0.0057,   -0.0052,    0.0062}, { 0.0057,   -0.0063,
>   
>        0.0063}, { 
>        0.0057,   -0.0063,   -0.0051}, {-0.0057,   -0.0052,   -0.0052},
>\
>{-0.0057,    0.0063,   -0.0063}, {0.0057,    0.0052,   -0.0062}};
>
>Rechecking
>
>Show[Graphics3D[
>      Join[{RGBColor[1, 0, 0], Line[vert], RGBColor[0, 0, 1]}, 
>        Table[Text[ToString[k], vert[[k]]], {k, Length[vert]}]]]];
>
>Each of the six faces will be a polygon formed by four vertices
>
>faces = {{1, 2, 3, 4}, {5, 6, 7, 8}, {3, 4, 5, 6}, {1, 2, 7, 8}, {2, 3,
>6, 
>        7}, {1, 4, 5, 8}};
>
>Drawing the hexahedron
>
>Show[Graphics3D[Polygon[#] & /@ (vert[[#]] & /@ faces)]];
>

Needs["Graphics`Polyhedra`"]

Needs["DiscreteMath`Permutations`"]

This function allows the vertices of the Hexahedron to be given in any 
sequence

drawHexahedron[vertices_List, opts___] := 
  Module[{origin = Chop[(Plus @@ #) & /@ Transpose[vertices]], seq1, seq2, 
      remap},
    seq1 = (FromDigits[#, 
              2] & /@ ((1 + Sign[#])/2 & /@ ((# - origin) & /@ vertices)));
    seq2 = FromDigits[#, 2] & /@ ((1 + Sign[#])/2 & /@ Vertices[Hexahedron]);
    remap = Inner[Rule, seq2, Range[8], List];
    orderedVertices = 
      Transpose[
        Rest[Transpose[
            Sort[Transpose[Join[{seq1 /. remap}, Transpose[vertices]]]]]]];
    Show[Graphics3D[
        Polygon[#] & /@ (orderedVertices[[#]] & /@ Faces[Hexahedron])], opts]
    ]

 vert = {{0.0057,    0.0052,    0.0052}, {-0.0057,    0.0063,    
      0.0051}, { -0.0057,   -0.0052,    0.0062}, { 0.0057,   -0.0063,    
      0.0063}, { 
      0.0057,   -0.0063,   -0.0051}, {-0.0057,   -0.0052,   -0.0052}, \
{-0.0057,    0.0063,   -0.0063}, {0.0057,    0.0052,   -0.0062}};

Demonstrating that the vertices can be entered in any order

drawHexahedron[vert[[#]] & /@ RandomPermutation[8], 
    ViewPoint -> {1.300, -2.400, 2.000}];

Bob

BobHanlon at aol.com


  • Prev by Date: Re: sending notebooks as attatchments with microsoft OutlookExpress...
  • Next by Date: Re: Cantor set plot, Dirichlet function plot
  • Previous by thread: Re: Question of function for hexahedron
  • Next by thread: Matrix Multiplication...