axis-manip.h revision 44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42
/*
* Generic auxiliary routines for 3D axes
*
* Authors:
* Maximilian Albert <Anhalter42@gmx.de>
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifndef SEEN_AXIS_MANIP_H
#define SEEN_AXIS_MANIP_H
#include <cassert>
#include <string>
#include <utility>
enum VPState {
VP_FINITE = 0,
};
// in binary representation, respectively.
enum Axis {
X = 0,
Y = 1,
Z = 2,
W = 3,
};
inline char const*
switch (axis) {
case X: return "X"; break;
case Y: return "Y"; break;
case Z: return "Z"; break;
case W: return "W"; break;
case NONE: return "NONE"; break;
}
return "";
}
} // namespace Proj
const double epsilon = 1e-6;
// in binary representation, respectively.
enum Axis {
X = 1,
Y = 2,
Z = 4,
XY = 3,
XZ = 5,
YZ = 6,
XYZ = 7,
NONE = 0
};
// We use the fourth bit in binary representation
// to indicate whether a face is front or rear.
enum FrontOrRear { // find a better name
FRONT = 0,
REAR = 8
};
// converts X, Y, Z respectively to 0, 1, 2 (for use as array indices, e.g)
switch (axis) {
case Box3D::X:
return 0;
break;
case Box3D::Y:
return 1;
break;
case Box3D::Z:
return 2;
break;
return -1;
break;
default:
assert(false);
}
}
switch (axis) {
case Box3D::X:
return Proj::X;
case Box3D::Y:
return Proj::Y;
case Box3D::Z:
return Proj::Z;
default:
assert(false);
}
}
} // namespace Box3D
switch (axis) {
case Proj::X:
return Box3D::X;
case Proj::Y:
return Box3D::Y;
case Proj::Z:
return Box3D::Z;
default:
assert(false);
}
}
} // namespace Proj
/*
* Identify the axes X, Y, Z with the numbers 0, 1, 2.
* A box's face is identified by the axis perpendicular to it.
* For a rear face, add 3.
*/
// Given a bit sequence that unambiguously specifies the face of a 3D box,
// return a number between 0 and 5 corresponding to that particular face
// (which is normally used to index an array). Return -1 if the bit sequence
// does not specify a face. A face can either be given by its plane (e.g, XY)
// or by the axis that is orthogonal to it (e.g., Z).
inline int face_to_int (unsigned int face_id) {
switch (face_id) {
case 1: return 0;
case 2: return 1;
case 4: return 2;
case 3: return 2;
case 5: return 1;
case 6: return 0;
case 9: return 3;
case 10: return 4;
case 12: return 5;
case 11: return 5;
case 13: return 4;
case 14: return 3;
default: return -1;
}
}
inline int int_to_face (unsigned id) {
switch (id) {
}
}
inline bool is_face_id (unsigned int face_id) {
}
/**
inline gint opposite_face (guint face_id) {
return face_id + (((face_id % 2) == 0) ? 1 : -1);
}
**/
unsigned int num = 0;
return num;
}
}
// tests whether dir is nonzero and a power of 2
}
/**
* Given two axis directions out of {X, Y, Z} or the corresponding plane, return the remaining one
* We don't check if 'plane' really specifies a plane (i.e., if it consists of precisely two directions).
*/
}
}
}
}
}
/* returns an axis direction perpendicular to the ones occuring in the (possibly compound) expression 'dirs' */
}
} // namespace Box3D
#endif /* !SEEN_AXIS_MANIP_H */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :