An 2d abstract bounded object

Introduced properties

abstract fun bottom: N

geometry :: Boxed :: bottom

Bottom bound
fun contains(other: Boxed[N]): Bool

geometry :: Boxed :: contains

Is other contained within self?
fun intersects(other: Boxed[N]): Bool

geometry :: Boxed :: intersects

Does self intersect with other?
abstract fun left: N

geometry :: Boxed :: left

Left bound
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
abstract fun top: N

geometry :: Boxed :: top

Top bound

Redefined properties

redef type SELF: Boxed[N]

geometry $ Boxed :: SELF

Type of this instance, automatically specialized in every class
redef fun to_s: String

geometry $ Boxed :: to_s

User readable representation of self.

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
abstract fun bottom: N

geometry :: Boxed :: bottom

Bottom bound
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?
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.
abstract fun left: N

geometry :: Boxed :: left

Left bound
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
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_s: String

core :: Object :: to_s

User readable representation of self.
abstract fun top: N

geometry :: Boxed :: top

Top bound
package_diagram geometry::Boxed Boxed core::Object Object geometry::Boxed->core::Object geometry::Box Box geometry::Box->geometry::Boxed geometry::Boxed3d Boxed3d geometry::Boxed3d->geometry::Boxed geometry::IPoint IPoint geometry::IPoint->geometry::Boxed geometry::ILine ILine geometry::ILine->geometry::Boxed geometry::Box3d Box3d geometry::Box3d->geometry::Box geometry::Box3d->geometry::Boxed3d geometry::Box3d... ... geometry::Box3d...->geometry::Box3d geometry::IPoint3d IPoint3d geometry::IPoint3d->geometry::Boxed3d geometry::IPoint3d->geometry::IPoint geometry::ILine3d ILine3d geometry::ILine3d->geometry::Boxed3d geometry::ILine3d->geometry::ILine geometry::IPoint3d... ... geometry::IPoint3d...->geometry::IPoint3d geometry::ILine3d... ... geometry::ILine3d...->geometry::ILine3d geometry::Point Point geometry::Point->geometry::IPoint geometry::Point... ... geometry::Point...->geometry::Point geometry::Line Line geometry::Line->geometry::ILine geometry::Line... ... geometry::Line...->geometry::Line

Parents

interface Object

core :: Object

The root of the class hierarchy.

Children

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
interface ILine[N: Numeric]

geometry :: ILine

Abstract 2D line segment between two ordered points
interface IPoint[N: Numeric]

geometry :: IPoint

Abstract 2d point, strongly linked to its implementation Point

Descendants

class Box3d[N: Numeric]

geometry :: Box3d

A 3d bounded object and an implementation of Boxed
interface ILine3d[N: Numeric]

geometry :: ILine3d

Abstract 3D line segment between two ordered points
interface IPoint3d[N: Numeric]

geometry :: IPoint3d

Abstract 3d point, strongly linked to its implementation Point3d
class Line[N: Numeric]

geometry :: Line

2D line segment between two ordered points
class Line3d[N: Numeric]

geometry :: Line3d

3D line segment between two ordered points
class Point[N: Numeric]

geometry :: Point

2D point with x and z
class Point3d[N: Numeric]

geometry :: Point3d

3D point with x, y and z

Class definitions

geometry $ Boxed
# An 2d abstract bounded object
interface Boxed[N: Numeric]
	# Left bound
	#
	# require: left <= right
	fun left: N is abstract

	# Right bound
	#
	# require: right >= left
	fun right: N is abstract

	# Top bound
	#
	# require: top >= bottom
	fun top: N is abstract

	# Bottom bound
	#
	# require: bottom <= top
	fun bottom: N is abstract

	# Is `other` contained within `self`?
	#
	#     var a = new Box[Int].lbwh(1, 1, 4, 4)
	#     var b = new Box[Int].lbwh(2, 2, 2, 2)
	#     var c = new Box[Int].lbwh(0, 2, 8, 2)
	#     assert a.contains(b)
	#     assert not b.contains(a)
	#     assert c.contains(b)
	#     assert not b.contains(c)
	#     assert not a.contains(c)
	#     assert not c.contains(a)
	fun contains(other: Boxed[N]): Bool
	do
		return self.top >= other.top and self.bottom <= other.bottom and
			self.left <= other.left and self.right >= other.right
	end

	# Does `self` intersect with `other`?
	#
	#     var a = new Box[Int].lbwh(0, 0, 2, 2)
	#     var b = new Box[Int].lbwh(1, 1, 8, 2)
	#     var c = new Box[Int].lbwh(3, 0, 2, 8)
	#     assert a.intersects(b)
	#     assert b.intersects(a)
	#     assert b.intersects(c)
	#     assert c.intersects(b)
	#     assert not c.intersects(a)
	#     assert not a.intersects(c)
	fun intersects(other: Boxed[N]): Bool
	do
		return self.left <= other.right and other.left <= self.right and
			self.top >= other.bottom and other.top >= self.bottom
	end

	# Create a bounding box that encloses the actual bounding box.
	# `dist` is the distance between the inner boundaries and the outer boundaries.
	# ~~~
	# var p = new Point[Int](5,10)
	# var b = p.padded(3)
	# assert b.left == 2 and b.right == 8 and b.top == 13 and b.bottom == 7
	# ~~~
	fun padded(dist: N): Box[N] do return new Box[N].lrtb(left - dist, right + dist, top + dist, bottom - dist)

	redef fun to_s do return "<{class_name} left: {left}, right: {right}, top: {top}, bottom: {bottom}>"
end
lib/geometry/boxes.nit:22,1--88,3