The Solar-Stellar Spectrograph

[ Home | About | Tech Info & Data | Publications | References ]      [ Site by Jeffrey Hall | Research funded by NSF ]

ARTICLE

Rect

The Rect class implements defintion of and operations on rectangular areas. Most of the methods are quite compact and simple, and are simply meant to provide a common bit of code for frequently used operations.

Version History

2008 July 17 - Documentation written.

 

Data Members

Coord topLeft

Coord bottomRight

 

Method List

area( )

center( )

center_at

center_zero( )

cleanup

define

diagonal( )

equals

get_bottom_left( )

get_bottom_right( )

get_bottom_top( )

get_left_right( )

get_top_left( )

get_top_right( )

height( )

init( )

is_valid( )

set

set_at

shift_by

width( )

 

Method Descriptions

 

FUNCTION area

Calls Rect::height, Rect::width

Return float area

Returns the area of the rectangle.

 

FUNCTION center

Calls Rect::height, Rect::width, Coord::get

Return float[ 2 ] center

Returns the center of the rectangle as an (x, y) pair of floats.

 

PRO center_at

argument float x

argument float y

Calls Rect::center, Rect::shift_to

Shifts the center of the rectangle to (x, y), preserving its dimensions.

 

FUNCTION center_zero

Calls Rect::center

Return bool TRUE, FALSE

Returns TRUE if the rectangle is centered at [0,0], FALSE otherwise.

 

PRO cleanup

Calls Root::cleanup

Destructor. Destroys the Coord data members. Never call this procedure directly; it is invoked by IDL's Obj_Destroy function.

 

PRO define

Structure definition. Specifies the contents of the IDL structure instantiated by the Rect class. Used by Obj_New; do not invoke directly.

 

FUNCTION diagonal

Calls Rect::height, Rect::width

Return float diagonal

Returns the length of the rectangle's diagonal.

 

PRO equals

argument Rect rect

Calls Rect::get_top_left, Rect::get_bottom_right, Rect::set

Sets the coordinates of the rectangle equal to those of the Rect passed in the argument.

 

FUNCTION get_bottom_left

Calls Rect::get_bottom_right, Rect::get_top_left

Return float[ 2 ] [bottom, left]

Returns the bottom and left coordinates of the rectangle as an array of two floats.

 

FUNCTION get_bottom_right

Calls Rect::get

Return Coord bottomRight

Returns the bottom right coordinate of the rectangle.

 

FUNCTION get_bottom_top

Calls Rect::get_bottom_right, Rect::get_top_left

Return float[ 2 ] [top, right]

Returns the bottom and top coordinates of the rectangle as an array of two floats.

 

FUNCTION get_left_right

Calls Rect::get_bottom_right, Rect::get_top_left

Return float[ 2 ] [left, right]

Returns the left and right doordinates of the rectangle.

 

FUNCTION get_top_left

Calls Rect::get

Return Coord topLeft

Returns the top left coordinate of the rectangle.

 

FUNCTION get_top_right

Calls Rect::get_bottom_right, Rect::get_top_left

Return float[ 2 ] [top, right]

Returns the top and right coordinates of the rectangle as an array of two floats.

 

FUNCTION height

Calls Rect::get_bottom_left, Coord::diff

Return float height

Returns the height of the rectangle.

 

FUNCTION init

argument float top

argument float left

argument float bottom

argument float right

Return bool TRUE

Constructor. The arguments specify the values of the rectangle sides. Never call this function directly; it is invoked by IDL's Obj_New function.

 

FUNCTION is_valid

Calls Coord::is_valid

Return long valid

Each OIL class has an is_valid function that performs class-specific tests on its data members. If all members are found to be valid, however validity is defined for that class, this funtion returns 1. Otherwise, a negative number is returned that contains a bitwise combination of all errors detected. In the case of Rect, the error codes are: -1 (if Obj_Valid called on the Rect is NULL) or -2 (if either of the Coord objects are invalid.

 

PRO set

argument float top

argument float left

argument float bottom

argument float right

Calls Coord::set

Sets the dimensions of the rectangle.

 

PRO set_at

keyword float top

keyword float left

keyword float bottom

keyword float right

Calls Coord::set, Coord::get

Sets any the value of any one or any combination of the sides of the rectangle via the keywords.

 

PRO shift_by

argument float xAmount

argument float yAmount

Calls Coord::set, Coord::get

Sets the dimensions of the rectangle.

 

FUNCTION width

Calls Rect::get_top_left, Coord::diff

Return float width

Returns the width of the rectangle.

 

 

Sample Usage

obj = Obj_New( 'Rect', 512, 0, 0, 512 )

Obj_Destroy( obj )

 


[Back to contents]

Supported by grants from the National Science Foundation.
[ Back to my home page | Email me: jch [at] lowell [dot] edu ]
The SSS is publicly funded. Unless explicitly noted otherwise, everything on this site is in the public domain.
If you use or quote our results or images, we appreciate an acknowledgment.
This site is best viewed with Mozilla Firefox.