1math::geometry(n)              Tcl Math Library              math::geometry(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       math::geometry - Geometrical computations
9

SYNOPSIS

11       package require Tcl  ?8.3?
12
13       package require math::geometry  ?1.0.3?
14
15       ::math::geometry::angle line
16
17       ::math::geometry::calculateDistanceToLine P line
18
19       ::math::geometry::calculateDistanceToLineSegment P linesegment
20
21       ::math::geometry::calculateDistanceToPolyline P polyline
22
23       ::math::geometry::findClosestPointOnLine P line
24
25       ::math::geometry::findClosestPointOnLineSegment P linesegment
26
27       ::math::geometry::findClosestPointOnPolyline P polyline
28
29       ::math::geometry::lengthOfPolyline polyline
30
31       ::math::geometry::movePointInDirection P direction dist
32
33       ::math::geometry::lineSegmentsIntersect linesegment1 linesegment2
34
35       ::math::geometry::findLineSegmentIntersection linesegment1 linesegment2
36
37       ::math::geometry::findLineIntersection line1 line2
38
39       ::math::geometry::polylinesIntersect polyline1 polyline2
40
41       ::math::geometry::polylinesBoundingIntersect polyline1 polyline2 granu‐
42       larity
43
44       ::math::geometry::intervalsOverlap y1 y2 y3 y4 strict
45
46       ::math::geometry::rectanglesOverlap P1 P2 Q1 Q2 strict
47
48       ::math::geometry::bbox polyline
49
50       ::math::geometry::pointInsidePolygon P polyline
51
52       ::math::geometry::rectangleInsidePolygon P1 P2 polyline
53
54       ::math::geometry::areaPolygon polygon
55
56_________________________________________________________________
57

DESCRIPTION

59       The math::geometry package is a collection of  functions  for  computa‐
60       tions and manipulations on two-dimensional geometrical objects, such as
61       points, lines and polygons.
62
63       The geometrical objects are implemented as plain lists of  coordinates.
64       For instance a line is defined by a list of four numbers, the x- and y-
65       coordinate of a first point and the x- and y-coordinates  of  a  second
66       point on the line.
67
68       The  various types of object are recognised by the number of coordinate
69       pairs and the context in which they are used: a list of  four  elements
70       can  be regarded as an infinite line, a finite line segment but also as
71       a polyline of one segment and a point set of two points.
72
73       Currently the following types of objects are distinguished:
74
75       ·      point - a list of two coordinates representing  the  x-  and  y-
76              coordinates respectively.
77
78       ·      line  - a list of four coordinates, interpreted as the x- and y-
79              coordinates of two distinct points on the line.
80
81       ·      line segment - a list of four coordinates, interpreted as the x-
82              and  y-coordinates  of the first and the last points on the line
83              segment.
84
85       ·      polyline - a list of an even number of coordinates,  interpreted
86              as the x- and y-coordinates of an ordered set of points.
87
88       ·      polygon  -  like a polyline, but the implicit assumption is that
89              the polyline is closed (if the first  and  last  points  do  not
90              coincide, the missing segment is automatically added).
91
92       ·      point  set  - again a list of an even number of coordinates, but
93              the points are regarded without any ordering.
94

PROCEDURES

96       The package defines the following public procedures:
97
98       ::math::geometry::angle line
99              Calculate the angle from the positive x-axis to a given line (in
100              two dimensions only).
101
102              list line
103                     Coordinates of the line
104
105
106       ::math::geometry::calculateDistanceToLine P line
107              Calculate  the  distance  of  point P to the (infinite) line and
108              return the result
109
110              list P List of two numbers, the coordinates of the point
111
112              list line
113                     List of four numbers, the coordinates of  two  points  on
114                     the line
115
116
117       ::math::geometry::calculateDistanceToLineSegment P linesegment
118              Calculate  the  distance of point P to the (finite) line segment
119              and return the result.
120
121              list P List of two numbers, the coordinates of the point
122
123              list linesegment
124                     List of four numbers, the coordinates of  the  first  and
125                     last points of the line segment
126
127
128
129       ::math::geometry::calculateDistanceToPolyline P polyline
130              Calculate the distance of point P to the polyline and return the
131              result.
132
133              list P List of two numbers, the coordinates of the point
134
135              list polyline
136                     List of numbers, the coordinates of the vertices  of  the
137                     polyline
138
139
140       ::math::geometry::findClosestPointOnLine P line
141              Return the point on a line which is closest to a given point.
142
143              list P List of two numbers, the coordinates of the point
144
145              list line
146                     List  of  four  numbers, the coordinates of two points on
147                     the line
148
149
150       ::math::geometry::findClosestPointOnLineSegment P linesegment
151              Return the point on a line segment which is closest to  a  given
152              point.
153
154              list P List of two numbers, the coordinates of the point
155
156              list linesegment
157                     List  of  four  numbers, the first and last points on the
158                     line segment
159
160
161       ::math::geometry::findClosestPointOnPolyline P polyline
162              Return the point on a polyline  which  is  closest  to  a  given
163              point.
164
165              list P List of two numbers, the coordinates of the point
166
167              list polyline
168                     List of numbers, the vertices of the polyline
169
170
171       ::math::geometry::lengthOfPolyline polyline
172              Return  the  length  of the polyline (note: it not regarded as a
173              polygon)
174
175              list polyline
176                     List of numbers, the vertices of the polyline
177
178
179       ::math::geometry::movePointInDirection P direction dist
180              Move a point over a given distance  in  a  given  direction  and
181              return the new coordinates (in two dimensions only).
182
183              list P Coordinates of the point to be moved
184
185              double direction
186                     Direction (in degrees; 0 is to the right, 90 upwards)
187
188              list dist
189                     Distance over which to move the point
190
191
192       ::math::geometry::lineSegmentsIntersect linesegment1 linesegment2
193              Check  if  two line segments intersect or coincide. Returns 1 if
194              that is the case, 0 otherwise (in two dimensions only).
195
196              list linesegment1
197                     First line segment
198
199              list linesegment2
200                     Second line segment
201
202
203       ::math::geometry::findLineSegmentIntersection linesegment1 linesegment2
204              Find the intersection point of two  line  segments.  Return  the
205              coordinates  or  the keywords "coincident" or "none" if the line
206              segments coincide or have no points in common (in two dimensions
207              only).
208
209              list linesegment1
210                     First line segment
211
212              list linesegment2
213                     Second line segment
214
215
216       ::math::geometry::findLineIntersection line1 line2
217              Find  the intersection point of two (infinite) lines. Return the
218              coordinates or the keywords "coincident" or "none" if the  lines
219              coincide or have no points in common (in two dimensions only).
220
221              list line1
222                     First line
223
224              list line2
225                     Second line
226
227
228       ::math::geometry::polylinesIntersect polyline1 polyline2
229              Check  if  two  polylines  intersect  or  not (in two dimensions
230              only).
231
232              list polyline1
233                     First polyline
234
235              list polyline2
236                     Second polyline
237
238
239       ::math::geometry::polylinesBoundingIntersect polyline1 polyline2 granu‐
240       larity
241              Check  whether  two polylines intersect, but reduce the correct‐
242              ness of the result to  the  given  granularity.   Use  this  for
243              faster, but weaker, intersection checking.
244
245              How it works:
246
247              Each  polyline is split into a number of smaller polylines, con‐
248              sisting of granularity points each. If a pair of  those  smaller
249              lines'  bounding boxes intersect, then this procedure returns 1,
250              otherwise it returns 0.
251
252              list polyline1
253                     First polyline
254
255              list polyline2
256                     Second polyline
257
258              int granularity
259                     Number of points in each  part  (<=1  means  check  every
260                     edge)
261
262
263       ::math::geometry::intervalsOverlap y1 y2 y3 y4 strict
264              Check if two intervals overlap.
265
266              double y1,y2
267                     Begin and end of first interval
268
269              double y3,y4
270                     Begin and end of second interval
271
272              logical strict
273                     Check for strict or non-strict overlap
274
275
276       ::math::geometry::rectanglesOverlap P1 P2 Q1 Q2 strict
277              Check if two rectangles overlap.
278
279              list P1
280                     upper-left corner of the first rectangle
281
282              list P2
283                     lower-right corner of the first rectangle
284
285              list Q1
286                     upper-left corner of the second rectangle
287
288              list Q2
289                     lower-right corner of the second rectangle
290
291              list strict
292                     choosing strict or non-strict interpretation
293
294
295       ::math::geometry::bbox polyline
296              Calculate the bounding box of a polyline. Returns a list of four
297              coordinates: the upper-left and the lower-right  corner  of  the
298              box.
299
300              list polyline
301                     The polyline to be examined
302
303
304       ::math::geometry::pointInsidePolygon P polyline
305              Determine  if  a  point  is  completely inside a polygon. If the
306              point touches the polygon, then  the  point  is  not  completely
307              inside the polygon.
308
309              list P Coordinates of the point
310
311              list polyline
312                     The polyline to be examined
313
314
315       ::math::geometry::rectangleInsidePolygon P1 P2 polyline
316              Determine  if  a  rectangle  is  completely inside a polygon. If
317              polygon touches the rectangle, then the rectangle  is  not  com‐
318              plete inside the polygon.
319
320              list P1
321                     Upper-left corner of the rectangle
322
323              list P2
324                     Lower-right corner of the rectangle
325
326
327              list polygon
328                     The polygon in question
329
330
331       ::math::geometry::areaPolygon polygon
332              Calculate the area of a polygon.
333
334              list polygon
335                     The polygon in question
336

BUGS, IDEAS, FEEDBACK

338       This  document,  and the package it describes, will undoubtedly contain
339       bugs and other problems.  Please report such in the  category  math  ::
340       geometry     of     the     Tcllib    SF    Trackers    [http://source
341       forge.net/tracker/?group_id=12883].  Please also report any  ideas  for
342       enhancements you may have for either package and/or documentation.
343

KEYWORDS

345       angle, distance, line, math, plane geometry, point
346
348       Copyright (c) 2004 by Ideogramic ApS and other parties
349
350
351
352
353math                                 1.0.3                   math::geometry(n)
Impressum