- Timestamp:
- Nov 12, 2008, 12:14:33 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source_numpy_conversion/anuga/utilities/test_polygon.py
r5902 r5948 658 658 assert numpy.allclose(value, [1.0, 1.0]) 659 659 660 # This function is a helper function for 661 # the test_intersection_bug_20081110_?() set of tests. 662 # This function tests all parallel line cases for 4 collinear points. 663 # This function should never be run directly by the unittest code. 664 def helper_test_parallel_intersection_code(self, P1, P2, P3, P4): 665 # lines in same direction, no overlap 666 # 0: ---->---- 667 # 1: --------->----------- 668 line0 = [P1,P2] 669 line1 = [P3,P4] 670 status, value = intersection(line0, line1) 671 self.failIf(status!=3, 'Expected status 3, got status=%s, value=%s' % 672 (str(status), str(value))) 673 self.failUnless(value is None, 'Expected value of None, got %s' % 674 str(value)) 675 676 # lines in same direction, no overlap 677 # 0: ----<---- 678 # 1: ---------<----------- 679 line0 = [P2,P1] 680 line1 = [P4,P3] 681 status, value = intersection(line0, line1) 682 self.failIf(status!=3, 'Expected status 3, got status=%s, value=%s' % 683 (str(status), str(value))) 684 self.failUnless(value is None, 'Expected value of None, got %s' % 685 str(value)) 686 687 # lines in opposite direction, no overlap 688 # 0: ----<---- 689 # 1: --------->----------- 690 line0 = [P2,P1] 691 line1 = [P3,P4] 692 status, value = intersection(line0, line1) 693 self.failIf(status!=3, 'Expected status 3, got status=%s, value=%s' % 694 (str(status), str(value))) 695 self.failUnless(value is None, 'Expected value of None, got %s' % 696 str(value)) 697 698 # lines in opposite direction, no overlap 699 # 0: ---->---- 700 # 1: ---------<----------- 701 line0 = [P1,P2] 702 line1 = [P4,P3] 703 status, value = intersection(line0, line1) 704 self.failIf(status!=3, 'Expected status 3, got status=%s, value=%s' % 705 (str(status), str(value))) 706 self.failUnless(value is None, 'Expected value of None, got %s' % 707 str(value)) 708 709 #---------------------------------------------------------------------- 710 711 # line0 fully within line1, same direction 712 # 0: ---->---- 713 # 1: --------->----------- 714 # value should be line0: 715 # ---->---- 716 line0 = [P2,P3] 717 line1 = [P1,P4] 718 status, value = intersection(line0, line1) 719 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 720 (str(status), str(value))) 721 self.failUnless(numpy.allclose(value, line0)) 722 723 # line0 fully within line1, same direction 724 # 0: ----<---- 725 # 1: ---------<----------- 726 # value should be line0: 727 # ----<---- 728 line0 = [P3,P2] 729 line1 = [P4,P1] 730 status, value = intersection(line0, line1) 731 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 732 (str(status), str(value))) 733 self.failUnless(numpy.allclose(value, line0)) 734 735 # line0 fully within line1, opposite direction 736 # 0: ----<---- 737 # 1: --------->----------- 738 # value should be line0: 739 # ----<---- 740 line0 = [P3,P2] 741 line1 = [P1,P4] 742 status, value = intersection(line0, line1) 743 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 744 (str(status), str(value))) 745 self.failUnless(numpy.allclose(value, line0)) 746 747 # line0 fully within line1, opposite direction 748 # 0: ---->---- 749 # 1: ---------<----------- 750 # value should be line0: 751 # ---->---- 752 line0 = [P2,P3] 753 line1 = [P4,P1] 754 status, value = intersection(line0, line1) 755 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 756 (str(status), str(value))) 757 self.failUnless(numpy.allclose(value, line0)) 758 759 #---------------------------------------------------------------------- 760 761 # line1 fully within line0, same direction 762 # 0: --------->----------- 763 # 1: ---->---- 764 # value should be line1: 765 # ---->---- 766 line0 = [P1,P4] 767 line1 = [P2,P3] 768 status, value = intersection(line0, line1) 769 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 770 (str(status), str(value))) 771 self.failUnless(numpy.allclose(value, line1)) 772 773 # line1 fully within line0, same direction 774 # 0: ---------<----------- 775 # 1: ----<---- 776 # value should be line1: 777 # ----<---- 778 line0 = [P4,P1] 779 line1 = [P3,P2] 780 status, value = intersection(line0, line1) 781 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 782 (str(status), str(value))) 783 self.failUnless(numpy.allclose(value, line1)) 784 785 # line1 fully within line0, opposite direction 786 # 0: ---------<----------- 787 # 1: ---->---- 788 # value should be line1: 789 # ---->---- 790 line0 = [P4,P1] 791 line1 = [P2,P3] 792 status, value = intersection(line0, line1) 793 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 794 (str(status), str(value))) 795 self.failUnless(numpy.allclose(value, line1)) 796 797 # line1 fully within line0, opposite direction 798 # 0: --------->----------- 799 # 1: ----<---- 800 # value should be line1: 801 # ----<---- 802 line0 = [P1,P4] 803 line1 = [P3,P2] 804 status, value = intersection(line0, line1) 805 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 806 (str(status), str(value))) 807 self.failUnless(numpy.allclose(value, line1)) 808 809 #---------------------------------------------------------------------- 810 811 # line in same direction, partial overlap 812 # 0: ----->----- 813 # 1: ------->-------- 814 # value should be segment line1_start->line0_end: 815 # --->---- 816 line0 = [P1,P3] 817 line1 = [P2,P4] 818 status, value = intersection(line0, line1) 819 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 820 (str(status), str(value))) 821 self.failUnless(numpy.allclose(value, [line1[0],line0[1]])) 822 823 # line in same direction, partial overlap 824 # 0: -----<----- 825 # 1: -------<-------- 826 # value should be segment line0_start->line1_end: 827 # ---<---- 828 line0 = [P3,P1] 829 line1 = [P4,P2] 830 status, value = intersection(line0, line1) 831 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 832 (str(status), str(value))) 833 self.failUnless(numpy.allclose(value, [line0[0],line1[1]])) 834 835 # line in opposite direction, partial overlap 836 # 0: -----<----- 837 # 1: ------->-------- 838 # value should be segment line0_start->line1_start: 839 # ---<---- 840 line0 = [P3,P1] 841 line1 = [P2,P4] 842 status, value = intersection(line0, line1) 843 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 844 (str(status), str(value))) 845 self.failUnless(numpy.allclose(value, [line0[0],line1[0]])) 846 847 # line in opposite direction, partial overlap 848 # 0: ----->----- 849 # 1: -------<-------- 850 # value should be segment line1_end->line0_end: 851 # --->---- 852 line0 = [P1,P3] 853 line1 = [P4,P2] 854 status, value = intersection(line0, line1) 855 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 856 (str(status), str(value))) 857 self.failUnless(numpy.allclose(value, [line1[1],line0[1]])) 858 859 #---------------------------------------------------------------------- 860 861 # line in same direction, partial overlap 862 # 0: ------>------ 863 # 1: ------>------ 864 # value should be segment line0_start->line1_end: 865 # --->---- 866 line0 = [P2,P4] 867 line1 = [P1,P3] 868 status, value = intersection(line0, line1) 869 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 870 (str(status), str(value))) 871 self.failUnless(numpy.allclose(value, [line0[0],line1[1]])) 872 873 # line in same direction, partial overlap 874 # 0: ------<------ 875 # 1: ------<------ 876 # value should be segment line1_start->line0_end: 877 # ----<----- 878 line0 = [P4,P2] 879 line1 = [P3,P1] 880 status, value = intersection(line0, line1) 881 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 882 (str(status), str(value))) 883 self.failUnless(numpy.allclose(value, [line1[0],line0[1]])) 884 885 # line in opposite direction, partial overlap 886 # 0: ------<------ 887 # 1: ----->------ 888 # value should be segment line1_end->line0_end: 889 # --->---- 890 line0 = [P4,P2] 891 line1 = [P1,P3] 892 status, value = intersection(line0, line1) 893 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 894 (str(status), str(value))) 895 self.failUnless(numpy.allclose(value, [line1[1],line0[1]])) 896 897 # line in opposite direction, partial overlap 898 # 0: ------>------ 899 # 1: -----<------ 900 # value should be segment line0_start->line1_start: 901 # ---<---- 902 line0 = [P2,P4] 903 line1 = [P3,P1] 904 status, value = intersection(line0, line1) 905 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 906 (str(status), str(value))) 907 self.failUnless(numpy.allclose(value, [line0[0],line1[0]])) 908 909 #---------------------------------------------------------------------- 910 911 # line in same direction, same left point, line1 longer 912 # 0: ----->------ 913 # 1: ------->-------- 914 # value should be line0: 915 # ----->------ 916 line0 = [P1,P3] 917 line1 = [P1,P4] 918 status, value = intersection(line0, line1) 919 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 920 (str(status), str(value))) 921 self.failUnless(numpy.allclose(value, line0)) 922 923 # line in same direction, same left point, line1 longer 924 # 0: -----<------ 925 # 1: -------<-------- 926 # value should be line0: 927 # -----<------ 928 line0 = [P3,P1] 929 line1 = [P4,P1] 930 status, value = intersection(line0, line1) 931 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 932 (str(status), str(value))) 933 self.failUnless(numpy.allclose(value, line0)) 934 935 # line in opposite direction, same left point, line1 longer 936 # 0: ----->------ 937 # 1: -------<-------- 938 # value should be line0: 939 # ----->------ 940 line0 = [P1,P3] 941 line1 = [P4,P1] 942 status, value = intersection(line0, line1) 943 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 944 (str(status), str(value))) 945 self.failUnless(numpy.allclose(value, line0)) 946 947 # line in opposite direction, same start point, line1 longer 948 # 0: -----<------ 949 # 1: ------->-------- 950 # value should be line0: 951 # -----<------ 952 line0 = [P3,P1] 953 line1 = [P1,P4] 954 status, value = intersection(line0, line1) 955 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 956 (str(status), str(value))) 957 self.failUnless(numpy.allclose(value, line0)) 958 959 #---------------------------------------------------------------------- 960 961 # line in same direction, same left point, same right point 962 # 0: ------->-------- 963 # 1: ------->-------- 964 # value should be line0 or line1: 965 # ------->-------- 966 line0 = [P1,P3] 967 line1 = [P1,P3] 968 status, value = intersection(line0, line1) 969 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 970 (str(status), str(value))) 971 self.failUnless(numpy.allclose(value, line0)) 972 973 # line in same direction, same left point, same right point 974 # 0: -------<-------- 975 # 1: -------<-------- 976 # value should be line0 (or line1): 977 # -------<-------- 978 line0 = [P3,P1] 979 line1 = [P3,P1] 980 status, value = intersection(line0, line1) 981 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 982 (str(status), str(value))) 983 self.failUnless(numpy.allclose(value, line0)) 984 985 # line in opposite direction, same left point, same right point 986 # 0: ------->-------- 987 # 1: -------<-------- 988 # value should be line0: 989 # ------->-------- 990 line0 = [P1,P3] 991 line1 = [P3,P1] 992 status, value = intersection(line0, line1) 993 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 994 (str(status), str(value))) 995 self.failUnless(numpy.allclose(value, line0)) 996 997 # line in opposite direction, same left point, same right point 998 # 0: -------<-------- 999 # 1: ------->-------- 1000 # value should be line0: 1001 # -------<-------- 1002 line0 = [P3,P1] 1003 line1 = [P1,P3] 1004 status, value = intersection(line0, line1) 1005 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1006 (str(status), str(value))) 1007 self.failUnless(numpy.allclose(value, line0)) 1008 1009 #---------------------------------------------------------------------- 1010 1011 # line in same direction, same right point, line1 longer 1012 # 0: ----->------ 1013 # 1: ------->-------- 1014 # value should be line0: 1015 # ----->------ 1016 line0 = [P2,P4] 1017 line1 = [P1,P4] 1018 status, value = intersection(line0, line1) 1019 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1020 (str(status), str(value))) 1021 self.failUnless(numpy.allclose(value, line0)) 1022 1023 # line in same direction, same right point, line1 longer 1024 # 0: -----<------ 1025 # 1: -------<-------- 1026 # value should be line0: 1027 # -----<------ 1028 line0 = [P4,P2] 1029 line1 = [P4,P1] 1030 status, value = intersection(line0, line1) 1031 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1032 (str(status), str(value))) 1033 self.failUnless(numpy.allclose(value, line0)) 1034 1035 # line in opposite direction, same right point, line1 longer 1036 # 0: ----->------ 1037 # 1: -------<-------- 1038 # value should be line0: 1039 # ----->------ 1040 line0 = [P2,P4] 1041 line1 = [P4,P1] 1042 status, value = intersection(line0, line1) 1043 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1044 (str(status), str(value))) 1045 self.failUnless(numpy.allclose(value, line0)) 1046 1047 # line in opposite direction, same right point, line1 longer 1048 # 0: -----<------ 1049 # 1: ------->-------- 1050 # value should be line0: 1051 # -----<------ 1052 line0 = [P4,P2] 1053 line1 = [P1,P4] 1054 status, value = intersection(line0, line1) 1055 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1056 (str(status), str(value))) 1057 self.failUnless(numpy.allclose(value, line0)) 1058 1059 #---------------------------------------------------------------------- 1060 1061 # line in same direction, same left point, line0 longer 1062 # 0: ------->-------- 1063 # 1: ----->------ 1064 # value should be line1: 1065 # ----->------ 1066 line0 = [P1,P4] 1067 line1 = [P1,P3] 1068 status, value = intersection(line0, line1) 1069 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1070 (str(status), str(value))) 1071 self.failUnless(numpy.allclose(value, line1)) 1072 1073 # line in same direction, same left point, line0 longer 1074 # 0: -------<-------- 1075 # 1: -----<------ 1076 # value should be line1: 1077 # -----<------ 1078 line0 = [P4,P1] 1079 line1 = [P3,P1] 1080 status, value = intersection(line0, line1) 1081 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1082 (str(status), str(value))) 1083 self.failUnless(numpy.allclose(value, line1)) 1084 1085 # line in opposite direction, same left point, line0 longer 1086 # 0: ------->-------- 1087 # 1: -----<------ 1088 # value should be line1: 1089 # -----<------ 1090 line0 = [P1,P4] 1091 line1 = [P3,P1] 1092 status, value = intersection(line0, line1) 1093 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1094 (str(status), str(value))) 1095 self.failUnless(numpy.allclose(value, line1)) 1096 1097 # line in opposite direction, same left point, line0 longer 1098 # 0: -------<-------- 1099 # 1: ----->------ 1100 # value should be line1: 1101 # ----->------ 1102 line0 = [P4,P1] 1103 line1 = [P1,P3] 1104 status, value = intersection(line0, line1) 1105 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1106 (str(status), str(value))) 1107 self.failUnless(numpy.allclose(value, line1)) 1108 1109 #---------------------------------------------------------------------- 1110 1111 # line in same direction, same right point, line0 longer 1112 # 0: ------->-------- 1113 # 1: ----->------ 1114 # value should be line1: 1115 # ----->------ 1116 line0 = [P1,P4] 1117 line1 = [P2,P4] 1118 status, value = intersection(line0, line1) 1119 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1120 (str(status), str(value))) 1121 self.failUnless(numpy.allclose(value, line1)) 1122 1123 # line in same direction, same right point, line0 longer 1124 # 0: -------<-------- 1125 # 1: -----<------ 1126 # value should be line1: 1127 # -----<------ 1128 line0 = [P4,P1] 1129 line1 = [P4,P2] 1130 status, value = intersection(line0, line1) 1131 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1132 (str(status), str(value))) 1133 self.failUnless(numpy.allclose(value, line1)) 1134 1135 # line in opposite direction, same right point, line0 longer 1136 # 0: ------->-------- 1137 # 1: -----<------ 1138 # value should be line1: 1139 # -----<------ 1140 line0 = [P1,P4] 1141 line1 = [P4,P2] 1142 status, value = intersection(line0, line1) 1143 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1144 (str(status), str(value))) 1145 self.failUnless(numpy.allclose(value, line1)) 1146 1147 # line in opposite direction, same right point, line0 longer 1148 # 0: -------<-------- 1149 # 1: ----->------ 1150 # value should be line1: 1151 # ----->------ 1152 line0 = [P4,P1] 1153 line1 = [P2,P4] 1154 status, value = intersection(line0, line1) 1155 self.failIf(status!=2, 'Expected status 2, got status=%s, value=%s' % 1156 (str(status), str(value))) 1157 self.failUnless(numpy.allclose(value, line1)) 1158 1159 1160 def test_intersection_bug_20081110_TR(self): 1161 """test_intersection_bug_20081110(self) 1162 1163 Test all cases in top-right quadrant 1164 """ 1165 1166 # define 4 collinear points in top-right quadrant 1167 # P1---P2---P3---P4 1168 P1 = [1.0, 1.0] 1169 P2 = [2.0, 2.0] 1170 P3 = [3.0, 3.0] 1171 P4 = [4.0, 4.0] 1172 1173 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1174 P1 = [1.0, 1.0+1.0e-9] 1175 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1176 P1 = [1.0, 1.0] 1177 P2 = [2.0, 2.0+1.0e-9] 1178 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1179 P2 = [2.0, 2.0] 1180 P3 = [3.0, 3.0+1.0e-9] 1181 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1182 P3 = [3.0, 3.0] 1183 P4 = [4.0, 4.0+1.0e-9] 1184 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1185 1186 def test_intersection_bug_20081110_TL(self): 1187 """test_intersection_bug_20081110(self) 1188 1189 Test all cases in top-left quadrant 1190 """ 1191 1192 # define 4 collinear points in top-left quadrant 1193 # P1---P2---P3---P4 1194 P1 = [-1.0, 1.0] 1195 P2 = [-2.0, 2.0] 1196 P3 = [-3.0, 3.0] 1197 P4 = [-4.0, 4.0] 1198 1199 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1200 P1 = [-1.0, 1.0+1.0e-9] 1201 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1202 P1 = [-1.0, 1.0] 1203 P2 = [-2.0, 2.0+1.0e-9] 1204 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1205 P2 = [-2.0, 2.0] 1206 P3 = [-3.0, 3.0+1.0e-9] 1207 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1208 P3 = [-3.0, 3.0] 1209 P4 = [-4.0, 4.0+1.0e-9] 1210 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1211 1212 def test_intersection_bug_20081110_BL(self): 1213 """test_intersection_bug_20081110(self) 1214 1215 Test all cases in bottom-left quadrant 1216 """ 1217 1218 # define 4 collinear points in bottom-left quadrant 1219 # P1---P2---P3---P4 1220 P1 = [-1.0, -1.0] 1221 P2 = [-2.0, -2.0] 1222 P3 = [-3.0, -3.0] 1223 P4 = [-4.0, -4.0] 1224 1225 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1226 P1 = [-1.0, -1.0+1.0e-9] 1227 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1228 P1 = [-1.0, -1.0] 1229 P2 = [-2.0, -2.0+1.0e-9] 1230 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1231 P2 = [-2.0, -2.0] 1232 P3 = [-3.0, -3.0+1.0e-9] 1233 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1234 P3 = [-3.0, -3.0] 1235 P4 = [-4.0, -4.0+1.0e-9] 1236 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1237 1238 def test_intersection_bug_20081110_BR(self): 1239 """test_intersection_bug_20081110(self) 1240 1241 Test all cases in bottom-right quadrant 1242 """ 1243 1244 # define 4 collinear points in bottom-right quadrant 1245 # P1---P2---P3---P4 1246 P1 = [1.0, -1.0] 1247 P2 = [2.0, -2.0] 1248 P3 = [3.0, -3.0] 1249 P4 = [4.0, -4.0] 1250 1251 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1252 P1 = [1.0, -1.0+1.0e-9] 1253 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1254 P1 = [1.0, -1.0] 1255 P2 = [2.0, -2.0+1.0e-9] 1256 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1257 P2 = [2.0, -2.0] 1258 P3 = [3.0, -3.0+1.0e-9] 1259 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1260 P3 = [3.0, -3.0] 1261 P4 = [4.0, -4.0+1.0e-9] 1262 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1263 1264 def test_intersection_bug_20081110_TR_TL(self): 1265 """test_intersection_bug_20081110(self) 1266 1267 Test all cases in top-right & top-left quadrant 1268 """ 1269 1270 # define 4 collinear points, 1 in TL, 3 in TR 1271 # P1---P2---P3---P4 1272 P1 = [-3.0, 1.0] 1273 P2 = [ 1.0, 5.0] 1274 P3 = [ 2.0, 6.0] 1275 P4 = [ 3.0, 7.0] 1276 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1277 1278 # define 4 collinear points, 2 in TL, 2 in TR 1279 # P1---P2---P3---P4 1280 P1 = [-3.0, 1.0] 1281 P2 = [-2.0, 2.0] 1282 P3 = [ 2.0, 6.0] 1283 P4 = [ 3.0, 7.0] 1284 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1285 1286 # define 4 collinear points, 2 in TL, 1 in TR 1287 # P1---P2---P3---P4 1288 P1 = [-3.0, 1.0] 1289 P2 = [-2.0, 2.0] 1290 P3 = [-1.0, 3.0] 1291 P4 = [ 3.0, 7.0] 1292 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1293 1294 def test_intersection_bug_20081110_TR_BL(self): 1295 """test_intersection_bug_20081110(self) 1296 1297 Test all cases in top-right & bottom-left quadrant 1298 """ 1299 1300 # define 4 collinear points, 1 in BL, 3 in TR 1301 # P1---P2---P3---P4 1302 P1 = [-4.0, -3.0] 1303 P2 = [ 1.0, 2.0] 1304 P3 = [ 2.0, 3.0] 1305 P4 = [ 3.0, 4.0] 1306 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1307 1308 # define 4 collinear points, 2 in TL, 2 in TR 1309 # P1---P2---P3---P4 1310 P1 = [-4.0, -3.0] 1311 P2 = [-3.0, -2.0] 1312 P3 = [ 2.0, 3.0] 1313 P4 = [ 3.0, 4.0] 1314 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1315 1316 # define 4 collinear points, 3 in TL, 1 in TR 1317 # P1---P2---P3---P4 1318 P1 = [-4.0, -3.0] 1319 P2 = [-3.0, -2.0] 1320 P3 = [-2.0, -1.0] 1321 P4 = [ 3.0, 4.0] 1322 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1323 1324 def test_intersection_bug_20081110_TR_BR(self): 1325 """test_intersection_bug_20081110(self) 1326 1327 Test all cases in top-right & bottom-right quadrant 1328 """ 1329 1330 # define 4 collinear points, 1 in BR, 3 in TR 1331 # P1---P2---P3---P4 1332 P1 = [ 1.0, -3.0] 1333 P2 = [ 5.0, 1.0] 1334 P3 = [ 6.0, 2.0] 1335 P4 = [ 7.0, 3.0] 1336 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1337 1338 # define 4 collinear points, 2 in BR, 2 in TR 1339 # P1---P2---P3---P4 1340 P1 = [ 1.0, -3.0] 1341 P2 = [ 2.0, -2.0] 1342 P3 = [ 6.0, 2.0] 1343 P4 = [ 7.0, 3.0] 1344 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1345 1346 # define 4 collinear points, 3 in BR, 1 in TR 1347 # P1---P2---P3---P4 1348 P1 = [ 1.0, -3.0] 1349 P2 = [ 2.0, -2.0] 1350 P3 = [ 3.0, -1.0] 1351 P4 = [ 7.0, 3.0] 1352 self.helper_test_parallel_intersection_code(P1, P2, P3, P4) 1353 660 1354 661 1355 def test_intersection_direction_invariance(self): … … 997 1691 if __name__ == "__main__": 998 1692 suite = unittest.makeSuite(Test_Polygon,'test') 999 ## suite = unittest.makeSuite(Test_Polygon,'test_ polygon_function_constantsX')1693 ## suite = unittest.makeSuite(Test_Polygon,'test_intersection_bug_20081110') 1000 1694 runner = unittest.TextTestRunner() 1001 1695 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.