Property definitions

geometry $ Box3d :: defaultinit
# A 3d bounded object and an implementation of Boxed
#
# This class offers many constructors specialized for different usage. They are
# named according to the order of their arguments.
class Box3d[N: Numeric]
	super Boxed3d[N]
	super Box[N]

	redef var front: N
	redef var back: N

	# Create a `Box` covering all of the `boxed`
	#
	#     var box = new Box[Int].around(new Point[Int](-4,-4), new Point[Int](4,4))
	#     assert box.left == -4 and box.bottom == -4
	#     assert box.right == 4 and box.top == 4
	init around(boxed: Boxed3d[N]...)
	do
		super

		assert not boxed.is_empty

		var left: nullable N = null
		var right: nullable N = null
		var top: nullable N = null
		var bottom: nullable N = null
		var front: nullable N = null
		var back: nullable N= null

		for box in boxed do
			if left == null or box.left < left then left = box.left
			if right == null or box.right > right then right = box.right
			if top == null or box.top > top then top = box.top
			if bottom == null or box.bottom < bottom then bottom = box.bottom
			if front == null or box.front > front then front = box.front
			if back == null or box.back < back then back = box.back
		end

		assert left != null and right != null and top != null and bottom != null

		self.left = left
		self.right = right
		self.top = top
		self.bottom = bottom
	end

	# Create a `Box3d` using left, right, bottom, top, front and back
	init lrbtfb(left, right, bottom, top, front, back: N)
	do
		lrbt(left, right, bottom, top)

		self.front = front
		self.back = back
	end

	# Create a `Box3d` using left, right, top, bottom, front and back
	init lrtbfb(left, right, top, bottom, front, back: N)
	do
		lrtb(left, right, top, bottom)

		self.front = front
		self.back = back
	end

	# Create a `Box3d` using left, top, front, width, height and depth
	init lbfwhd(left, bottom, front, width, height, depth: N)
	do
		lbwh(left, bottom, width, height)

		self.front = front
		self.back = front - depth
	end

	# Create a `Box3d` using left, top, front, width, height and depth
	init ltfwhd(left, top, front, width, height, depth: N)
	do
		ltwh(left, top, width, height)

		self.front = front
		self.back = front - depth
	end
end
lib/geometry/boxes.nit:202,1--283,3