Class myphysicslab.lab.util.DoubleRect
Provided By 

A rectangle whose boundaries are stored with double floating point precision. This is an immutable class: once an instance is created it cannot be changed.
Note that for DoubleRect we regard the vertical coordinate as increasing upwards, so the top coordinate is greater than the bottom coordinate. This is in contrast to HTML5 canvas where vertical coordinates increase downwards.
new DoubleRect( left, bottom, right, top_ )
Parameters 
 

Throws 

Instance Methods
this.contains( point ) → boolean
boolean
Returns true
if the given point is within this rectangle.
Parameters 
 

Returns 

this.equals( obj ) → boolean
boolean
Returns true
if the object is a DoubleRect with the same coordinates.
Parameters 
 

Returns 

this.expand( marginX, marginY ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a copy of this DoubleRect expanded by the given margin in x and y dimension.
Parameters 
 

Returns 

this.getBottom() → number
number
Returns the smallest vertical coordinate of this DoubleRect
Parameters  None.  

Returns 

this.getCenter() → myphysicslab.lab.util.Vector
myphysicslab.lab.util.Vector
Returns the center of this DoubleRect.
Parameters  None.  

Returns 

this.getCenterX() → number
number
Returns the horizontal coordinate of center of this DoubleRect.
Parameters  None.  

Returns 

this.getCenterY() → number
number
Returns the vertical coordinate of center of this DoubleRect.
Parameters  None.  

Returns 

this.getHeight() → number
number
Returns the vertical height of this DoubleRect
Parameters  None.  

Returns 

this.getLeft() → number
number
Returns the smallest horizontal coordinate of this DoubleRect
Parameters  None.  

Returns 

this.getRight() → number
number
Returns the largest horizontal coordinate of this DoubleRect
Parameters  None.  

Returns 

this.getTop() → number
number
Returns the largest vertical coordinate of this DoubleRect
Parameters  None.  

Returns 

this.getWidth() → number
number
Returns the horizontal width of this DoubleRect
Parameters  None.  

Returns 

this.isEmpty( opt_tolerance ) → boolean
boolean
Returns true
if width or height of this DoubleRect are zero (within given
tolerance).
Parameters 
 

Returns 

this.maybeVisible( p1, p2 ) → boolean
boolean
Returns true if the line between the two points might be visible in the rectangle.
Parameters 
 

Returns 

this.nearEqual( rect, opt_tolerance ) → boolean
boolean
Returns true
if this DoubleRect is nearly equal to another DoubleRect.
The optional tolerance value corresponds to the epsilon
in
myphysicslab.lab.util.UtilityCore#veryDifferent
, so the actual tolerance
used depends on the magnitude of the numbers being compared.
Parameters 
 

Returns 

this.scale( factorX, factorY ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a copy of this DoubleRect expanded by the given factors in both x and y dimension. Expands (or contracts) about the center of this DoubleRect by the given expansion factor in x and y dimensions.
Parameters 
 

Returns 

this.toString() → string
string
Parameters  None.  

Returns 

this.translate( x, y ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a copy of this rectangle translated by the given amount.
Parameters 
 

Returns 
 
Throws 

this.union( rect ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a rectangle that is the union of this and another rectangle.
Parameters 
 

Returns 

this.unionPoint( point ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a rectangle that is the union of this rectangle and a point
Parameters 
 

Returns 

Static Functions
DoubleRect.clone( rect ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a copy of the given DoubleRect.
Parameters 
 

Returns 

DoubleRect.isDuckType( obj ) → boolean
boolean
Returns true if the object is likely a DoubleRect. Only works under simple compilation, intended for interactive noncompiled code.
Parameters 
 

Returns 

DoubleRect.make( point1, point2 ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a DoubleRect spanning the two given points.
Parameters 
 

Returns 

DoubleRect.makeCentered( center, width, height ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a DoubleRect centered at the given point with given height and width.
Parameters 
 

Returns 

DoubleRect.makeCentered2( center, size ) → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
Returns a DoubleRect centered at the given point with given size.
Parameters 
 

Returns 

Static Properties
DoubleRect.EMPTY_RECT → myphysicslab.lab.util.DoubleRect
myphysicslab.lab.util.DoubleRect
The empty rectangle (0, 0, 0, 0).