Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Hexahedron.cxx

Go to the documentation of this file.
00001 // $Id: Hexahedron.cxx,v 1.4 2001/05/25 02:19:45 burnett Exp $
00002 //
00003 
00004 
00005 #include "geometry/Hexahedron.h"
00006 
00007 inline static double sqr(double x){return x*x;}
00008 
00009 Hexahedron::Hexahedron()
00010 : Volume(6)
00011 {}
00012 
00013 Point
00014 Hexahedron::vertex(int n)const
00015 { // map to the plane to use:
00016   int ix=(n&1), iy= ((n/2)&1)+2, iz=((n/4)&1)+4;
00017   Point dummy;
00018   Vector a(plane(ix).normal(dummy)),
00019          b(plane(iy).normal(dummy)),
00020          c(plane(iz).normal(dummy));
00021   double l=plane(ix).offset(), w=plane(iy).offset(), h=plane(iz).offset();
00022 
00023   double ax=a.x(), ay=a.y(), az=a.z(),
00024         bx=b.x(), by=b.y(), bz=b.z(),
00025         cx=c.x(), cy=c.y(), cz=c.z();
00026   // invert the 3x3 matrix by hand
00027   double Mxx = by*cz-bz*cy,
00028     Myx =-bx*cz+bz*cx,
00029         Mzx = bx*cy-by*cx,
00030 
00031         Mxy =-ay*cz+az*cy,
00032         Myy = ax*cz-az*cx,
00033         Mzy =-ax*cy+ay*cx,
00034 
00035         Mxz = ay*bz-az*by,
00036         Myz =-ax*bz+az*bx,
00037         Mzz = ax*by-ay*bx,
00038 
00039         D = ax*by*cz-ax*bz*cy-bx*ay*cz+bx*az*cy+cx*ay*bz-cx*az*by;
00040 
00041    Vector v( (Mxx*l + Mxy*w + Mxz*h)/D,
00042              (Myx*l + Myy*w + Myz*h)/D,
00043              (Mzx*l + Mzy*w + Mzz*h)/D);
00044 // Next line commented out & replaced because gcc tries to make a Point from a Vector.
00045 //   return center()+v;
00046      Point p = center();
00047      return p+v;
00048 }
00049 

Generated at Mon Nov 26 18:18:21 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000