| 
									
										
										
										
											2008-07-11 19:14:05 -04:00
										 |  |  | USING: help.markup help.syntax ;
 | 
					
						
							| 
									
										
										
										
											2009-02-05 04:28:41 -05:00
										 |  |  | IN: math.rectangles | 
					
						
							| 
									
										
										
										
											2008-07-11 19:14:05 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | HELP: rect | 
					
						
							|  |  |  | { $class-description "A rectangle with the following slots:" | 
					
						
							|  |  |  |     { $list | 
					
						
							| 
									
										
										
										
											2009-02-05 04:28:41 -05:00
										 |  |  |         { { $slot "loc" } " - the top-left corner of the rectangle as an x/y pair" } | 
					
						
							|  |  |  |         { { $slot "dim" } " - the dimensions of the rectangle as a width/height pair" } | 
					
						
							| 
									
										
										
										
											2008-07-11 19:14:05 -04:00
										 |  |  |     } | 
					
						
							|  |  |  |     "Rectangles are constructed by calling " { $link <rect> } " and " { $link <extent-rect> } "." | 
					
						
							|  |  |  | } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-15 20:44:56 -05:00
										 |  |  | HELP: <rect> | 
					
						
							| 
									
										
										
										
											2008-07-11 19:14:05 -04:00
										 |  |  | { $values { "loc" "a pair of integers" } { "dim" "a pair of integers" } { "rect" "a new " { $link rect } } } | 
					
						
							|  |  |  | { $description "Creates a new rectangle with the specified top-left location and dimensions." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { <zero-rect> <rect> <extent-rect> } related-words | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: rect-bounds | 
					
						
							|  |  |  | { $values { "rect" rect } { "loc" "a pair of integers" } { "dim" "a pair of integers" } } | 
					
						
							|  |  |  | { $description "Outputs the location and dimensions of a rectangle." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | { rect-bounds rect-extent } related-words | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-15 20:44:56 -05:00
										 |  |  | HELP: <extent-rect> | 
					
						
							| 
									
										
										
										
											2008-07-11 19:14:05 -04:00
										 |  |  | { $values { "loc" "a pair of integers" } { "ext" "a pair of integers" } { "rect" "a new " { $link rect } } } | 
					
						
							|  |  |  | { $description "Creates a new rectangle with the specified top-left and bottom-right corner locations." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: rect-extent | 
					
						
							|  |  |  | { $values { "rect" rect } { "loc" "a pair of integers" } { "ext" "a pair of integers" } } | 
					
						
							|  |  |  | { $description "Outputs the location of the top-left and bottom-right corners of a rectangle." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: offset-rect | 
					
						
							|  |  |  | { $values { "rect" rect } { "loc" "a pair of integers" } { "newrect" "a new " { $link rect } } } | 
					
						
							|  |  |  | { $description "Creates a new rectangle with the same dimensions, and top-left corner translated by " { $snippet "loc" } "." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: rect-intersect | 
					
						
							|  |  |  | { $values { "rect1" rect } { "rect2" rect } { "newrect" "a new " { $link rect } } } | 
					
						
							|  |  |  | { $description "Computes the intersection of two rectangles." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-05 06:16:22 -05:00
										 |  |  | HELP: contains-rect? | 
					
						
							|  |  |  | { $values { "rect1" rect } { "rect2" rect } { "?" "a boolean" } } | 
					
						
							|  |  |  | { $description "Tests if two rectangles have a non-empty intersection." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: contains-point? | 
					
						
							|  |  |  | { $values { "point" "a pair of integers" } { "rect" rect } { "?" "a boolean" } } | 
					
						
							|  |  |  | { $description "Tests if a rectangle contains a point." } ;
 | 
					
						
							| 
									
										
										
										
											2008-07-11 19:14:05 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | HELP: <zero-rect> | 
					
						
							|  |  |  | { $values { "rect" "a new " { $link rect } } } | 
					
						
							|  |  |  | { $description "Creates a rectangle located at the origin with zero dimensions." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-05 04:28:41 -05:00
										 |  |  | ARTICLE: "math.rectangles" "Rectangles" | 
					
						
							|  |  |  | "The " { $vocab-link "math.rectangles" } " vocabulary defines a rectangle data type and operations on them." | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections rect } | 
					
						
							| 
									
										
										
										
											2008-11-19 18:10:19 -05:00
										 |  |  | "Rectangles can be taken apart:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections | 
					
						
							|  |  |  |     rect-bounds | 
					
						
							|  |  |  |     rect-extent | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-11-19 18:10:19 -05:00
										 |  |  | "New rectangles can be created:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections | 
					
						
							|  |  |  |     <zero-rect> | 
					
						
							|  |  |  |     <rect> | 
					
						
							|  |  |  |     <extent-rect> | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-02-05 06:16:22 -05:00
										 |  |  | "Set-theoretic operations on rectangles:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections | 
					
						
							|  |  |  |     rect-intersect | 
					
						
							|  |  |  |     rect-union | 
					
						
							|  |  |  |     contains-rect? | 
					
						
							|  |  |  |     contains-point? | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-02-05 06:16:22 -05:00
										 |  |  | "A utility word:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections offset-rect } ;
 | 
					
						
							| 
									
										
										
										
											2008-11-19 18:13:10 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-05 04:28:41 -05:00
										 |  |  | ABOUT: "math.rectangles" |