csVector3 csBox3::GetCorner (int corner) const { switch (corner) { case CS_BOX_CORNER_xyz: return Min (); case CS_BOX_CORNER_xyZ: return csVector3 (MinX (), MinY (), MaxZ ()); case CS_BOX_CORNER_xYz: return csVector3 (MinX (), MaxY (), MinZ ()); case CS_BOX_CORNER_xYZ: return csVector3 (MinX (), MaxY (), MaxZ ()); case CS_BOX_CORNER_Xyz: return csVector3 (MaxX (), MinY (), MinZ ()); case CS_BOX_CORNER_XyZ: return csVector3 (MaxX (), MinY (), MaxZ ()); case CS_BOX_CORNER_XYz: return csVector3 (MaxX (), MaxY (), MinZ ()); case CS_BOX_CORNER_XYZ: return Max (); case CS_BOX_CENTER3: return GetCenter (); } return csVector3 (0, 0, 0); }
void csBox3::ManhattanDistance (const csBox3& other, csVector3& dist) const { if (other.MinX () >= MaxX ()) dist.x = other.MinX () - MaxX (); else if (MinX () >= other.MaxX ()) dist.x = MinX () - other.MaxX (); else dist.x = 0; if (other.MinY () >= MaxY ()) dist.y = other.MinY () - MaxY (); else if (MinY () >= other.MaxY ()) dist.y = MinY () - other.MaxY (); else dist.y = 0; if (other.MinZ () >= MaxZ ()) dist.z = other.MinZ () - MaxZ (); else if (MinZ () >= other.MaxZ ()) dist.z = MinZ () - other.MaxZ (); else dist.z = 0; }
int csBox3::Adjacent (const csBox3 &other, float epsilon) const { if (AdjacentX (other, epsilon)) { if (other.MaxX () > MaxX ()) return CS_BOX_SIDE_X; else return CS_BOX_SIDE_x; } if (AdjacentY (other, epsilon)) { if (other.MaxY () > MaxY ()) return CS_BOX_SIDE_Y; else return CS_BOX_SIDE_y; } if (AdjacentZ (other, epsilon)) { if (other.MaxZ () > MaxZ ()) return CS_BOX_SIDE_Z; else return CS_BOX_SIDE_z; } return -1; }
void csBox3::GetAxisPlane (int side, int& axis, float& where) const { axis = side / 2; switch (side) { case CS_BOX_SIDE_x: where = MinX (); break; case CS_BOX_SIDE_X: where = MaxX (); break; case CS_BOX_SIDE_y: where = MinY (); break; case CS_BOX_SIDE_Y: where = MaxY (); break; case CS_BOX_SIDE_z: where = MinZ (); break; case CS_BOX_SIDE_Z: where = MaxZ (); break; } }
csString csBox3::Description () const { csString s; s.Format("(%g,%g,%g)-(%g,%g,%g)", MinX (), MinY (), MinZ (), MaxX (), MaxY (), MaxZ ()); return s; }
csBox2 csBox3::GetSide (int side) const { switch (side) { case CS_BOX_SIDE_x: case CS_BOX_SIDE_X: return csBox2 (MinY (), MinZ (), MaxY (), MaxZ ()); case CS_BOX_SIDE_y: case CS_BOX_SIDE_Y: return csBox2 (MinX (), MinZ (), MaxX (), MaxZ ()); case CS_BOX_SIDE_z: case CS_BOX_SIDE_Z: return csBox2 (MinX (), MinY (), MaxX (), MaxY ()); } return csBox2 (); }
bool csBox3::AdjacentZ (const csBox3& other) const { if (ABS (other.MinZ () - MaxZ ()) < SMALL_EPSILON || ABS (other.MaxZ () - MinZ ()) < SMALL_EPSILON) { if (MaxX () < other.MinX () || MinX () > other.MaxX ()) return false; if (MaxY () < other.MinY () || MinY () > other.MaxY ()) return false; return true; } return false; }
bool csBox3::AdjacentZ (const csBox3 &other, float epsilon) const { if ( ABS (other.MinZ () - MaxZ ()) < epsilon || ABS (other.MaxZ () - MinZ ()) < epsilon) { if (MaxX () < other.MinX () || MinX () > other.MaxX ()) return false; if (MaxY () < other.MinY () || MinY () > other.MaxY ()) return false; return true; } return false; }
int csBox3::Adjacent (const csBox3& other) const { if (AdjacentX (other)) { if (other.MaxX () > MaxX ()) return BOX_SIDE_X; else return BOX_SIDE_x; } if (AdjacentY (other)) { if (other.MaxY () > MaxY ()) return BOX_SIDE_Y; else return BOX_SIDE_y; } if (AdjacentZ (other)) { if (other.MaxZ () > MaxZ ()) return BOX_SIDE_Z; else return BOX_SIDE_z; } return -1; }