1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273
|
'\"
'\" Generated from file 'math_geometry\&.man' by tcllib/doctools with format 'nroff'
'\" Copyright (c) 2001 by Ideogramic ApS and other parties
'\" Copyright (c) 2010 by Andreas Kupries
'\" Copyright (c) 2010 by Kevin Kenny
'\" Copyright (c) 2018 by Arjen Markus
'\" Copyright (c) 2020 by Manfred Rosenberger
'\"
.TH "math::geometry" n 1\&.4\&.2 tcllib "Tcl Math Library"
.\" The -*- nroff -*- definitions below are for supplemental macros used
.\" in Tcl/Tk manual entries.
.\"
.\" .AP type name in/out ?indent?
.\" Start paragraph describing an argument to a library procedure.
.\" type is type of argument (int, etc.), in/out is either "in", "out",
.\" or "in/out" to describe whether procedure reads or modifies arg,
.\" and indent is equivalent to second arg of .IP (shouldn't ever be
.\" needed; use .AS below instead)
.\"
.\" .AS ?type? ?name?
.\" Give maximum sizes of arguments for setting tab stops. Type and
.\" name are examples of largest possible arguments that will be passed
.\" to .AP later. If args are omitted, default tab stops are used.
.\"
.\" .BS
.\" Start box enclosure. From here until next .BE, everything will be
.\" enclosed in one large box.
.\"
.\" .BE
.\" End of box enclosure.
.\"
.\" .CS
.\" Begin code excerpt.
.\"
.\" .CE
.\" End code excerpt.
.\"
.\" .VS ?version? ?br?
.\" Begin vertical sidebar, for use in marking newly-changed parts
.\" of man pages. The first argument is ignored and used for recording
.\" the version when the .VS was added, so that the sidebars can be
.\" found and removed when they reach a certain age. If another argument
.\" is present, then a line break is forced before starting the sidebar.
.\"
.\" .VE
.\" End of vertical sidebar.
.\"
.\" .DS
.\" Begin an indented unfilled display.
.\"
.\" .DE
.\" End of indented unfilled display.
.\"
.\" .SO ?manpage?
.\" Start of list of standard options for a Tk widget. The manpage
.\" argument defines where to look up the standard options; if
.\" omitted, defaults to "options". The options follow on successive
.\" lines, in three columns separated by tabs.
.\"
.\" .SE
.\" End of list of standard options for a Tk widget.
.\"
.\" .OP cmdName dbName dbClass
.\" Start of description of a specific option. cmdName gives the
.\" option's name as specified in the class command, dbName gives
.\" the option's name in the option database, and dbClass gives
.\" the option's class in the option database.
.\"
.\" .UL arg1 arg2
.\" Print arg1 underlined, then print arg2 normally.
.\"
.\" .QW arg1 ?arg2?
.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation).
.\"
.\" .PQ arg1 ?arg2?
.\" Print an open parenthesis, arg1 in quotes, then arg2 normally
.\" (for trailing punctuation) and then a closing parenthesis.
.\"
.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
.nr ^l \n(.l
.ad b
.\" # Start an argument description
.de AP
.ie !"\\$4"" .TP \\$4
.el \{\
. ie !"\\$2"" .TP \\n()Cu
. el .TP 15
.\}
.ta \\n()Au \\n()Bu
.ie !"\\$3"" \{\
\&\\$1 \\fI\\$2\\fP (\\$3)
.\".b
.\}
.el \{\
.br
.ie !"\\$2"" \{\
\&\\$1 \\fI\\$2\\fP
.\}
.el \{\
\&\\fI\\$1\\fP
.\}
.\}
..
.\" # define tabbing values for .AP
.de AS
.nr )A 10n
.if !"\\$1"" .nr )A \\w'\\$1'u+3n
.nr )B \\n()Au+15n
.\"
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
.nr )C \\n()Bu+\\w'(in/out)'u+2n
..
.AS Tcl_Interp Tcl_CreateInterp in/out
.\" # BS - start boxed text
.\" # ^y = starting y location
.\" # ^b = 1
.de BS
.br
.mk ^y
.nr ^b 1u
.if n .nf
.if n .ti 0
.if n \l'\\n(.lu\(ul'
.if n .fi
..
.\" # BE - end boxed text (draw box now)
.de BE
.nf
.ti 0
.mk ^t
.ie n \l'\\n(^lu\(ul'
.el \{\
.\" Draw four-sided box normally, but don't draw top of
.\" box if the box started on an earlier page.
.ie !\\n(^b-1 \{\
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.el \}\
\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.\}
.fi
.br
.nr ^b 0
..
.\" # VS - start vertical sidebar
.\" # ^Y = starting y location
.\" # ^v = 1 (for troff; for nroff this doesn't matter)
.de VS
.if !"\\$2"" .br
.mk ^Y
.ie n 'mc \s12\(br\s0
.el .nr ^v 1u
..
.\" # VE - end of vertical sidebar
.de VE
.ie n 'mc
.el \{\
.ev 2
.nf
.ti 0
.mk ^t
\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
.sp -1
.fi
.ev
.\}
.nr ^v 0
..
.\" # Special macro to handle page bottom: finish off current
.\" # box/sidebar if in box/sidebar mode, then invoked standard
.\" # page bottom macro.
.de ^B
.ev 2
'ti 0
'nf
.mk ^t
.if \\n(^b \{\
.\" Draw three-sided box if this is the box's first page,
.\" draw two sides but no top otherwise.
.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.\}
.if \\n(^v \{\
.nr ^x \\n(^tu+1v-\\n(^Yu
\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
.\}
.bp
'fi
.ev
.if \\n(^b \{\
.mk ^y
.nr ^b 2
.\}
.if \\n(^v \{\
.mk ^Y
.\}
..
.\" # DS - begin display
.de DS
.RS
.nf
.sp
..
.\" # DE - end display
.de DE
.fi
.RE
.sp
..
.\" # SO - start of list of standard options
.de SO
'ie '\\$1'' .ds So \\fBoptions\\fR
'el .ds So \\fB\\$1\\fR
.SH "STANDARD OPTIONS"
.LP
.nf
.ta 5.5c 11c
.ft B
..
.\" # SE - end of list of standard options
.de SE
.fi
.ft R
.LP
See the \\*(So manual entry for details on the standard options.
..
.\" # OP - start of full description for a single option
.de OP
.LP
.nf
.ta 4c
Command-Line Name: \\fB\\$1\\fR
Database Name: \\fB\\$2\\fR
Database Class: \\fB\\$3\\fR
.fi
.IP
..
.\" # CS - begin code excerpt
.de CS
.RS
.nf
.ta .25i .5i .75i 1i
..
.\" # CE - end code excerpt
.de CE
.fi
.RE
..
.\" # UL - underline word
.de UL
\\$1\l'|0\(ul'\\$2
..
.\" # QW - apply quotation marks to word
.de QW
.ie '\\*(lq'"' ``\\$1''\\$2
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\$2
..
.\" # PQ - apply parens and quotation marks to word
.de PQ
.ie '\\*(lq'"' (``\\$1''\\$2)\\$3
.\"" fix emacs highlighting
.el (\\*(lq\\$1\\*(rq\\$2)\\$3
..
.\" # QR - quoted range
.de QR
.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
..
.\" # MT - "empty" string
.de MT
.QW ""
..
.BS
.SH NAME
math::geometry \- Geometrical computations
.SH SYNOPSIS
package require \fBTcl ?8\&.5 9?\fR
.sp
package require \fBmath::geometry ?1\&.4\&.2?\fR
.sp
\fB::math::geometry::+\fR \fIpoint1\fR \fIpoint2\fR
.sp
\fB::math::geometry::-\fR \fIpoint1\fR \fIpoint2\fR
.sp
\fB::math::geometry::p\fR \fIx\fR \fIy\fR
.sp
\fB::math::geometry::distance\fR \fIpoint1\fR \fIpoint2\fR
.sp
\fB::math::geometry::length\fR \fIpoint\fR
.sp
\fB::math::geometry::s*\fR \fIfactor\fR \fIpoint\fR
.sp
\fB::math::geometry::direction\fR \fIangle\fR
.sp
\fB::math::geometry::h\fR \fIlength\fR
.sp
\fB::math::geometry::v\fR \fIlength\fR
.sp
\fB::math::geometry::between\fR \fIpoint1\fR \fIpoint2\fR \fIs\fR
.sp
\fB::math::geometry::octant\fR \fIpoint\fR
.sp
\fB::math::geometry::rect\fR \fInw\fR \fIse\fR
.sp
\fB::math::geometry::nwse\fR \fIrect\fR
.sp
\fB::math::geometry::angle\fR \fIline\fR
.sp
\fB::math::geometry::angleBetween\fR \fIvector1\fR \fIvector2\fR
.sp
\fB::math::geometry::inproduct\fR \fIvector1\fR \fIvector2\fR
.sp
\fB::math::geometry::areaParallellogram\fR \fIvector1\fR \fIvector2\fR
.sp
\fB::math::geometry::calculateDistanceToLine\fR \fIP\fR \fIline\fR
.sp
\fB::math::geometry::calculateDistanceToLineSegment\fR \fIP\fR \fIlinesegment\fR
.sp
\fB::math::geometry::calculateDistanceToPolyline\fR \fIP\fR \fIpolyline\fR
.sp
\fB::math::geometry::calculateDistanceToPolygon\fR \fIP\fR \fIpolygon\fR
.sp
\fB::math::geometry::findClosestPointOnLine\fR \fIP\fR \fIline\fR
.sp
\fB::math::geometry::findClosestPointOnLineSegment\fR \fIP\fR \fIlinesegment\fR
.sp
\fB::math::geometry::findClosestPointOnPolyline\fR \fIP\fR \fIpolyline\fR
.sp
\fB::math::geometry::lengthOfPolyline\fR \fIpolyline\fR
.sp
\fB::math::geometry::movePointInDirection\fR \fIP\fR \fIdirection\fR \fIdist\fR
.sp
\fB::math::geometry::lineSegmentsIntersect\fR \fIlinesegment1\fR \fIlinesegment2\fR
.sp
\fB::math::geometry::findLineSegmentIntersection\fR \fIlinesegment1\fR \fIlinesegment2\fR
.sp
\fB::math::geometry::findLineIntersection\fR \fIline1\fR \fIline2\fR
.sp
\fB::math::geometry::polylinesIntersect\fR \fIpolyline1\fR \fIpolyline2\fR
.sp
\fB::math::geometry::polylinesBoundingIntersect\fR \fIpolyline1\fR \fIpolyline2\fR \fIgranularity\fR
.sp
\fB::math::geometry::intervalsOverlap\fR \fIy1\fR \fIy2\fR \fIy3\fR \fIy4\fR \fIstrict\fR
.sp
\fB::math::geometry::rectanglesOverlap\fR \fIP1\fR \fIP2\fR \fIQ1\fR \fIQ2\fR \fIstrict\fR
.sp
\fB::math::geometry::bbox\fR \fIpolyline\fR
.sp
\fB::math::geometry::overlapBBox\fR \fIpolyline1\fR \fIpolyline2\fR ?strict?
.sp
\fB::math::geometry::pointInsideBBox\fR \fIbbox\fR \fIpoint\fR
.sp
\fB::math::geometry::cathetusPoint\fR \fIpa\fR \fIpb\fR \fIcathetusLength\fR ?location?
.sp
\fB::math::geometry::parallel\fR \fIline\fR \fIoffset\fR ?orient?
.sp
\fB::math::geometry::unitVector\fR \fIline\fR
.sp
\fB::math::geometry::pointInsidePolygon\fR \fIP\fR \fIpolyline\fR
.sp
\fB::math::geometry::pointInsidePolygonAlt\fR \fIP\fR \fIpolyline\fR
.sp
\fB::math::geometry::rectangleInsidePolygon\fR \fIP1\fR \fIP2\fR \fIpolyline\fR
.sp
\fB::math::geometry::areaPolygon\fR \fIpolygon\fR
.sp
\fB::math::geometry::translate\fR \fIvector\fR \fIpolyline\fR
.sp
\fB::math::geometry::rotate\fR \fIangle\fR \fIpolyline\fR
.sp
\fB::math::geometry::rotateAbout\fR \fIp\fR \fIangle\fR \fIpolyline\fR
.sp
\fB::math::geometry::reflect\fR \fIangle\fR \fIpolyline\fR
.sp
\fB::math::geometry::degToRad\fR \fIangle\fR
.sp
\fB::math::geometry::radToDeg\fR \fIangle\fR
.sp
\fB::math::geometry::circle\fR \fIcentre\fR \fIradius\fR
.sp
\fB::math::geometry::circleTwoPoints\fR \fIpoint1\fR \fIpoint2\fR
.sp
\fB::math::geometry::pointInsideCircle\fR \fIpoint\fR \fIcircle\fR
.sp
\fB::math::geometry::lineIntersectsCircle\fR \fIline\fR \fIcircle\fR
.sp
\fB::math::geometry::lineSegmentIntersectsCircle\fR \fIsegment\fR \fIcircle\fR
.sp
\fB::math::geometry::intersectionLineWithCircle\fR \fIline\fR \fIcircle\fR
.sp
\fB::math::geometry::intersectionCircleWithCircle\fR \fIcircle1\fR \fIcircle2\fR
.sp
\fB::math::geometry::tangentLinesToCircle\fR \fIpoint\fR \fIcircle\fR
.sp
\fB::math::geometry::intersectionPolylines\fR \fIpolyline1\fR \fIpolyline2\fR ?mode? ?granularity?
.sp
\fB::math::geometry::intersectionPolylineCircle\fR \fIpolyline\fR \fIcircle\fR ?mode? ?granularity?
.sp
\fB::math::geometry::polylineCutOrigin\fR \fIpolyline1\fR \fIpolyline2\fR ?granularity?
.sp
\fB::math::geometry::polylineCutEnd\fR \fIpolyline1\fR \fIpolyline2\fR ?granularity?
.sp
\fB::math::geometry::splitPolyline\fR \fIpolyline\fR \fInumberVertex\fR
.sp
\fB::math::geometry::enrichPolyline\fR \fIpolyline\fR \fIaccuracy\fR
.sp
\fB::math::geometry::cleanupPolyline\fR \fIpolyline\fR
.sp
.BE
.SH DESCRIPTION
.PP
The \fBmath::geometry\fR package is a collection of functions for
computations and manipulations on two-dimensional geometrical objects,
such as points, lines and polygons\&.
.PP
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\&.
.PP
\fINote:\fR In version 1\&.4\&.0 an inconsistency was repaired - see \fIhttps://core\&.tcl-lang\&.org/tcllib/tktview?name=fb4812f82b\fR\&.
More in \fBCOORDINATE SYSTEM\fR
.PP
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\&.
.PP
Currently the following types of objects are distinguished:
.IP \(bu
\fIpoint\fR - a list of two coordinates representing the x- and
y-coordinates respectively\&.
.IP \(bu
\fIline\fR - a list of four coordinates, interpreted as the x- and
y-coordinates of two distinct points on the line\&.
.IP \(bu
\fIline segment\fR - a list of four coordinates, interpreted as the
x- and y-coordinates of the first and the last points on the line
segment\&.
.IP \(bu
\fIpolyline\fR - a list of an even number of coordinates,
interpreted as the x- and y-coordinates of an ordered set of points\&.
.IP \(bu
\fIpolygon\fR - like a polyline, but the implicit assumption is that
the polyline is closed (if the first and last points do not coincide,
the missing segment is automatically added)\&.
.IP \(bu
\fIpoint set\fR - again a list of an even number of coordinates, but
the points are regarded without any ordering\&.
.IP \(bu
\fIcircle\fR - a list of three numbers, the first two are the coordinates of the
centre and the third is the radius\&.
.PP
.SH PROCEDURES
The package defines the following public procedures:
.TP
\fB::math::geometry::+\fR \fIpoint1\fR \fIpoint2\fR
Compute the sum of the two vectors given as points and return it\&.
The result is a vector as well\&.
.TP
\fB::math::geometry::-\fR \fIpoint1\fR \fIpoint2\fR
Compute the difference (point1 - point2) of the two vectors
given as points and return it\&. The result is a vector as well\&.
.TP
\fB::math::geometry::p\fR \fIx\fR \fIy\fR
Construct a point from its coordinates and return it as the
result of the command\&.
.TP
\fB::math::geometry::distance\fR \fIpoint1\fR \fIpoint2\fR
Compute the distance between the two points and return it as the
result of the command\&. This is in essence the same as
.CS
math::geometry::length [math::geomtry::- point1 point2]
.CE
.TP
\fB::math::geometry::length\fR \fIpoint\fR
Compute the length of the vector and return it as the
result of the command\&.
.TP
\fB::math::geometry::s*\fR \fIfactor\fR \fIpoint\fR
Scale the vector by the factor and return it as the
result of the command\&. This is a vector as well\&.
.TP
\fB::math::geometry::direction\fR \fIangle\fR
Given the angle in degrees this command computes and returns
the unit vector pointing into this direction\&. The vector for
angle == 0 points to the right (east), and for angle == 90 up (north)\&.
.TP
\fB::math::geometry::h\fR \fIlength\fR
Returns a horizontal vector on the X-axis of the specified length\&.
Positive lengths point to the right (east)\&.
.TP
\fB::math::geometry::v\fR \fIlength\fR
Returns a vertical vector on the Y-axis of the specified length\&.
Positive lengths point down (south)\&.
.TP
\fB::math::geometry::between\fR \fIpoint1\fR \fIpoint2\fR \fIs\fR
Compute the point which is at relative distance \fIs\fR between the two
points and return it as the result of the command\&. A relative distance of
\fB0\fR returns \fIpoint1\fR, the distance \fB1\fR returns \fIpoint2\fR\&.
Distances < 0 or > 1 extrapolate along the line between the two point\&.
.TP
\fB::math::geometry::octant\fR \fIpoint\fR
Compute the octant of the circle the point is in and return it as the result
of the command\&. The possible results are
.RS
.IP [1]
east
.IP [2]
northeast
.IP [3]
north
.IP [4]
northwest
.IP [5]
west
.IP [6]
southwest
.IP [7]
south
.IP [8]
southeast
.RE
.IP
Each octant is the arc of the circle +/- 22\&.5 degrees from the cardinal direction
the octant is named for\&.
.TP
\fB::math::geometry::rect\fR \fInw\fR \fIse\fR
Construct a rectangle from its northwest and southeast corners and return
it as the result of the command\&.
.TP
\fB::math::geometry::nwse\fR \fIrect\fR
Extract the northwest and southeast corners of the rectangle and return
them as the result of the command (a 2-element list containing the
points, in the named order)\&.
.TP
\fB::math::geometry::angle\fR \fIline\fR
Calculate the angle from the positive x-axis to a given line
(in two dimensions only)\&.
.RS
.TP
list \fIline\fR
Coordinates of the line
.RE
.TP
\fB::math::geometry::angleBetween\fR \fIvector1\fR \fIvector2\fR
Calculate the angle between two vectors (in degrees)
.RS
.TP
list \fIvector1\fR
First vector
.TP
list \fIvector2\fR
Second vector
.RE
.TP
\fB::math::geometry::inproduct\fR \fIvector1\fR \fIvector2\fR
Calculate the inner product of two vectors
.RS
.TP
list \fIvector1\fR
First vector
.TP
list \fIvector2\fR
Second vector
.RE
.TP
\fB::math::geometry::areaParallellogram\fR \fIvector1\fR \fIvector2\fR
Calculate the area of the parallellogram with the two vectors as its sides
.RS
.TP
list \fIvector1\fR
First vector
.TP
list \fIvector2\fR
Second vector
.RE
.TP
\fB::math::geometry::calculateDistanceToLine\fR \fIP\fR \fIline\fR
Calculate the distance of point P to the (infinite) line and return the
result
.RS
.TP
list \fIP\fR
List of two numbers, the coordinates of the point
.TP
list \fIline\fR
List of four numbers, the coordinates of two points
on the line
.RE
.TP
\fB::math::geometry::calculateDistanceToLineSegment\fR \fIP\fR \fIlinesegment\fR
Calculate the distance of point P to the (finite) line segment and
return the result\&.
.RS
.TP
list \fIP\fR
List of two numbers, the coordinates of the point
.TP
list \fIlinesegment\fR
List of four numbers, the coordinates of the
first and last points of the line segment
.RE
.TP
\fB::math::geometry::calculateDistanceToPolyline\fR \fIP\fR \fIpolyline\fR
Calculate the distance of point P to the polyline and
return the result\&. Note that a polyline needs not to be closed\&.
.RS
.TP
list \fIP\fR
List of two numbers, the coordinates of the point
.TP
list \fIpolyline\fR
List of numbers, the coordinates of the
vertices of the polyline
.RE
.TP
\fB::math::geometry::calculateDistanceToPolygon\fR \fIP\fR \fIpolygon\fR
Calculate the distance of point P to the polygon and
return the result\&. If the list of coordinates is not closed (first and last
points differ), it is automatically closed\&.
.RS
.TP
list \fIP\fR
List of two numbers, the coordinates of the point
.TP
list \fIpolygon\fR
List of numbers, the coordinates of the
vertices of the polygon
.RE
.TP
\fB::math::geometry::findClosestPointOnLine\fR \fIP\fR \fIline\fR
Return the point on a line which is closest to a given point\&.
.RS
.TP
list \fIP\fR
List of two numbers, the coordinates of the point
.TP
list \fIline\fR
List of four numbers, the coordinates of two points
on the line
.RE
.TP
\fB::math::geometry::findClosestPointOnLineSegment\fR \fIP\fR \fIlinesegment\fR
Return the point on a \fIline segment\fR which is closest to a given
point\&.
.RS
.TP
list \fIP\fR
List of two numbers, the coordinates of the point
.TP
list \fIlinesegment\fR
List of four numbers, the first and last
points on the line segment
.RE
.TP
\fB::math::geometry::findClosestPointOnPolyline\fR \fIP\fR \fIpolyline\fR
Return the point on a \fIpolyline\fR which is closest to a given
point\&.
.RS
.TP
list \fIP\fR
List of two numbers, the coordinates of the point
.TP
list \fIpolyline\fR
List of numbers, the vertices of the polyline
.RE
.TP
\fB::math::geometry::lengthOfPolyline\fR \fIpolyline\fR
Return the length of the \fIpolyline\fR (note: it not regarded as a
polygon)
.RS
.TP
list \fIpolyline\fR
List of numbers, the vertices of the polyline
.RE
.TP
\fB::math::geometry::movePointInDirection\fR \fIP\fR \fIdirection\fR \fIdist\fR
Move a point over a given distance in a given direction and return the
new coordinates (in two dimensions only)\&.
.RS
.TP
list \fIP\fR
Coordinates of the point to be moved
.TP
double \fIdirection\fR
Direction (in degrees; 0 is to the right, 90
upwards)
.TP
list \fIdist\fR
Distance over which to move the point
.RE
.TP
\fB::math::geometry::lineSegmentsIntersect\fR \fIlinesegment1\fR \fIlinesegment2\fR
Check if two line segments intersect or coincide\&. Returns 1 if that is
the case, 0 otherwise (in two dimensions only)\&. If an endpoint of one segment lies on
the other segment (or is very close to the segment), they are considered to intersect
.RS
.TP
list \fIlinesegment1\fR
First line segment
.TP
list \fIlinesegment2\fR
Second line segment
.RE
.TP
\fB::math::geometry::findLineSegmentIntersection\fR \fIlinesegment1\fR \fIlinesegment2\fR
Find the intersection point of two line segments\&. Return the coordinates
or the keywords "coincident" or "none" if the line segments coincide or
have no points in common (in two dimensions only)\&.
.RS
.TP
list \fIlinesegment1\fR
First line segment
.TP
list \fIlinesegment2\fR
Second line segment
.RE
.TP
\fB::math::geometry::findLineIntersection\fR \fIline1\fR \fIline2\fR
Find the intersection point of two (infinite) lines\&. Return the coordinates
or the keywords "coincident" or "none" if the lines coincide or
have no points in common (in two dimensions only)\&.
.RS
.TP
list \fIline1\fR
First line
.TP
list \fIline2\fR
Second line
.RE
.IP
See section \fBReferences\fR for details on the algorithm and math behind it\&.
.TP
\fB::math::geometry::polylinesIntersect\fR \fIpolyline1\fR \fIpolyline2\fR
Check if two polylines intersect or not (in two dimensions only)\&.
.RS
.TP
list \fIpolyline1\fR
First polyline
.TP
list \fIpolyline2\fR
Second polyline
.RE
.TP
\fB::math::geometry::polylinesBoundingIntersect\fR \fIpolyline1\fR \fIpolyline2\fR \fIgranularity\fR
Check whether two polylines intersect, but reduce
the correctness of the result to the given granularity\&.
Use this for faster, but weaker, intersection checking\&.
.sp
How it works:
.sp
Each polyline is split into a number of smaller polylines,
consisting of granularity points each\&. If a pair of those smaller
lines' bounding boxes intersect, then this procedure returns 1,
otherwise it returns 0\&.
.RS
.TP
list \fIpolyline1\fR
First polyline
.TP
list \fIpolyline2\fR
Second polyline
.TP
int \fIgranularity\fR
Number of points in each part (<=1 means check
every edge)
.RE
.TP
\fB::math::geometry::intervalsOverlap\fR \fIy1\fR \fIy2\fR \fIy3\fR \fIy4\fR \fIstrict\fR
Check if two intervals overlap\&.
.RS
.TP
double \fIy1,y2\fR
Begin and end of first interval
.TP
double \fIy3,y4\fR
Begin and end of second interval
.TP
logical \fIstrict\fR
Check for strict or non-strict overlap
.RE
.TP
\fB::math::geometry::rectanglesOverlap\fR \fIP1\fR \fIP2\fR \fIQ1\fR \fIQ2\fR \fIstrict\fR
Check if two rectangles overlap\&.
.RS
.TP
list \fIP1\fR
upper-left corner of the first rectangle
.TP
list \fIP2\fR
lower-right corner of the first rectangle
.TP
list \fIQ1\fR
upper-left corner of the second rectangle
.TP
list \fIQ2\fR
lower-right corner of the second rectangle
.TP
list \fIstrict\fR
choosing strict or non-strict interpretation
.RE
.TP
\fB::math::geometry::bbox\fR \fIpolyline\fR
Calculate the bounding box of a polyline\&. Returns a list of four
coordinates: the upper-left and the lower-right corner of the box\&.
.RS
.TP
list \fIpolyline\fR
The polyline to be examined
.RE
.TP
\fB::math::geometry::overlapBBox\fR \fIpolyline1\fR \fIpolyline2\fR ?strict?
Check if the bounding boxes of two polylines overlap or not\&.
.sp
Arguments:
.RS
.TP
list \fIpolyline1\fR
The first polyline
.TP
list \fIpolyline1\fR
The second polyline
.TP
int \fIstrict\fR
Whether strict overlap is to checked (1) or if the bounding boxes may touch (0, default)
.RE
.TP
\fB::math::geometry::pointInsideBBox\fR \fIbbox\fR \fIpoint\fR
.sp
Check if the point is inside or on the bounding box or not\&.
Arguments:
.RS
.TP
list \fIbbox\fR
The bounding box given as a list of x/y coordinates
.TP
list \fIpoint\fR
The point to be checked
.RE
.TP
\fB::math::geometry::cathetusPoint\fR \fIpa\fR \fIpb\fR \fIcathetusLength\fR ?location?
Return the third point of the rectangular triangle defined by the two given end points of the hypothenusa\&.
The triangle's side from point A (or B, if the location is given as "b") to the third point is the cathetus length\&.
If the cathetus' length is lower than the length of the hypothenusa, an empty list is returned\&.
.sp
Arguments:
.RS
.TP
list \fIpa\fR
The starting point on hypotenuse
.TP
list \fIpb\fR
The ending point on hypotenuse
.TP
float \fIcathetusLength\fR
The length of the cathetus of the triangle
.TP
string \fIlocation\fR
The location of the given cathetus,
"a" means given cathetus shares point pa (default)
"b" means given cathetus shares point pb
.RE
.TP
\fB::math::geometry::parallel\fR \fIline\fR \fIoffset\fR ?orient?
Return a line parallel to the given line, with a distance "offset"\&. The orientation is determined by the
two points defining the line\&.
.sp
Arguments:
.RS
.TP
list \fIline\fR
The given line
.TP
float \fIoffset\fR
The distance to the given line
.TP
string \fIorient\fR
Orientation of the new line with respect to the given line (defaults to "right")
.RE
.sp
.TP
\fB::math::geometry::unitVector\fR \fIline\fR
Return a unit vector from the given line or direction, if the \fIline\fR argument is
a single point (then a line through the origin is assumed)
Arguments:
.RS
.TP
list \fIline\fR
The line in question (or a single point, implying a line through the origin)
.RE
.TP
\fB::math::geometry::pointInsidePolygon\fR \fIP\fR \fIpolyline\fR
Determine if a point is completely inside a polygon\&. If the point
touches the polygon, then the point is not completely inside the
polygon\&.
.RS
.TP
list \fIP\fR
Coordinates of the point
.TP
list \fIpolyline\fR
The polyline to be examined
.RE
.TP
\fB::math::geometry::pointInsidePolygonAlt\fR \fIP\fR \fIpolyline\fR
Determine if a point is completely inside a polygon\&. If the point
touches the polygon, then the point is not completely inside the
polygon\&. \fINote:\fR this alternative procedure uses the so-called
winding number to determine this\&. It handles self-intersecting polygons
in a "natural" way\&.
.RS
.TP
list \fIP\fR
Coordinates of the point
.TP
list \fIpolyline\fR
The polyline to be examined
.RE
.TP
\fB::math::geometry::rectangleInsidePolygon\fR \fIP1\fR \fIP2\fR \fIpolyline\fR
Determine if a rectangle is completely inside a polygon\&. If polygon
touches the rectangle, then the rectangle is not complete inside the
polygon\&.
.RS
.TP
list \fIP1\fR
Upper-left corner of the rectangle
.TP
list \fIP2\fR
Lower-right corner of the rectangle
.sp
.TP
list \fIpolygon\fR
The polygon in question
.RE
.TP
\fB::math::geometry::areaPolygon\fR \fIpolygon\fR
Calculate the area of a polygon\&.
.RS
.TP
list \fIpolygon\fR
The polygon in question
.RE
.TP
\fB::math::geometry::translate\fR \fIvector\fR \fIpolyline\fR
Translate a polyline over a given vector
.RS
.TP
list \fIvector\fR
Translation vector
.TP
list \fIpolyline\fR
The polyline to be translated
.RE
.TP
\fB::math::geometry::rotate\fR \fIangle\fR \fIpolyline\fR
Rotate a polyline over a given angle (degrees) around the origin
.RS
.TP
list \fIangle\fR
Angle over which to rotate the polyline (degrees)
.TP
list \fIpolyline\fR
The polyline to be rotated
.RE
.TP
\fB::math::geometry::rotateAbout\fR \fIp\fR \fIangle\fR \fIpolyline\fR
Rotate a polyline around a given point p and return the new polyline\&.
.sp
Arguments:
.RS
.TP
list \fIp\fR
The point of rotation
.TP
float \fIangle\fR
The angle over which to rotate the polyline (degrees)
.TP
list \fIpolyline\fR
The polyline to be rotated
.RE
.TP
\fB::math::geometry::reflect\fR \fIangle\fR \fIpolyline\fR
Reflect a polyline in a line through the origin at a given angle (degrees) to the x-axis
.RS
.TP
list \fIangle\fR
Angle of the line of reflection (degrees)
.TP
list \fIpolyline\fR
The polyline to be reflected
.RE
.TP
\fB::math::geometry::degToRad\fR \fIangle\fR
Convert from degrees to radians
.RS
.TP
list \fIangle\fR
Angle in degrees
.RE
.TP
\fB::math::geometry::radToDeg\fR \fIangle\fR
Convert from radians to degrees
.RS
.TP
list \fIangle\fR
Angle in radians
.RE
.TP
\fB::math::geometry::circle\fR \fIcentre\fR \fIradius\fR
Convenience procedure to create a circle from a point and a radius\&.
.RS
.TP
list \fIcentre\fR
Coordinates of the circle centre
.TP
list \fIradius\fR
Radius of the circle
.RE
.TP
\fB::math::geometry::circleTwoPoints\fR \fIpoint1\fR \fIpoint2\fR
Convenience procedure to create a circle from two points on its circumference
The centre is the point between the two given points, the radius is half the
distance between them\&.
.RS
.TP
list \fIpoint1\fR
First point
.TP
list \fIpoint2\fR
Second point
.RE
.TP
\fB::math::geometry::pointInsideCircle\fR \fIpoint\fR \fIcircle\fR
Determine if the given point is inside the circle or on the circumference (1)
or outside (0)\&.
.RS
.TP
list \fIpoint\fR
Point to be checked
.TP
list \fIcircle\fR
Circle that may or may not contain the point
.RE
.TP
\fB::math::geometry::lineIntersectsCircle\fR \fIline\fR \fIcircle\fR
Determine if the given line intersects the circle or touches it (1)
or does not (0)\&.
.RS
.TP
list \fIline\fR
Line to be checked
.TP
list \fIcircle\fR
Circle that may or may not be intersected
.RE
.TP
\fB::math::geometry::lineSegmentIntersectsCircle\fR \fIsegment\fR \fIcircle\fR
Determine if the given line segment intersects the circle or touches it (1)
or does not (0)\&.
.RS
.TP
list \fIsegment\fR
Line segment to be checked
.TP
list \fIcircle\fR
Circle that may or may not be intersected
.RE
.TP
\fB::math::geometry::intersectionLineWithCircle\fR \fIline\fR \fIcircle\fR
Determine the points at which the given line intersects the circle\&. There can
be zero, one or two points\&. (If the line touches the circle or is close to it,
then one point is returned\&. An arbitrary margin of 1\&.0e-10 times the radius
is used to determine this situation\&.)
.RS
.TP
list \fIline\fR
Line to be checked
.TP
list \fIcircle\fR
Circle that may or may not be intersected
.RE
.TP
\fB::math::geometry::intersectionCircleWithCircle\fR \fIcircle1\fR \fIcircle2\fR
Determine the points at which the given two circles intersect\&. There can
be zero, one or two points\&. (If the two circles touch the circle or are very close,
then one point is returned\&. An arbitrary margin of 1\&.0e-10 times the mean of the radii of
the two circles is used to determine this situation\&.)
.RS
.TP
list \fIcircle1\fR
First circle
.TP
list \fIcircle2\fR
Second circle
.RE
.TP
\fB::math::geometry::tangentLinesToCircle\fR \fIpoint\fR \fIcircle\fR
Determine the tangent lines from the given point to the circle\&. There can
be zero, one or two lines\&. (If the point is on the cirucmference or very close to
the circle, then one line is returned\&. An arbitrary margin of 1\&.0e-10 times the
radius of the circle is used to determine this situation\&.)
.RS
.TP
list \fIpoint\fR
Point in question
.TP
list \fIcircle\fR
Circle to which the tangent lines are to be determined
.RE
.TP
\fB::math::geometry::intersectionPolylines\fR \fIpolyline1\fR \fIpolyline2\fR ?mode? ?granularity?
Return the first point or all points where the two polylines intersect\&. If the number of points in the polylines is large,
you can use the granularity to get an approximate answer faster\&.
.sp
Arguments:
.RS
.TP
list \fIpolyline1\fR
The first polyline
.TP
list \fIpolyline2\fR
The second polyline
.TP
string \fImode\fR
Whether to return only the first (default) or to return all intersection points ("all")
.TP
int \fIgranularity\fR
The number of points that will be skipped plus 1 in the search for intersection points (1 or smaller means an exact answer is returned)
.RE
.TP
\fB::math::geometry::intersectionPolylineCircle\fR \fIpolyline\fR \fIcircle\fR ?mode? ?granularity?
Return the first point or all points where the polyline intersects the circle\&. If the number of points in the polyline is large,
you can use the granularity to get an approximate answer faster\&.
.sp
Arguments:
.RS
.TP
list \fIpolyline\fR
The polyline that may intersect the circle
.TP
list \fIcircle\fR
The circle in question
.TP
string \fImode\fR
Whether to return only the first (default) or to return all intersection points ("all")
.TP
int \fIgranularity\fR
The number of points that will be skipped plus 1 in the search for intersection points (1 or smaller means an exact answer is returned)
.RE
.TP
\fB::math::geometry::polylineCutOrigin\fR \fIpolyline1\fR \fIpolyline2\fR ?granularity?
Return the part of the first polyline from the origin up to the first intersection with the second\&. If the number of points in the polyline is large,
you can use the granularity to get an approximate answer faster\&.
.sp
Arguments:
.RS
.TP
list \fIpolyline1\fR
The first polyline (from which a part is to be returned)
.TP
list \fIpolyline2\fR
The second polyline
.TP
int \fIgranularity\fR
The number of points that will be skipped plus 1 in the search for intersection points (1 or smaller means an exact answer is returned)
.RE
.TP
\fB::math::geometry::polylineCutEnd\fR \fIpolyline1\fR \fIpolyline2\fR ?granularity?
Return the part of the first polyline from the last intersection point with the second to the end\&. If the number of points in the polyline is large,
you can use the granularity to get an approximate answer faster\&.
.sp
Arguments:
.RS
.TP
list \fIpolyline1\fR
The first polyline (from which a part is to be returned)
.TP
list \fIpolyline2\fR
The second polyline
.TP
int \fIgranularity\fR
The number of points that will be skipped plus 1 in the search for intersection points (1 or smaller means an exact answer is returned)
.RE
.TP
\fB::math::geometry::splitPolyline\fR \fIpolyline\fR \fInumberVertex\fR
Split the poyline into a set of polylines where each separate polyline holds "numberVertex" vertices between the two end points\&.
.sp
Arguments:
.RS
.TP
list \fIpolyline\fR
The polyline to be split up
.TP
int \fInumberVertex\fR
The number of "internal" vertices
.RE
.TP
\fB::math::geometry::enrichPolyline\fR \fIpolyline\fR \fIaccuracy\fR
Split up each segment of a polyline into a number of smaller segments and return the result\&.
.sp
Arguments:
.RS
.TP
list \fIpolyline\fR
The polyline to be refined
.TP
int \fIaccuracy\fR
The number of subsegments to be created
.RE
.TP
\fB::math::geometry::cleanupPolyline\fR \fIpolyline\fR
Remove duplicate neighbouring vertices and return the result\&.
.sp
Arguments:
.RS
.TP
list \fIpolyline\fR
The polyline to be cleaned up
.RE
.PP
.SH "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\&.
.SH REFERENCES
.IP [1]
\fIPolygon Intersection\fR [http:/wiki\&.tcl\&.tk/12070]
.IP [2]
\fIhttp://en\&.wikipedia\&.org/wiki/Line-line_intersection\fR
.IP [3]
\fIhttp://local\&.wasp\&.uwa\&.edu\&.au/~pbourke/geometry/lineline2d/\fR
.PP
.SH "BUGS, IDEAS, FEEDBACK"
This document, and the package it describes, will undoubtedly contain
bugs and other problems\&.
Please report such in the category \fImath :: geometry\fR of the
\fITcllib Trackers\fR [http://core\&.tcl\&.tk/tcllib/reportlist]\&.
Please also report any ideas for enhancements you may have for either
package and/or documentation\&.
.PP
When proposing code changes, please provide \fIunified diffs\fR,
i\&.e the output of \fBdiff -u\fR\&.
.PP
Note further that \fIattachments\fR are strongly preferred over
inlined patches\&. Attachments can be made by going to the \fBEdit\fR
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar\&.
.SH KEYWORDS
angle, distance, line, math, plane geometry, point
.SH CATEGORY
Mathematics
.SH COPYRIGHT
.nf
Copyright (c) 2001 by Ideogramic ApS and other parties
Copyright (c) 2010 by Andreas Kupries
Copyright (c) 2010 by Kevin Kenny
Copyright (c) 2018 by Arjen Markus
Copyright (c) 2020 by Manfred Rosenberger
.fi
|