Tcl Library Source Code

Documentation
Login


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

math::geometry - Geometrical computations

Table Of Contents

SYNOPSIS

package require Tcl ?8.5 9?
package require math::geometry ?1.4.2?

::math::geometry::+ point1 point2
::math::geometry::- point1 point2
::math::geometry::p x y
::math::geometry::distance point1 point2
::math::geometry::length point
::math::geometry::s* factor point
::math::geometry::direction angle
::math::geometry::h length
::math::geometry::v length
::math::geometry::between point1 point2 s
::math::geometry::octant point
::math::geometry::rect nw se
::math::geometry::nwse rect
::math::geometry::angle line
::math::geometry::angleBetween vector1 vector2
::math::geometry::inproduct vector1 vector2
::math::geometry::areaParallellogram vector1 vector2
::math::geometry::calculateDistanceToLine P line
::math::geometry::calculateDistanceToLineSegment P linesegment
::math::geometry::calculateDistanceToPolyline P polyline
::math::geometry::calculateDistanceToPolygon P polygon
::math::geometry::findClosestPointOnLine P line
::math::geometry::findClosestPointOnLineSegment P linesegment
::math::geometry::findClosestPointOnPolyline P polyline
::math::geometry::lengthOfPolyline polyline
::math::geometry::movePointInDirection P direction dist
::math::geometry::lineSegmentsIntersect linesegment1 linesegment2
::math::geometry::findLineSegmentIntersection linesegment1 linesegment2
::math::geometry::findLineIntersection line1 line2
::math::geometry::polylinesIntersect polyline1 polyline2
::math::geometry::polylinesBoundingIntersect polyline1 polyline2 granularity
::math::geometry::intervalsOverlap y1 y2 y3 y4 strict
::math::geometry::rectanglesOverlap P1 P2 Q1 Q2 strict
::math::geometry::bbox polyline
::math::geometry::overlapBBox polyline1 polyline2 ?strict?
::math::geometry::pointInsideBBox bbox point
::math::geometry::cathetusPoint pa pb cathetusLength ?location?
::math::geometry::parallel line offset ?orient?
::math::geometry::unitVector line
::math::geometry::pointInsidePolygon P polyline
::math::geometry::pointInsidePolygonAlt P polyline
::math::geometry::rectangleInsidePolygon P1 P2 polyline
::math::geometry::areaPolygon polygon
::math::geometry::translate vector polyline
::math::geometry::rotate angle polyline
::math::geometry::rotateAbout p angle polyline
::math::geometry::reflect angle polyline
::math::geometry::degToRad angle
::math::geometry::radToDeg angle
::math::geometry::circle centre radius
::math::geometry::circleTwoPoints point1 point2
::math::geometry::pointInsideCircle point circle
::math::geometry::lineIntersectsCircle line circle
::math::geometry::lineSegmentIntersectsCircle segment circle
::math::geometry::intersectionLineWithCircle line circle
::math::geometry::intersectionCircleWithCircle circle1 circle2
::math::geometry::tangentLinesToCircle point circle
::math::geometry::intersectionPolylines polyline1 polyline2 ?mode? ?granularity?
::math::geometry::intersectionPolylineCircle polyline circle ?mode? ?granularity?
::math::geometry::polylineCutOrigin polyline1 polyline2 ?granularity?
::math::geometry::polylineCutEnd polyline1 polyline2 ?granularity?
::math::geometry::splitPolyline polyline numberVertex
::math::geometry::enrichPolyline polyline accuracy
::math::geometry::cleanupPolyline polyline

DESCRIPTION

The math::geometry package is a collection of functions for computations and manipulations on two-dimensional geometrical objects, such as points, lines and polygons.

The geometrical objects are implemented as plain lists of coordinates. For instance a line is defined by a list of four numbers, the x- and y-coordinate of a first point and the x- and y-coordinates of a second point on the line.

Note: In version 1.4.0 an inconsistency was repaired - see https://core.tcl-lang.org/tcllib/tktview?name=fb4812f82b. More in COORDINATE SYSTEM

The various types of object are recognised by the number of coordinate pairs and the context in which they are used: a list of four elements can be regarded as an infinite line, a finite line segment but also as a polyline of one segment and a point set of two points.

Currently the following types of objects are distinguished:

PROCEDURES

The package defines the following public procedures:

COORDINATE SYSTEM

The coordinate system used by the package is the ordinary cartesian system, where the positive x-axis is directed to the right and the positive y-axis is directed upwards. Angles and directions are defined with respect to the positive x-axis in a counter-clockwise direction, so that an angle of 90 degrees is the direction of the positive y-axis. Note that the Tk canvas coordinates differ from this, as there the origin is located in the upper left corner of the window. Up to and including version 1.3, the direction and octant procedures of this package used this convention inconsistently.

References

  1. Polygon Intersection

  2. http://en.wikipedia.org/wiki/Line-line_intersection

  3. http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math :: geometry of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.

KEYWORDS

angle, distance, line, math, plane geometry, point

CATEGORY

Mathematics

COPYRIGHT

Copyright © 2001 by Ideogramic ApS and other parties
Copyright © 2010 by Andreas Kupries
Copyright © 2010 by Kevin Kenny
Copyright © 2018 by Arjen Markus
Copyright © 2020 by Manfred Rosenberger