Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Icosa.h
1 //
2 // Icosa.h
3 //
4 // Thanks go to Robert W. Gray (http://www.rwgrayprojects.com/) and the
5 // Buckminster Fuller Institute (http://www.bfi.org/) for notes, references,
6 // permission, and ancestral source for the following implementation.
7 //
8 // Copyright (c) 2001-2004 Virtual Terrain Project
9 // Free for all uses, see license.txt for details.
10 //
11 
12 #ifndef ICOSAH
13 #define ICOSAH
14 
15 #include "MathTypes.h"
16 
17 struct icoface
18 {
19  DPoint3 base; // a designated "base corner" of each face
20  DPoint3 center; // the center of the face
21  DPoint3 vec_a, vec_b, vec_c; // normalized basis vectors
22 
25 
26  double d; // forth component of the plane equation
27 };
28 
43 {
44 public:
45  DymaxIcosa();
46 
47  void InitIcosa();
48 
49  void FindFaceUV(const DPoint2 &p, int &face, int &subface, DPoint3 &uvw);
50  void FindFace(const DPoint3 &p, int &face, int &subface);
51  void FindUV(const DPoint3 &p_in, int face, DPoint3 &uvw);
52 
53  void GeoToFacePoint(const DPoint2 &p, int &face, int &subface, DPoint3 &p_out);
54  void FaceUVToGeo(int face, DPoint3 &uvw, double &lon, double &lat);
55  bool GeoToDymax(const DPoint2 &geo, DPoint2 &dymax);
56 
57  double DihedralAngle();
58 
59  void GetDymaxEdges(DLine2Array &polys);
60 
61 protected:
62  void AddFlatTri(DLine2Array &polys, int a, int b, int c, int d=-1);
63 
64  // icosahedron data
65  DPoint3 m_verts[12];
66  icoface m_face[20];
67  DPoint2 m_flatverts[27];
68  double m_edge_length; // edge length of icosahedron (~1.05 for unit radius)
69 };
70 
71 // vertex indices for each face of the icosahedron
72 extern int icosa_face_v[20][3];
73 extern int icosa_face_pairs[10][2];
74 
75 #endif // ICOSAH
76