struct CP::BB

Overview

Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)

Defined in:

chipmunk/vector.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(left : Number = 0, bottom : Number = 0, right : Number = 0, top : Number = 0) #

[View source]
def self.new_for_circle(p : Vect, r : Number) : self #

Constructs a BB fitting a circle with the position p and radius r.


[View source]
def self.new_for_extents(c : Vect, hw : Number, hh : Number) : self #

Constructs a BB centered on a point with the given extents (half sizes).


[View source]

Instance Method Detail

def area : Float64 #

Returns the area of the bounding box.


[View source]
def bottom : Float64 #

[View source]
def bottom=(bottom : Float64) #

[View source]
def center : Vect #

Returns the center of a bounding box.


[View source]
def clamp_vect(v : Vect) : Vect #

Clamp a vector to a bounding box


[View source]
def contains?(other : BB) : Bool #

Returns true if the other BB lies completely within this one.


[View source]
def contains?(point : Vect) : Bool #

Returns true if this BB contains the point.


[View source]
def expand(point : Vect) : BB #

Returns the minimal bounding box that contains both this BB and the point.


[View source]
def intersects?(other : BB) : Bool #

Returns true if this BB intersects the other.


[View source]
def intersects_segment?(a : Vect, b : Vect) : Bool #

Return true if the bounding box intersects the line segment with ends a and b.


[View source]
def left : Float64 #

[View source]
def left=(left : Float64) #

[View source]
def merge(other : BB) : BB #

Returns a bounding box that holds both bounding boxes.


[View source]
def offset(v : Vect) : BB #

Returns a bounding box offseted by v.


[View source]
def right : Float64 #

[View source]
def right=(right : Float64) #

[View source]
def segment_query(a : Vect, b : Vect) : Float64 #

Returns the fraction along the segment query the BB is hit.

Returns INFINITY if it doesn't hit.


[View source]
def top : Float64 #

[View source]
def top=(top : Float64) #

[View source]
def wrap_vect(v : Vect) : Vect #

Wrap a vector to a bounding box.


[View source]