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.

Introduced properties

init around(boxed: Boxed3d[N]...)

geometry :: Box3d :: around

Create a Box covering all of the boxed
protected fun back=(back: N)

geometry :: Box3d :: back=

init defaultinit(left: N, right: N, top: N, bottom: N, front: N, back: N)

geometry :: Box3d :: defaultinit

protected fun front=(front: N)

geometry :: Box3d :: front=

init lbfwhd(left: N, bottom: N, front: N, width: N, height: N, depth: N)

geometry :: Box3d :: lbfwhd

Create a Box3d using left, top, front, width, height and depth
init lrbtfb(left: N, right: N, bottom: N, top: N, front: N, back: N)

geometry :: Box3d :: lrbtfb

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

geometry :: Box3d :: lrtbfb

Create a Box3d using left, right, top, bottom, front and back
init ltfwhd(left: N, top: N, front: N, width: N, height: N, depth: N)

geometry :: Box3d :: ltfwhd

Create a Box3d using left, top, front, width, height and depth

Redefined properties

redef type SELF: Box3d[N]

geometry $ Box3d :: SELF

Type of this instance, automatically specialized in every class
redef fun back: N

geometry $ Box3d :: back

Back bound
redef fun front: N

geometry $ Box3d :: front

Front bound

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
init around(boxed: Boxed[N]...)

geometry :: Box :: around

Create a Box covering all of the boxed
init around(boxed: Boxed3d[N]...)

geometry :: Box3d :: around

Create a Box covering all of the boxed
abstract fun back: N

geometry :: Boxed3d :: back

Back bound
protected fun back=(back: N)

geometry :: Box3d :: back=

abstract fun bottom: N

geometry :: Boxed :: bottom

Bottom bound
protected fun bottom=(bottom: N)

geometry :: Box :: bottom=

protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun contains(other: Boxed[N]): Bool

geometry :: Boxed :: contains

Is other contained within self?
init defaultinit(left: N, right: N, top: N, bottom: N, front: N, back: N)

geometry :: Box3d :: defaultinit

init defaultinit(left: N, right: N, top: N, bottom: N)

geometry :: Box :: defaultinit

abstract fun front: N

geometry :: Boxed3d :: front

Front bound
protected fun front=(front: N)

geometry :: Box3d :: front=

fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun intersects(other: Boxed[N]): Bool

geometry :: Boxed :: intersects

Does self intersect with other?
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
init lbfwhd(left: N, bottom: N, front: N, width: N, height: N, depth: N)

geometry :: Box3d :: lbfwhd

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

geometry :: Box :: lbwh

Create a Box using left, bottom, width and height
abstract fun left: N

geometry :: Boxed :: left

Left bound
protected fun left=(left: N)

geometry :: Box :: left=

init lrbt(left: N, right: N, bottom: N, top: N)

geometry :: Box :: lrbt

Create a Box using left, right, bottom and top
init lrbtfb(left: N, right: N, bottom: N, top: N, front: N, back: N)

geometry :: Box3d :: lrbtfb

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

geometry :: Box :: lrtb

Create a Box using left, right, top and bottom
init lrtbfb(left: N, right: N, top: N, bottom: N, front: N, back: N)

geometry :: Box3d :: lrtbfb

Create a Box3d using left, right, top, bottom, front and back
init ltfwhd(left: N, top: N, front: N, width: N, height: N, depth: N)

geometry :: Box3d :: ltfwhd

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

geometry :: Box :: ltwh

Create a Box using left, top, width and height
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun padded(dist: N): Box[N]

geometry :: Boxed :: padded

Create a bounding box that encloses the actual bounding box.
abstract fun right: N

geometry :: Boxed :: right

Right bound
protected fun right=(right: N)

geometry :: Box :: right=

fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_mesh: Cuboid

geometry :: Boxed3d :: to_mesh

Create a Cuboid mesh with the dimension of self
fun to_s: String

core :: Object :: to_s

User readable representation of self.
abstract fun top: N

geometry :: Boxed :: top

Top bound
protected fun top=(top: N)

geometry :: Box :: top=

package_diagram geometry::Box3d Box3d geometry::Boxed3d Boxed3d geometry::Box3d->geometry::Boxed3d geometry::Box Box geometry::Box3d->geometry::Box geometry::Boxed Boxed geometry::Boxed3d->geometry::Boxed geometry::Box->geometry::Boxed ...geometry::Boxed ... ...geometry::Boxed->geometry::Boxed

Ancestors

interface Boxed[N: Numeric]

geometry :: Boxed

An 2d abstract bounded object
interface Object

core :: Object

The root of the class hierarchy.

Parents

class Box[N: Numeric]

geometry :: Box

A 2d bounded object and an implementation of Boxed
interface Boxed3d[N: Numeric]

geometry :: Boxed3d

An 3d abstract bounded object

Class definitions

geometry $ Box3d
# 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