geometry :: Boxed3d :: defaultinit
geometry $ Boxed3d :: intersects
var a = new Box3d[Int].lbfwhd(0, 0, 0, 2, 2, 2)
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
geometry :: Boxed3d :: defaultinit
geometry :: Boxed :: defaultinit
geometry :: Boxed :: intersects
Doesself
intersect with other
?
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# An 3d abstract bounded object
interface Boxed3d[N: Numeric]
super Boxed[N]
# Front bound
#
# require: front >= back
fun front: N is abstract
# Back bound
#
# require: back <= bottom
fun back: N is abstract
# var a = new Box3d[Int].lbfwhd(1, 1, -1, 4, 4, 4)
# var b = new Box3d[Int].lbfwhd(2, 2, -2, 2, 2, 2)
# var c = new Box3d[Int].lbfwhd(2, 2, 0, 2, 2, 8)
# 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)
redef fun contains(other)
do
return super and (not other isa Boxed3d[N] or
(self.front >= other.front and self.back <= other.back))
end
# var a = new Box3d[Int].lbfwhd(0, 0, 0, 2, 2, 2)
# var b = new Box3d[Int].lbfwhd(1, 1, 1, 8, 2, 2)
# var c = new Box3d[Int].lbfwhd(3, 0, 0, 2, 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)
redef fun intersects(other)
do
return super and (not other isa Boxed3d[N] or
(self.back <= other.front and other.back <= self.front))
end
redef fun padded(dist): Box3d[N] do return new Box3d[N].lrtbfb(left - dist, right + dist, top + dist, bottom - dist, front + dist, back - dist)
redef fun to_s do return "<{class_name} left: {left}, right: {right}, top: {top}, bottom: {bottom}, front: {front}, back: {back}>"
end
lib/geometry/boxes.nit:153,1--200,3
redef class Boxed3d[N]
# Create a `Cuboid` mesh with the dimension of `self`
#
# Does not use the position of `self`, but it can be given to an `Actor`.
fun to_mesh: Cuboid
do
var width = right.to_f-left.to_f
var height = top.to_f-bottom.to_f
var depth = front.to_f-back.to_f
return new Cuboid(width, height, depth)
end
end
lib/gamnit/depth/more_meshes.nit:163,1--174,3