DUIM-Extended-Geometry Library¶
Overview¶
The DUIM-Extended-Geometry library builds on the features provided by the DUIM-Geometry library, and provides more extensive support for coordinate geometry that is only required for more specialist uses. The library contains a single module, duim-extended-geometry, from which all the interfaces described in this chapter are exposed. See DUIM-Extended-Geometry Module that contains complete reference entries for each exposed interface.
The class hierarchy for DUIM-Extended-Geometry¶
The DUIM-Extended-Geometry library defines no base classes itself, but
instead subclasses two classes exposed in the DUIM-Geometry library:
<area>
and <path>
. In each case, these subclasses provide more
specialized geometrical tools.
Subclasses of <area>¶
Three subclasses of <area>
are exposed in the DUIM-Extended-Geometry
library, each of which provides the ability to create instances of
particular shapes. Their usage is relatively obvious.
<rectangle>
This class is used to create rectangular shapes on a drawable object.<ellipse>
This class is used to create elliptical shapes on a drawable object.<polygon>
This class is used to create more general polygon shapes on a drawable object.
Subclass of <path>¶
Three subclasses of <path>
are exposed in the DUIM-Extended-Geometry
library, each of which provides the ability to create instances of
particular types of line. Their usage is relatively obvious.
<line>
This class is used to create straight lines between two points on a drawable object.<elliptical-arc>
This class is used to create elliptical arcs (portions of an ellipse) on a drawable object.<polyline>
This class is used to create lines that pass through an arbitrary set of coordinates. It produces a jagged line with vertices at each coordinate.
DUIM-Extended-Geometry Module¶
This section contains a complete reference of all the interfaces that are exported from the duim-extended-geometry module.
- do-polygon-coordinates Generic function¶
Applies a function to all of the coordinates of the vertices of a polygon.
- Signature:
do-polygon-coordinates function polygon => ()
- Parameters:
function – An instance of type
<function>
.polygon – An instance of type
<polygon>
.
- Discussion:
Applies function to all of the coordinates of the vertices of polygon. function is a function of two arguments, the x and y coordinates of the vertex. do-polygon-coordinates returns
#f
.- See also:
- do-polygon-segments Generic function¶
Applies a function to the segments that compose a polygon.
- Signature:
do-polygon-segments function polygon => ()
- Parameters:
function – An instance of type
<function>
.polygon – An instance of type
<polygon>
.
- Discussion:
Applies function to the segments that compose polygon. function is a function of four arguments, the x and y coordinates of the start of the segment, and the x and y coordinates of the end of the segment. When do-polygon-segments is called on a closed polyline, it calls function on the segment that connects the last point back to the first point.
The function do-polygon-segments returns
#f
.- See also:
- draw-design Generic function¶
Draws a design on a drawing surface.
- Signature:
draw-design drawable design => ()
- Parameters:
drawable – An instance of type type-union(<sheet>, <medium>).
design – A
<region>
to draw.
- Discussion:
Draws design on the sheet medium drawable.
- <ellipse> Abstract Instantiable Class¶
The class that corresponds to an ellipse.
- Superclasses:
- Init-Keywords:
center-x – An instance of type
<real>
.center-y – An instance of type
<real>
.center-point – An instance of type
<point>
.radius-1-dx – An instance of type
<real>
radius-1-dy – An instance of type
<real>
radius-2-dx – An instance of type
<real>
radius-2-dy – An instance of type
<real>
start-angle – An instance of
false-or(<real>)
.end-angle – An instance of
false-or(<real>)
.
- Discussion:
An ellipse is an area that is the outline and interior of an ellipse. Circles are special cases of ellipses.
The center-x: init-keyword specifies the x coordinate of the center of the ellipse.
The center-y: init-keyword specifies the y coordinate of the center of the ellipse.
The center-point: init-keyword specifies the center of the ellipse as a point.
An ellipse is specified in a manner that is easy to transform, and treats all ellipses on an equal basis. An ellipse is specified by its center point and two vectors that describe a bounding parallelogram of the ellipse. y*c* -dx*1* + dx*2*
Note that several different parallelograms specify the same ellipse. One parallelogram is bound to be a rectangle — the vectors will be perpendicular and correspond to the semi-axes of the ellipse.
- Operations:
The following operations are exported from the DUIM-Extended-Geometry module.
The following operations are exported from the DUIM-Geometry module.
- See also:
- ellipse? Generic function¶
Returns
#t
if an object is an ellipse.
- ellipse-center-point Generic function¶
Returns the center point of an ellipse or an elliptical arc.
- Signature:
ellipse-center-point elliptical-object => point
- Parameters:
elliptical-object – An instance of type type-union(
<ellipse>
,<elliptical-arc>
).
- Values:
point – An instance of type
<point>
.
- Discussion:
Returns the center point of ellipse-object as a
<point>
object.- See also:
- ellipse-center-position Generic function¶
Returns the coordinates of the center point of an ellipse or an elliptical arc.
- Signature:
ellipse-center-position* elliptical-object => x y
- Parameters:
elliptical-object – An instance of type type-union(
<ellipse>
,<elliptical-arc>
).
- Values:
- Discussion:
Returns the coordinates of the center point of elliptical-object.
The arguments x and y represent the x and y coordinates of the center of the elliptical object, respectively.
- See also:
- ellipse-end-angle Generic function¶
Returns the end angle of an ellipse or an elliptical-object.
- Signature:
ellipse-end-angle elliptical-object => angle
- Parameters:
elliptical-object – An instance of type
type-union(<ellipse>, <elliptical-arc>)
.
- Values:
angle – An instance of type
false-or(<real>)
.
- Discussion:
Returns the end angle of elliptical-object. If elliptical-object is a full ellipse or closed path then ellipse-end-angle returns
#f
; otherwise the value is a number greater than zero, and less than or equal to 2p.- See also:
- ellipse-radii Generic function¶
Returns four values corresponding to the two radius vectors of an elliptical arc.
- Signature:
ellipse-radii elliptical-object => r1-dx r1-dy r2-dx d2-dy
- Parameters:
elliptical-object – An instance of type
type-union(<ellipse>, <elliptical-arc>)
.
- Values:
- Discussion:
Returns four values corresponding to the two radius vectors of elliptical-object. These values may be canonicalized in some way, and so may not be the same as the values passed to the constructor function.
- See also:
- ellipse-start-angle Generic function¶
Returns the start angle of an elliptical arc.
- Signature:
ellipse-start-angle elliptical-object => angle
- Parameters:
elliptical-object – An instance of type
type-union(<ellipse>, <elliptical-arc>)
.
- Values:
angle – An instance of type
false-or(<real>)
.
- Discussion:
Returns the start angle of elliptical-object. If elliptical-object is a full ellipse or closed path then ellipse-start-angle returns
#f
; otherwise the value will be a number greater than or equal to zero, and less than 2p.- See also:
- <elliptical-arc> Abstract Instantiable Class¶
An elliptical arc is a path consisting of all or a portion of the outline of an ellipse.
- Superclasses:
- Init-Keywords:
center-x – An instance of type
<real>
.center-y – An instance of
<real>
.center-point – An instance of type
<point>
.radius-1-dx – An instance of
<real>
.radius-1-dy – An instance of
<real>
.radius-2-dx – An instance of
<real>
.radius-2-dy – An instance of
<real>
.start-angle – An instance of
false-or(<real>)
.end-angle – An instance of
false-or(<real>)
.
- Discussion:
An elliptical arc is a path consisting of all or a portion of the outline of an ellipse. Circular arcs are special cases of elliptical arcs.
- Operations:
The following operations are exported from the DUIM-Extended-Geometry module.
The following operations are exported from the DUIM-Geometry module.
- See also:
- elliptical-arc? Generic function¶
Returns
#t
if an object is an elliptical arc,
- <line> Abstract Instantiable Class¶
The class that corresponds to a line.
- Superclasses:
- Init-Keywords:
- Discussion:
The class that corresponds to a line. This is a subclass of
<path>
.This is the instantiable class that implements a line segment.
make-line
instantiates an object of type<line>
.- Operations:
The following operations are exported from the DUIM-Extended-Geometry module.
The following operations are exported from the DUIM-Geometry module.
- See also:
- line? Generic function¶
Returns
#t
if an object is a line.
- line-end-point Generic function¶
Returns the ending point of a line.
- line-end-position Generic function¶
Returns the ending point of a line.
- Signature:
line-end-position line => x y
- Parameters:
line – An instance of type
<line>
.
- Values:
- Discussion:
Returns two real numbers representing the x and y coordinates of the ending point of line.
The arguments x and y represent the x and y coordinates of the end of the line, respectively.
- See also:
- line-start-point Generic function¶
Returns the starting point of a line.
- line-start-position Generic function¶
Returns the starting point of a line.
- Signature:
line-start-position line => x y
- Parameters:
line – An instance of type
<line>
.
- Values:
- Discussion:
Returns two real numbers representing the x and y coordinates of the starting point of line.
The arguments x and y represent the x and y coordinates of the start of the line, respectively.
- See also:
- make-ellipse Function¶
Returns an object of class
<ellipse>
.- Signature:
make-ellipse center-x center-y radius-1-dx radius-1-dy radius-2-dx radius-2-dy #key start-angle end-angle => ellipse
- Signature:
make-ellipse* center-point radius-1-dx radius-1-dy radius-2-dx radius-2-dy #key start-angle end-angle => ellipse
- Parameters:
The following arguments are specific to make-ellipse.
The following argument is specific to make-ellipse.
- Parameters:
center-point – An instance of type
<point>
.
- Values:
ellipse – An instance of type
<ellipse>
.
- Discussion:
Returns an object of class <ellipse>. The center of the ellipse is at the position center-x,*center-y* or the point center-point.
Two vectors, (radius-1-dx,radius-1-dy) and (radius-2-dx,radius-2-dy ) specify the bounding parallelogram of the ellipse. All of the radii are real numbers. If the two vectors are colinear, the ellipse is not well-defined and the ellipse-not-well-defined error is signalled. The special case of an ellipse with its axes aligned with the coordinate axes can be obtained by setting both radius-1-dy and radius-2-dx to 0.
If start-angle or end-angle are supplied, the ellipse is the pie slice area swept out by a line from the center of the ellipse to a point on the boundary as the boundary point moves from the angle start-angle to end-angle. Angles are measured counter-clockwise with respect to the positive x axis. If end-angle is supplied, the default for start-angle is 0 ; if start-angle is supplied, the default for end-angle is 2p ; if neither is supplied then the region is a full ellipse and the angles are meaningless.
The function make-ellipse* is identical to make-ellipse, except that it passes composite objects, rather than separate coordinates, in its arguments. You should be aware that using this function may lead to a loss of performance.
- See also:
- make-elliptical-arc Function¶
Returns an object of class <elliptical-arc>.
- Signature:
make-elliptical-arc center-x center-y radius-1-dx radius-1-dy radius-2-dx radius-2-dy #key start-angle end-angle => arc
- Signature:
make-elliptical-arc* center-point radius-1-dx radius-1-dy radius-2-dx radius-2-dy #key start-angle end-angle => arc
- Parameters:
The following arguments are specific to make-elliptical-arc.
The following argument is specific to make-elliptical-arc*.
- Parameters:
center-point – An instance of type
<point>
.
- Values:
arc – An instance of type
<elliptical-arc>
.
- Discussion:
Returns an object of class <elliptical-arc>. The center of the ellipse is at the position center-x,center-y or the point center-point
Two vectors, (radius-1-dx,radius-1-dy) and (radius-2-dx,radius-2-dy ), specify the bounding parallelogram of the ellipse. All of the radii are real numbers. If the two vectors are colinear, the ellipse is not well-defined and the ellipse-not-well-defined error will be signalled. The special case of an elliptical arc with its axes aligned with the coordinate axes can be obtained by setting both radius-1-dy and radius-2-dx to 0.
If start-angle and end-angle are supplied, the arc is swept from start-angle to end-angle. Angles are measured counter-clockwise with respect to the positive x axis. If end-angle is supplied, the default for start-angle is 0 ; if start-angle is supplied, the default for end-angle is 2p ; if neither is supplied then the region is a closed elliptical path and the angles are meaningless.
The function make-elliptical-arc* is identical to make-elliptical-arc, except that it passes composite objects, rather than separate coordinates, in its arguments. You should be aware that using this function may lead to a loss of performance.
- See also:
- make-line Function¶
Returns an object of class
<line>
.t- Signature:
make-line start-x start-y end-x end-y => line
- Signature:
make-line* start-point end-point => line
- Parameters:
- Values:
line – An instance of type
<line>
.
- Discussion:
Returns an object of class
<line>
that connects the two positions (start-x,start-y) and (e*nd-x,end-y*) or the two points start-point and end-point.
- make-polygon Function¶
Returns an object of class
<polygon>
.- Signature:
make-polygon coord-seq => polygon
- Signature:
make-polygon* point-seq => polygon
The following argument is specific to
make-polygon
.- Parameters:
coord-seq – An instance of type limited(<sequence>, of: <real>).
The following argument is specific to
make-polygon*
.- Parameters:
point-seq – An instance of type
limited(<sequence>, of: <point>)
.
- Values:
polygon – An instance of type
<polygon>
.
- Discussion:
Returns an object of class <polygon> consisting of the area contained in the boundary that is specified by the segments connecting each of the points in point-seq or the points represented by the coordinate pairs in coord-seq. point-seq is a sequence of points; coord-seq is a sequence of coordinate pairs, which are real numbers. It is an error if coord-seq does not contain an even number of elements.
The function make-polygon* is identical to make-polygon, except that it passes composite objects, rather than separate coordinates, in its arguments. You should be aware that using this function may lead to a loss of performance.
- make-polyline Function¶
Returns an object of class
<polyline>
.- Signature:
make-polyline coord-seq #key closed? => polyline
- Signature:
make-polyline* point-seq #key closed? => polyline
- Parameters:
closed? – An instance of type
<boolean>
. Default value:#f
.
The following argument is specific to
make-polyline
.- Parameters:
coord-seq – An instance of type
limited(<sequence>, of: <real>)
.
The following argument is specific to
make-polyline\*
.- Parameters:
point-seq – An instance of type
limited(<sequence>, of: <point>)
.
- Values:
polyline – An instance of type
<polyline>
- Discussion:
Returns an object of class
<polyline>
consisting of the segments connecting each of the points in point-seq or the points represented by the coordinate pairs in coord-seq. point-seq is a sequence of points; coord-seq is a sequence of coordinate pairs, which are real numbers. It is an error if coord-seq does not contain an even number of elements.If closed? is
#t
, then the segment connecting the first point and the last point is included in the polyline. The default for closed? is**#f
.The function
make-polyline\*
is identical tomake-polyline
, except that it passes composite objects, rather than separate coordinates, in its arguments. You should be aware that using this function may lead to a loss of performance.
- make-rectangle Function¶
Returns an object of class
<rectangle>
.- Signature:
make-rectangle x1 y1 x2 y2 => rectangle
- Signature:
make-rectangle* min-point max-point => rectangle
The following arguments are specific to
make-rectangle
.- Parameters:
x1 – An instance of type
<real>
. The x coordinate of the left top of the rectangle.y1 – An instance of type
<real>
. The y coordinate of the left top of the rectanglex2 – An instance of type
<real>
. The x coordinate of the bottom right of the rectangle.y2 – An instance of type
<real>
. The y coordinate of the bottom right of the rectangle.
The following arguments are specific to
make-rectangle\*
.- Parameters:
min-point – The minimum point (left top) of the rectangle.
max-point – The maximum point (bottom right) of the rectangle.
- Values:
rectangle – An instance of type
<rectangle>
.
- Discussion:
Returns an object of class
<rectangle>
whose edges are parallel to the coordinate axes. One corner is at the point point1 or the position*x1,y1* and the opposite corner is at the point point2 or the position x2,y2. There are no ordering constraints among point1 and point2 or x1 and x2, and y1 and y2.The function make-rectangle* is identical to make-rectangle, except that it passes composite objects, rather than separate coordinates, in its arguments. You should be aware that using this function may lead to a loss of performance.
- <polygon> Abstract Instantiable Class¶
The class that corresponds to a polygon.
- Superclasses:
- Init-Keywords:
coordinates – An instance of type
limited(<sequence>, of: <real>)
.points – An instance of type
limited(<sequence>, of: <real>)
.
- Discussion:
The class that corresponds to a polygon. This is a subclass of
<area>
.A polygon can be described either in terms of the individual x and y coordinates that constitute its vertices, or by using composite points. If the former is used, then they can be specified at the time of creation using the coordinates: init-keyword, which is a sequence of real numbers, with x and y coordinates alternating within the sequence.
To describe a polygon in terms of composite point objects, use the points: init-keyword, which is a sequence of instances of
<point>
. You should be aware that using composite points may lead to a loss of performance.Exactly one of coordinates: and points: is required.
- Operations:
The following operations are exported from the DUIM-Extended-Geometry module.
The following operations are exported from the DUIM-Geometry module.
- See also:
- polygon? Generic function¶
Returns
#t
if its argument is a polygon.
- polygon-coordinates Generic function¶
Returns a sequence of coordinate pairs that specify the segments in a polygon or a polyline.
- Signature:
polygon-coordinates polygon-or-polyline => coordinates
- Parameters:
polygon-or-polyline – An instance of type
type-union(<polygon>, <polyline>)
.
- Values:
coordinates – An instance of type
limited(<sequence>, of: <real>)
.
- Discussion:
Returns a sequence of coordinate pairs that specify the segments in polygon-or-polyline.
- See also:
- polygon-points Generic function¶
Returns a sequence of points that specify the segments in a polygon or a polyline.
- Signature:
polygon-points polygon-or-polyline => points
- Parameters:
polygon-or-polyline – An instance of type
type-union(<polygon>, <polyline>)
.
- Values:
points – An instance of type
limited(<sequence>, of: <point>)
- Discussion:
Returns a sequence of points that specify the segments in polygon-or-polyline.
- See also:
- <polyline> Abstract Instantiable Class¶
The protocol class that corresponds to a polyline.
- Superclasses:
- Init-Keywords:
coordinates – An instance of type
limited(<sequence>, of: <real>)
. Required.points – An instance of type
limited(<sequence>, of: <real>)
. Required.
- Discussion:
The protocol class that corresponds to a polyline.
A polyline can be described either in terms of the individual x and y coordinates that constitute its vertices, or by using composite points. If the former is used, then they can be specified at the time of creation using the coordinates: init-keyword, which is a sequence of real numbers, with x and y coordinates alternating within the sequence.
To describe a polyline in terms of composite point objects, use the points: init-keyword, which is a sequence of instances of
<point>
. You should be aware that using composite points may lead to a loss of performance.Exactly one of coordinates: and points: is required.
- Operations:
The following operations are exported from the DUIM-Extended-Geometry module.
The following operations are exported from the DUIM-Geometry module.
- See also:
- polyline? Generic function¶
Returns
#t
if an object is a polyline.
- polyline-closed? Generic function¶
Returns
#t
if the polyline is closed.- Signature:
polyline-closed? polyline => boolean
- Parameters:
polyline – An instance of type
<polyline>
.
- Values:
boolean – An instance of type
<boolean>
.
- Discussion:
Returns
#t
if the polyline polyline is closed, otherwise returns#f
. This function need be implemented only for polylines, not for polygons.- See also:
- <rectangle> Abstract Instantiable Class¶
The protocol class that corresponds to a rectangle.
- Superclasses:
- Init-Keywords:
- Discussion:
The protocol class that corresponds to a rectangle. This is a subclass of
<polygon>
.Rectangles whose edges are parallel to the coordinate axes are a special case of polygon that can be specified completely by four real numbers x1,y1,x2,y2). They are not closed under general affine transformations (although they are closed under rectilinear transformations).
- Operations:
The following operations are exported from the DUIM-Extended-Geometry module.
The following operations are exported from the DUIM-Geometry module.
- See also:
- rectangle? Generic function¶
Returns
#t
if the object is a rectangle.
- rectangle-edges Generic function¶
Returns the coordinates of the minimum and maximum of the rectangle.
- Signature:
rectangle-edges rectangle => x1 y1 x2 y2
- Parameters:
rectangle – An instance of type
<rectangle>
.
- Values:
- Discussion:
Returns the coordinates of the minimum x and y and maximum x and y of the rectangle rectangle as four values, min-x, min-y, max-x, and max-y.
The argument min-x represents the x coordinate of the top left of the rectangle.
The argument min-y represents the y coordinate of the top left of the rectangle.
The argument max-x represents the x coordinate of the bottom right of the rectangle.
The argument max-y represents the y coordinate of the bottom right of the rectangle.
- See also:
- rectangle-height Generic function¶
Returns height of the rectangle.
- Signature:
rectangle-height rectangle => height
- Parameters:
rectangle – An instance of type
<rectangle>
.
- Values:
height – An instance of type
<real>
.
- Discussion:
Returns the height of the rectangle, which is the difference between the maximum y and its minimum y.
- See also:
- rectangle-max-point Generic function¶
Returns the bottom right point of the rectangle.
- Signature:
rectangle-max-point rectangle => point
- Parameters:
rectangle – An instance of type
<rectangle>
.
- Values:
point – An instance of type
<point>
.
- Discussion:
Returns the bottom right point of the rectangle.
- See also:
- rectangle-max-position Generic function¶
Returns the x and y coordinates of the bottom right of the rectangle.
- Signature:
rectangle-max-position rectangle => x2 y2
- Parameters:
rectangle – An instance of type
<rectangle>
.
- Values:
- Discussion:
Returns the x and y coordinates of the bottom right of the rectangle.
- See also:
- rectangle-min-point Generic function¶
Returns the left top point of the rectangle.
- Signature:
rectangle-min-point rectangle => point
- Parameters:
rectangle – An instance of type
<rectangle>
.
- Values:
point – An instance of type
<point>
.
- Discussion:
Returns the left top point of the rectangle.
- See also:
- rectangle-min-position Generic function¶
Returns the x and y coordinates of the left top of the rectangle.
- Signature:
rectangle-min-position rectangle => x1 y1
- Parameters:
rectangle – An instance of type
<rectangle>
.
- Values:
- Discussion:
Returns the x and y coordinates of the left top of the rectangle.
- See also:
- rectangle-size Generic function¶
Returns the width and the height of the rectangle.
- Signature:
rectangle-size rectangle => width height
- Parameters:
rectangle – An instance of type
<rectangle>
.
- Values:
- Discussion:
Returns two values, the width and the height.
- See also:
- rectangle-width Generic function¶
Returns the width of the rectangle.
- Signature:
rectangle-width rectangle => width
- Parameters:
rectangle – An instance of type
<rectangle>
.
- Values:
width – An instance of type
<real>
.
- Discussion:
Returns the width of the rectangle rectangle, which is the difference between the maximum x and its minimum x.
- See also: