/// <summary> /// Return a copy of the current bounding box after adding a margin to all limits (positiv to max limits, negativ to min limits) /// </summary> /// <remarks>Modify current object.</remarks> public void selfMargin(double marg) { BoundingBox3d b = new BoundingBox3d(); m_xmax += marg; m_xmin -= marg; m_ymax += marg; m_ymin -= marg; m_zmax += marg; m_zmin -= marg; }
/// <summary> /// Return a copy of the current bounding box after adding a margin to all limits (positiv to max limits, negativ to min limits) /// </summary> /// <remarks>Current object is not modified, a new one is created.</remarks> public BoundingBox3d margin(double marg) { BoundingBox3d b = new BoundingBox3d(); b.m_xmax = m_xmax + marg; b.m_xmin = m_xmin - marg; b.m_ymax = m_ymax + marg; b.m_ymin = m_ymin - marg; b.m_zmax = m_zmax + marg; b.m_zmin = m_zmin - marg; return(b); }
/// <summary> /// Return a copy of the current bounding box after shitfing all limits /// Shifting does not modify the current bounding box. /// </summary> /// <remarks>Current object is not modified, a new one is created.</remarks> public BoundingBox3d shift(Coord3d offset) { BoundingBox3d b = new BoundingBox3d(); b.m_xmax = m_xmax + offset.x; b.m_xmin = m_xmin + offset.x; b.m_ymax = m_ymax + offset.y; b.m_ymin = m_ymin + offset.y; b.m_zmax = m_zmax + offset.z; b.m_zmin = m_zmin + offset.z; return(b); }
/// <summary> /// Return a copy of the current bounding box after scaling all limits relative to 0,0,0 /// Scaling does not modify the current bounding box. /// </summary> /// <remarks>Current object is not modified, a new one is created.</remarks> public BoundingBox3d scale(Coord3d factors) { BoundingBox3d b = new BoundingBox3d(); b.m_xmax = m_xmax * factors.x; b.m_xmin = m_xmin * factors.x; b.m_ymax = m_ymax * factors.y; b.m_ymin = m_ymin * factors.y; b.m_zmax = m_zmax * factors.z; b.m_zmin = m_zmin * factors.z; return(b); }
/// <summary> /// Initialize a BoundingBox with another bounding box (i.e. performs a copy) /// </summary> public BoundingBox3d(BoundingBox3d anotherBox) : this(anotherBox.m_xmin, anotherBox.m_xmax, anotherBox.m_ymin, anotherBox.m_ymax, anotherBox.m_zmin, anotherBox.m_zmax) { }
/// <summary> /// Return true if <paramref name="anotherBox"/> intersects with this box. /// </summary> public bool intersect(BoundingBox3d anotherBox) { return((m_xmin <= anotherBox.m_xmin & anotherBox.m_xmin <= m_xmax) | (m_xmin <= anotherBox.m_xmax & anotherBox.m_xmax <= m_xmax) & (m_ymin <= anotherBox.m_ymin & anotherBox.m_ymin <= m_ymax) | (m_ymin <= anotherBox.m_ymax & anotherBox.m_ymax <= m_ymax) & (m_zmin <= anotherBox.m_zmin & anotherBox.m_zmin <= m_zmax) | (m_zmin <= anotherBox.m_zmax & anotherBox.m_zmax <= m_zmax)); }
/// <summary> /// Return true if <paramref name="anotherBox"/> is contained in this box. /// </summary> /// <remarks>if b1.contains(b2), then b1.intersect(b2) as well.</remarks> public bool contains(BoundingBox3d anotherBox) { return(m_xmin <= anotherBox.m_xmin & anotherBox.m_xmax <= m_xmax & m_ymin <= anotherBox.m_ymin & anotherBox.m_ymax <= m_ymax & m_zmin <= anotherBox.m_zmin & anotherBox.m_zmax <= m_zmax); }
/// <summary> /// Adds another <see cref="BoundingBox3d"/> to the bounding box, and enlarge the bounding /// box if its points lies outside of it (i.e. merge other bounding box inside current one) /// </summary> public void Add(BoundingBox3d b) { this.@add(b.m_xmin, b.m_ymin, b.m_zmin); this.@add(b.m_xmax, b.m_ymax, b.m_zmax); }