COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Cosmos::Physics::Structure Class Reference

#include <physicsclass.h>

Collaboration diagram for Cosmos::Physics::Structure:

Public Types

enum  Type {
  U1, U1X, U1Y, U1XY,
  U1_5, U1_5X, U1_5Y, U1_5XY,
  U2, U2X, U2Y, U2XY,
  U3, U3X, U3Y, U3XY,
  U6, U6X, U6Y, U6XY,
  U12, U12X, U12Y, U12XY
}
 
enum  ExternalPanelType { None = 0, X, Y, XY }
 

Public Member Functions

 Structure (physicsstruc *physp)
 
int32_t Setup (Type type)
 
int32_t add_u (double x, double y, double z, ExternalPanelType type)
 
int32_t add_cuboid (string name, Vector size, double depth, Quaternion orientation, Vector offset)
 
int32_t add_face (string name, Vector point0, Vector point1, Vector point2, Vector point3, double depth, uint8_t external=1, float pcell=.85, Quaternion orientation=Math::Quaternions::eye(), Vector offset=Vector())
 
int32_t add_face (string name, Vector size, Quaternion orientation, Vector offset)
 
int32_t add_triangle (Vector pointa, Vector pointb, Vector pointc, double depth, bool external=true, float pcell=.85)
 
int32_t add_vertex (Vector point)
 

Public Attributes

physicsstrucnewphys
 

Private Attributes

Type type
 

Member Enumeration Documentation

Enumerator
U1 
U1X 
U1Y 
U1XY 
U1_5 
U1_5X 
U1_5Y 
U1_5XY 
U2 
U2X 
U2Y 
U2XY 
U3 
U3X 
U3Y 
U3XY 
U6 
U6X 
U6Y 
U6XY 
U12 
U12X 
U12Y 
U12XY 
52  {
53  U1,
54  U1X,
55  U1Y,
56  U1XY,
57  U1_5,
58  U1_5X,
59  U1_5Y,
60  U1_5XY,
61  U2,
62  U2X,
63  U2Y,
64  U2XY,
65  U3,
66  U3X,
67  U3Y,
68  U3XY,
69  U6,
70  U6X,
71  U6Y,
72  U6XY,
73  U12,
74  U12X,
75  U12Y,
76  U12XY
77  };
Definition: physicsclass.h:75
Definition: physicsclass.h:69
Definition: physicsclass.h:53
Definition: physicsclass.h:55
Definition: physicsclass.h:66
Definition: physicsclass.h:71
Definition: physicsclass.h:59
Definition: physicsclass.h:72
Definition: physicsclass.h:64
Definition: physicsclass.h:67
Definition: physicsclass.h:68
Definition: physicsclass.h:65
Definition: physicsclass.h:73
Definition: physicsclass.h:63
Definition: physicsclass.h:74
Definition: physicsclass.h:56
Definition: physicsclass.h:61
Definition: physicsclass.h:54
Definition: physicsclass.h:58
Definition: physicsclass.h:70
Definition: physicsclass.h:76
Definition: physicsclass.h:62
Definition: physicsclass.h:60
Definition: physicsclass.h:57
Enumerator
None 
XY 
80  {
81  None = 0,
82  X,
83  Y,
84  XY
85  };
Definition: physicsclass.h:82
Definition: physicsclass.h:81
Definition: physicsclass.h:83
Definition: physicsclass.h:84

Constructor & Destructor Documentation

Cosmos::Physics::Structure::Structure ( physicsstruc physp)
inline
87  : newphys{physp}
88  {
89 
90  }
physicsstruc * newphys
Definition: physicsclass.h:49

Member Function Documentation

int32_t Cosmos::Physics::Structure::Setup ( Type  type)
8  {
9  int32_t iretn;
10 
11  switch (type)
12  {
13  case U1:
14  iretn = add_u(1, 1, 1, None);
15  break;
16  case U1X:
17  iretn = add_u(1, 1, 1, X);
18  break;
19  case U1Y:
20  iretn = add_u(1, 1, 1, Y);
21  break;
22  case U1XY:
23  iretn = add_u(1, 1, 1, XY);
24  break;
25  case U1_5:
26  iretn = add_u(1, 1, 1.5, None);
27  break;
28  case U1_5X:
29  iretn = add_u(1, 1, 1.5, X);
30  break;
31  case U1_5Y:
32  iretn = add_u(1, 1, 1.5, Y);
33  break;
34  case U1_5XY:
35  iretn = add_u(1, 1, 1.5, XY);
36  break;
37  case U3:
38  iretn = add_u(1, 1, 3, None);
39  break;
40  case U3X:
41  iretn = add_u(1, 1, 3, X);
42  break;
43  case U3Y:
44  iretn = add_u(1, 1, 3, Y);
45  break;
46  case U3XY:
47  iretn = add_u(1, 1, 3, XY);
48  break;
49  case U6:
50  iretn = add_u(1, 2, 3, None);
51  break;
52  case U6X:
53  iretn = add_u(1, 2, 3, X);
54  break;
55  case U6Y:
56  iretn = add_u(1, 2, 3, Y);
57  break;
58  case U6XY:
59  iretn = add_u(1, 2, 3, XY);
60  break;
61  case U12:
62  iretn = add_u(2, 2, 3, None);
63  break;
64  case U12X:
65  iretn = add_u(2, 2, 3, X);
66  break;
67  case U12Y:
68  iretn = add_u(2, 2, 3, Y);
69  break;
70  case U12XY:
71  iretn = add_u(2, 2, 3, XY);
72  break;
73  default:
75  }
76 
77  if (iretn < 0)
78  {
79  return iretn;
80  }
81 
82  // Calculate physical quantities
83  iretn = PhysSetup(newphys);
84  if (iretn < 0)
85  {
86  return iretn;
87  }
88 
89  return 0;
90  }
Definition: physicsclass.h:75
Definition: physicsclass.h:69
physicsstruc * newphys
Definition: physicsclass.h:49
Definition: physicsclass.h:53
Type type
Definition: physicsclass.h:101
int32_t add_u(double x, double y, double z, ExternalPanelType type)
Definition: physicsclass.cpp:92
Definition: physicsclass.h:55
Definition: physicsclass.h:66
Definition: physicsclass.h:71
Definition: physicsclass.h:59
Definition: physicsclass.h:82
Definition: physicsclass.h:72
int iretn
Definition: rw_test.cpp:37
Definition: physicsclass.h:67
Definition: physicsclass.h:68
Definition: physicsclass.h:65
#define GENERAL_ERROR_OUTOFRANGE
Definition: cosmos-errno.h:296
Definition: physicsclass.h:73
Definition: physicsclass.h:74
Definition: physicsclass.h:81
Definition: physicsclass.h:56
Definition: physicsclass.h:83
Definition: physicsclass.h:54
Definition: physicsclass.h:58
Definition: physicsclass.h:70
int32_t PhysSetup(physicsstruc *phys)
Definition: physicsclass.cpp:1369
Definition: physicsclass.h:76
Definition: physicsclass.h:60
Definition: physicsclass.h:57
Definition: physicsclass.h:84
int32_t Cosmos::Physics::Structure::add_u ( double  x,
double  y,
double  z,
ExternalPanelType  type 
)
93  {
94  switch (type)
95  {
96  case None:
97  add_face("external+x", Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(x/2., -y/2., z/2.), .004);
98  add_face("external-x", Vector(-x/2., -y/2., -z/2.), Vector(-x/2., y/2., -z/2.), Vector(-x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004);
99  add_face("external+y", Vector(-x/2., y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., y/2., z/2.), .004);
100  add_face("external-y", Vector(-x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004);
101  add_face("external+z", Vector(-x/2., -y/2., z/2.), Vector(x/2., -y/2., z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004);
102  add_face("external-z", Vector(-x/2., -y/2., -z/2.), Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(-x/2., -y/2., -z/2.), .004);
103  break;
104  case X:
105  add_face("external+x", Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(x/2., -y/2., z/2.), .004, 2, 0.);
106  add_face("external-x", Vector(-x/2., -y/2., -z/2.), Vector(-x/2., y/2., -z/2.), Vector(-x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004, 2, 0.);
107  add_face("panel+x", Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(z + x/2., y/2., -z/2.), Vector(z + x/2., -y/2., -z/2.), .004, false);
108  add_face("panel-x", Vector(-x/2., -y/2., -z/2.), Vector(-x/2., y/2., -z/2.), Vector(-z - x/2., y/2., -z/2.), Vector(-z - x/2., -y/2., -z/2.), .004, false);
109 
110  add_face("external+y", Vector(-x/2., y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., y/2., z/2.), .004);
111  add_face("external-y", Vector(-x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004);
112 
113  add_face("external+z", Vector(-x/2., -y/2., z/2.), Vector(x/2., -y/2., z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004);
114  add_face("external-z", Vector(-x/2., -y/2., -z/2.), Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(-x/2., -y/2., -z/2.), .004);
115  break;
116  case Y:
117  add_face("external+x", Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(x/2., -y/2., z/2.), .004);
118  add_face("external-x", Vector(-x/2., -y/2., -z/2.), Vector(-x/2., y/2., -z/2.), Vector(-x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004);
119 
120  add_face("external+y", Vector(-x/2., y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., y/2., z/2.), .004, 2, 0.);
121  add_face("external-y", Vector(-x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004, 2, 0.);
122  add_face("panel+y", Vector(-x/2., y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., z + y/2., -z/2.), Vector(-x/2., z + y/2., -z/2.), .004, false);
123  add_face("panel-y", Vector(-x/2., -y/2., -z/2.), Vector(x/2., -y/2., -z/2.), Vector(x/2., -z - y/2., -z/2.), Vector(-x/2., -z - y/2., -z/2.), .004, false);
124 
125  add_face("external+z", Vector(-x/2., -y/2., z/2.), Vector(x/2., -y/2., z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004);
126  add_face("external-z", Vector(-x/2., -y/2., -z/2.), Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(-x/2., -y/2., -z/2.), .004);
127  break;
128  case XY:
129  add_face("external+x", Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(x/2., -y/2., z/2.), .004, 2, 0.);
130  add_face("external-x", Vector(-x/2., -y/2., -z/2.), Vector(-x/2., y/2., -z/2.), Vector(-x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004, 2, 0.);
131  add_face("panel+x", Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(z + x/2., y/2., -z/2.), Vector(z + x/2., -y/2., -z/2.), .004, false);
132  add_face("panel-x", Vector(-x/2., -y/2., -z/2.), Vector(-x/2., y/2., -z/2.), Vector(-z - x/2., y/2., -z/2.), Vector(-z - x/2., -y/2., -z/2.), .004, false);
133 
134  add_face("external+y", Vector(-x/2., y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., y/2., z/2.), .004, 2, 0.);
135  add_face("external-y", Vector(-x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004, 2, 0.);
136  add_face("panel+y", Vector(-x/2., y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(x/2., z + y/2., -z/2.), Vector(-x/2., z + y/2., -z/2.), .004, false);
137  add_face("panel-y", Vector(-x/2., -y/2., -z/2.), Vector(x/2., -y/2., -z/2.), Vector(x/2., -z - y/2., -z/2.), Vector(-x/2., -z - y/2., -z/2.), .004, false);
138 
139  add_face("external+z", Vector(-x/2., -y/2., z/2.), Vector(x/2., -y/2., z/2.), Vector(x/2., y/2., z/2.), Vector(-x/2., -y/2., z/2.), .004);
140  add_face("external-z", Vector(-x/2., -y/2., -z/2.), Vector(x/2., -y/2., -z/2.), Vector(x/2., y/2., -z/2.), Vector(-x/2., -y/2., -z/2.), .004);
141  break;
142  }
143 
144  return 0;
145  }
Type type
Definition: physicsclass.h:101
y
Definition: inputfile.py:6
Definition: physicsclass.h:82
int32_t add_face(string name, Vector point0, Vector point1, Vector point2, Vector point3, double depth, uint8_t external=1, float pcell=.85, Quaternion orientation=Math::Quaternions::eye(), Vector offset=Vector())
Definition: physicsclass.cpp:159
Definition: physicsclass.h:81
Definition: physicsclass.h:83
x
Definition: inputfile.py:6
Vector Class.
Definition: vector.h:672
Definition: physicsclass.h:84
int32_t Cosmos::Physics::Structure::add_cuboid ( string  name,
Vector  size,
double  depth,
Quaternion  orientation,
Vector  offset 
)
148  {
149  add_face(name+"+x", Vector(size.x/2., -size.y/2., -size.z/2.), Vector(size.x/2., size.y/2., -size.z/2.), Vector(size.x/2., size.y/2., size.z/2.), Vector(size.x/2., -size.y/2., size.z/2.), depth, 1, 0., orientation, offset);
150  add_face(name+"-x", Vector(-size.x/2., -size.y/2., -size.z/2.), Vector(-size.x/2., size.y/2., -size.z/2.), Vector(-size.x/2., size.y/2., size.z/2.), Vector(-size.x/2., -size.y/2., size.z/2.), depth, 1, 0., orientation, offset);
151  add_face(name+"+y", Vector(-size.x/2., size.y/2., -size.z/2.), Vector(size.x/2., size.y/2., -size.z/2.), Vector(size.x/2., size.y/2., size.z/2.), Vector(-size.x/2., size.y/2., size.z/2.), depth, 1, 0., orientation, offset);
152  add_face(name+"-y", Vector(-size.x/2., -size.y/2., -size.z/2.), Vector(size.x/2., size.y/2., -size.z/2.), Vector(size.x/2., size.y/2., size.z/2.), Vector(-size.x/2., -size.y/2., size.z/2.), depth, 1, 0., orientation, offset);
153  add_face(name+"+z", Vector(-size.x/2., -size.y/2., size.z/2.), Vector(size.x/2., -size.y/2., size.z/2.), Vector(size.x/2., size.y/2., size.z/2.), Vector(-size.x/2., -size.y/2., size.z/2.), depth, 1, 0., orientation, offset);
154  add_face(name+"-z", Vector(-size.x/2., -size.y/2., -size.z/2.), Vector(size.x/2., -size.y/2., -size.z/2.), Vector(size.x/2., size.y/2., -size.z/2.), Vector(-size.x/2., -size.y/2., -size.z/2.), depth, 1, 0., orientation, offset);
155 
156  return 0;
157  }
double y
Definition: vector.h:713
int32_t add_face(string name, Vector point0, Vector point1, Vector point2, Vector point3, double depth, uint8_t external=1, float pcell=.85, Quaternion orientation=Math::Quaternions::eye(), Vector offset=Vector())
Definition: physicsclass.cpp:159
double z
Definition: vector.h:714
string name
Definition: cubesat2obj.cpp:6
double x
Definition: vector.h:712
Vector Class.
Definition: vector.h:672
int32_t Cosmos::Physics::Structure::add_face ( string  name,
Vector  point0,
Vector  point1,
Vector  point2,
Vector  point3,
double  depth,
uint8_t  external = 1,
float  pcell = .85,
Quaternion  orientation = Math::Quaternions::eye(),
Vector  offset = Vector() 
)
160  {
161  point0 = orientation.irotate(point0);
162  point0 += offset;
163  point1 = orientation.irotate(point1);
164  point1 += offset;
165  point2 = orientation.irotate(point2);
166  point2 += offset;
167  point3 = orientation.irotate(point3);
168  point3 += offset;
169  Vector point4 = (point0 + point1 + point2 + point3) / 4.;
170 
171  add_triangle(point0, point1, point4, depth, external, pcell);
172  add_triangle(point1, point2, point4, depth, external, pcell);
173  add_triangle(point2, point3, point4, depth, external, pcell);
174  add_triangle(point3, point0, point4, depth, external, pcell);
175 
176  return 0;
177  }
int32_t add_triangle(Vector pointa, Vector pointb, Vector pointc, double depth, bool external=true, float pcell=.85)
Definition: physicsclass.cpp:207
Vector Class.
Definition: vector.h:672
Vector irotate(const Vector &v)
Indirectly rotate a ::Vector using a ::Quaternion.
Definition: vector.cpp:2473
int32_t Cosmos::Physics::Structure::add_face ( string  name,
Vector  size,
Quaternion  orientation,
Vector  offset 
)
180  {
181  Vector points[5];
182 
183  points[0].x = -size.x / 2.;
184  points[2].x = -size.x / 2.;
185  points[1].x = size.x / 2.;
186  points[3].x = size.x / 2.;
187 
188  points[0].y = -size.y / 2.;
189  points[1].y = -size.y / 2.;
190  points[2].y = size.y / 2.;
191  points[3].y = size.y / 2.;
192 
193  for (uint16_t i=0; i<5; ++i)
194  {
195  points[i] = orientation.irotate(points[i]);
196  points[i] += offset;
197  }
198 
199  add_triangle(points[0], points[1], points[4], size.z);
200  add_triangle(points[1], points[1], points[4], size.z);
201  add_triangle(points[2], points[3], points[4], size.z);
202  add_triangle(points[3], points[0], points[4], size.z);
203 
204  return 4;
205  }
int i
Definition: rw_test.cpp:37
double y
Definition: vector.h:713
double z
Definition: vector.h:714
double x
Definition: vector.h:712
int32_t add_triangle(Vector pointa, Vector pointb, Vector pointc, double depth, bool external=true, float pcell=.85)
Definition: physicsclass.cpp:207
Vector Class.
Definition: vector.h:672
Vector irotate(const Vector &v)
Indirectly rotate a ::Vector using a ::Quaternion.
Definition: vector.cpp:2473
int32_t Cosmos::Physics::Structure::add_triangle ( Vector  pointa,
Vector  pointb,
Vector  pointc,
double  depth,
bool  external = true,
float  pcell = .85 
)
208  {
209  trianglestruc triangle;
210 
211  triangle.tidx[0] = add_vertex(pointa);
212  triangle.tidx[1] = add_vertex(pointb);
213  triangle.tidx[2] = add_vertex(pointc);
214 
215  triangle.external = external;
216  triangle.depth = depth;
217  triangle.pcell = pcell;
218  triangle.normal = (newphys->vertices[triangle.tidx[1]] - newphys->vertices[triangle.tidx[0]]).cross(newphys->vertices[triangle.tidx[2]] - newphys->vertices[triangle.tidx[0]]);
219  triangle.com = (newphys->vertices[triangle.tidx[0]] + newphys->vertices[triangle.tidx[1]] + newphys->vertices[triangle.tidx[2]]) / 3.;
220  triangle.area = (newphys->vertices[triangle.tidx[1]] - newphys->vertices[triangle.tidx[0]]).area(newphys->vertices[triangle.tidx[2]] - newphys->vertices[triangle.tidx[0]]);
221  triangle.perimeter = (newphys->vertices[triangle.tidx[1]] - newphys->vertices[triangle.tidx[0]]).norm() + (newphys->vertices[triangle.tidx[2]] - newphys->vertices[triangle.tidx[1]]).norm() + (newphys->vertices[triangle.tidx[0]] - newphys->vertices[triangle.tidx[2]]).norm();
222  newphys->triangles.push_back(triangle);
223 
224  return 1;
225  }
physicsstruc * newphys
Definition: physicsclass.h:49
float perimeter
perimeter
Definition: jsondef.h:3311
uint16_t tidx[3]
Definition: jsondef.h:3289
vector< Vector > vertices
Definition: jsondef.h:3451
int32_t add_vertex(Vector point)
Definition: physicsclass.cpp:227
float area
Area.
Definition: jsondef.h:3307
float pcell
Solar cell coverage.
Definition: jsondef.h:3315
Definition: jsondef.h:3275
uint8_t external
External facing sides.
Definition: jsondef.h:3278
float depth
Depth.
Definition: jsondef.h:3309
Vector com
center of mass
Definition: jsondef.h:3280
Vector normal
outward facing normal
Definition: jsondef.h:3282
vector< trianglestruc > triangles
Definition: jsondef.h:3452
int32_t Cosmos::Physics::Structure::add_vertex ( Vector  point)
228  {
229  bool found = false;
230 
231  int32_t index = -1;
232  for (uint16_t i=0; i<newphys->vertices.size(); ++ i)
233  {
234  if ((point - newphys->vertices[i]).norm() < .001)
235  {
236  found = true;
237  index = i;
238  break;
239  }
240  }
241 
242  if (found)
243  {
244  return index;
245  }
246  else {
247  newphys->vertices.push_back(point);
248  return newphys->vertices.size() - 1;
249  }
250  }
physicsstruc * newphys
Definition: physicsclass.h:49
vector< Vector > vertices
Definition: jsondef.h:3451
int i
Definition: rw_test.cpp:37

Member Data Documentation

physicsstruc* Cosmos::Physics::Structure::newphys
Type Cosmos::Physics::Structure::type
private

The documentation for this class was generated from the following files: