void goNwu() { m_max.x = m_mid.x; m_min.y = m_mid.y; m_min.z = m_mid.z; setMid(); }
void goSed(const bool force2d = false) { m_min.x = m_mid.x; m_max.y = m_mid.y; if (!force2d) m_max.z = m_mid.z; setMid(); }
void goNeu() { m_min.x = m_mid.x; m_min.y = m_mid.y; m_min.z = m_mid.z; setMid(); }
void goSeu() { m_min.x = m_mid.x; m_max.y = m_mid.y; m_min.z = m_mid.z; setMid(); }
void Bounds::grow(const Point& p) { m_min.x = std::min(m_min.x, p.x); m_min.y = std::min(m_min.y, p.y); m_min.z = std::min(m_min.z, p.z); m_max.x = std::max(m_max.x, p.x); m_max.y = std::max(m_max.y, p.y); m_max.z = std::max(m_max.z, p.z); setMid(); }
Bounds::Bounds(const Point& min, const Point& max) : m_min( std::min(min.x, max.x), std::min(min.y, max.y), std::min(min.z, max.z)) , m_max( std::max(min.x, max.x), std::max(min.y, max.y), std::max(min.z, max.z)) , m_mid() { setMid(); if (min.x > max.x || min.y > max.y || min.z > max.z) { std::cout << "Correcting malformed Bounds" << std::endl; } }
// Bloat all coordinates necessary to form a cube and also to the nearest // integer. void cubeify() { const double xDist(m_max.x - m_min.x); const double yDist(m_max.y - m_min.y); const double zDist(m_max.z - m_min.z); const double radius( std::ceil(std::max(std::max(xDist, yDist), zDist) / 2.0 + 10)); m_min.x = std::floor(m_mid.x) - radius; m_min.y = std::floor(m_mid.y) - radius; m_min.z = std::floor(m_mid.z) - radius; m_max.x = std::floor(m_mid.x) + radius; m_max.y = std::floor(m_mid.y) + radius; m_max.z = std::floor(m_mid.z) + radius; setMid(); }
bool isPalindrome(ListNode* head) { ListNode *right = NULL; ListNode *left = NULL; this->head = head; this->mid = head; setMid(); reverseSecondHalf(); left = head; right = mid; while ((left != right)&&(left != NULL)&&(right != NULL)) { if (left->val != right->val) { cout<<"False"<<endl; return false; } left = left->next; right = right->next; if (left == NULL || right == NULL) { break; } } reverseSecondHalf(); return true; }
void set(const Point& min, const Point& max) { m_min = min; m_max = max; setMid(); }
void Bounds::shrink(const Bounds& other) { m_min = Point::max(m_min, other.min()); m_max = Point::min(m_max, other.max()); setMid(); }