acm schedule… 2/23 geometry problems 3/2 lab problems (geometry!) 3/30 "mock"...
TRANSCRIPT
![Page 1: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/1.jpg)
ACM Schedule…
2/23 Geometry problems
3/2 Lab problems (geometry!)
3/30 "Mock" competition and lab session (4:15)
3/9 Final algorithm discussion…
3/16 [Spring break]
3/23 [Extended programming practicum break]
![Page 2: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/2.jpg)
Current Jotto standings…
Sophs Jrs Srs Profs
Chalk 1 Chalk 0 Chalk 1 Chalk 1
Quine 1 Quine 1 Quine 2 Quine 2
aught 2 aught 1 aught 1 aught 2
jotto 2 jotto 2 jotto 0 jotto 1
?? 2 ?? 2 ?? 0 ?? 1
![Page 3: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/3.jpg)
Last time: the Muddy Problem
Input
Output
4 4*.*..******...*.
# of rows and columns
The environment
*
4The smallest number of boards needed to cover all the muddy patches!
represents a muddy patch
. represents a grassy patch
![Page 4: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/4.jpg)
Turning direction
Python code for CCW turning
1
2
3
def turningDirection( pt1, pt2, pt3 ): """ returns 1 if pt1 -> pt2 -> pt3 is a turn returns -1 if pt1 -> pt2 -> pt3 is a turn returns 0 if they are collinear """ x1, y1 = pt1; x2, y2 = pt2; x3, y3 = pt3; # the signed magnitude of the cross product CP = (x2-x1)*(y3-y1)-(y2-y1)*(x3-x1) if CP > 0: return 1 if CP < 0: return -1 return 0
Bertrand Planes' Life Clock
(10,10)
(20,20)
(15,30)
3'
(40,20)
![Page 5: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/5.jpg)
Geometric algorithms
Line Segment intersection…
(x1,y1)
(x2,y2)
(xB,yB)
(xA,yA)
rs
xA - x1
yA - y1
dx1 dxA
dy1 dyA
=
(xi,yi)
All points on this line are (x1,y1) + r(x2-x1,y2-y1)
(xA,yA) + s(xB-xA,yB-yA)All points on this line are
dx1 dy1
dxA dyA
Solving these equations finds the intersection via r and s.
![Page 6: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/6.jpg)
Geometric algorithms
Line Segment intersection…
pt1 = (10, 10)
pt2 = (20,20)
pt3 = (10, 20)
pt4 = (20, 10)
pt5 = (40, 20)
Line segment #1 runs from (10, 10) to (20, 20)Line segment #2 runs from (10, 20) to (20, 10) Intersection result = (15.0, 15.0, 1, 0.5, 0.5)
Line segment #1 runs from (10, 10) to (10, 20)Line segment #2 runs from (20, 20) to (20, 10) Intersection result = (0, 0, 0, 0, 0)
Line segment #1 runs from (10, 10) to (20, 20)Line segment #2 runs from (20, 10) to (40, 20) Intersection result = (0.0, 0.0, 1, -1.0, -1.0)
![Page 7: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/7.jpg)
Geometric algorithms
Java has its advantages!
Line2d.linesIntersect(x1, y1, x2, y2, x3, y3, x4, y4);
Polygon().contains(x,y);
Line2D Polygon
![Page 8: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/8.jpg)
This week's Problems…
• read over these problems…
• rank them in "difficulty" order
• what geometric computation is needed?
![Page 9: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/9.jpg)
The EE ProblemInput
Output
# of test cases
Data Set 1:10.813.420.00The strength of the signal at each test location ==
1.0/(closest visible router ** 2)
# of room vertices, # of routers, # of test points
vertices of the room
Locations of the routers
test locations
routers
example input
Locations of the test points
+
+
+
A
B
C
C
A B
![Page 10: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/10.jpg)
1 4 4 0.1 0.1 0.0 0.9 1.0 0.05 1.1 -0.1 -0.1 -0.1 0.8 0 1.1 0.5 0.7 0 0.3 0.5 0 0.3
The IE ProblemInput
Output
# of test cases
Data Set 1:2.32
The minimum total cost to supply all stores from some warehouse(s).
# of stores and possible warehouse locations
(x,y) location of stores
(x,y,price) location of warehouses and their cost to build in Mega$
S
S
S
SW
W
WW
$.3$.3
$.5
$.8
delivery cost = Euclidean distance
Industrial Engineering
![Page 11: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/11.jpg)
The Superpaint ProblemInput
Output
4 32 12 34 1
one side of the square lattice
Locations of the cows (row,col)
5
The number of locations that "attack" all occupied squares
with a Queen's move
Row 1 . . . .C . C . . . . .C . . .
number of occupied squares
Row 2
Row 3
Row 4
Col 1
Col 2
Col 3
Col 4
Row 1 . . . .B . B . . B . .B . B .
Row 2
Row 3
Row 4
Col 1
Col 2
Col 3
Col 4
![Page 12: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/12.jpg)
The Safepens Problem
Input
Output
41 1 16 166 6 11 137 7 9 123 3 10 5
Number of rectangular fences
The fences!
(lower left and upper right vertices)
3 1
The deepest nesting level
The number of pens at that level
(1,1)
(16,16)
(6,6)
(11,13)
(7,7)
(9,12)
(3,3)
(10,5)
![Page 13: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/13.jpg)
http://en.wikipedia.org/wiki/Bentley–Ottmann_algorithm
"Sweepline algorithm"
![Page 14: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/14.jpg)
http://en.wikipedia.org/wiki/Bentley–Ottmann_algorithm
A
B
C
D Priority Queue
Binary Search Tree
![Page 15: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/15.jpg)
The Screens ProblemInput
Output
# of test cases
Vertices of the room
Data Set 1:90.00%
The total fraction of the presentation you can observe (all screens' contributions!)
# of projector screens
# of room vertices
(x,y) location of "you"
Line segments of the screens
room
oriented screens
![Page 16: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/16.jpg)
Current Jotto standings…
Sophs Jrs Srs Profs
Chalk 1 Chalk 0 Chalk 1 Chalk 1
Quine 1 Quine 1 Quine 2 Quine 2
aught 2 aught 1 aught 1 aught 2
jotto 2 jotto 2 jotto 0 jotto 1
?? 2 ?? 2 ?? 0 ?? 1
![Page 17: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/17.jpg)
Current Jotto standings…
Sophs Jrs Srs Others
icily 0 icily 0 icily 1 icily 1
strep 2 strep 2 strep 2 strep 1
spork 1 spork 3 spork 0 spork 0
spend 2 spend 2 spend 2 spend 2
peeps 2 peeps 1 peeps 2 peeps 1
furls 1 furls 1 furls 0 furls 1
Ghost 2 Ghost 1 Ghost 1 Ghost 0
Tanks 2 Tanks 1 Tanks 2 Tanks 1
Gecko 2 Gecko 1 Gecko 1 Gecko 1
![Page 18: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/18.jpg)
Convex Hull
the segments surrounding the
exterior of a point set.
First approach: brute force?
![Page 19: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/19.jpg)
The Graham Scan
"first algorithm in computational geometry"
1) Find extremal point, P[0]
2) Sort all other points in terms of their angles with P[0] - use atan2 !
3) the sorted list is P[i]
4) push P[0] and P[1] onto S
a stack (e.g.,
python list)
i = 2
while i < N:
A = the top of stack S B = the second point on S
if (P[i] is to the left of B to A): push P[i] onto stack S i = i+1 else: pop stack S and discard the top
5) run the scan:
![Page 20: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/20.jpg)
Graham Scan: java
Stack grahamScan(Coordinate[] c) { Point p; Stack ps = new Stack(); ps.push(c[0]); ps.push(c[1]); ps.push(c[2]); for (int i = 3; i < c.length; i++) { p = ps.pop(); while (computeOrientation(ps.peek(), p, c[i]) > 0)) { ps.pop(); } ps.push(p); ps.push(c[i]); } ps.push(c[0]); return ps;}
![Page 21: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/21.jpg)
Convex Hull #2
convex hull Jarvis’s March - shown hereGraham’s Scan - see previous
![Page 22: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/22.jpg)
Jarvis March
convex hull
start here
draw a line to this point (why?)
Jarvis’s March - shown hereGraham’s Scan - see previous
![Page 23: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/23.jpg)
Jarvis March
convex hull
start here
draw a line to this point
draw a line to the point with the LEAST relative angle ()
Jarvis’s March - shown hereGraham’s Scan - see previous
![Page 24: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/24.jpg)
Jarvis March
convex hull
start here
draw a line to the point with the LEAST relative angle ()
Jarvis’s March - shown hereGraham’s Scan - see previous
![Page 25: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/25.jpg)
Jarvis March
convex hull
draw a line to the point with the LEAST relative angle ()
but bigger than the previous angle!
Jarvis’s March - shown hereGraham’s Scan - see previous
![Page 26: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/26.jpg)
Jarvis March
convex hull
continue until you return…
Jarvis’s March - shown hereGraham’s Scan - see previous
![Page 27: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/27.jpg)
"QuickHull"
![Page 28: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/28.jpg)
"QuickHull"
choose L and R pts
draw chord
![Page 29: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/29.jpg)
"QuickHull"
choose L and R pts
draw chord
• assign sides
• find farthest point on each side
• create triangle
recurse!
![Page 30: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/30.jpg)
"QuickHull"
choose L and R pts
draw chord
• assign sides
• find farthest point on each side
• create triangle
recurse!
• assign sides
![Page 31: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/31.jpg)
Java's Polygon class
contains
constructors
intersects (a rect)
getBounds (get a bbox)
uses the WIND_EVEN_ODD rule
![Page 32: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/32.jpg)
The Sweepline Algorithm
choose L and R pts
draw chord
• assign sides
• find farthest point on each side
• create triangle
recurse!
• assign sides
![Page 33: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/33.jpg)
The Safepens Problem
Input
Output
41 1 16 166 6 11 137 7 9 123 3 10 5
Number of rectangular fences
The fences!
(lower left and upper right vertices)
3 1
The deepest nesting level
The number of pens at that level
(1,1)
(16,16)
(6,6)
(11,13)
(7,7)
(9,12)
(3,3)
(10,5)
![Page 34: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/34.jpg)
The Superpaint ProblemInput
Output
4 32 12 34 1
one side of the square lattice
Locations of the cows (row,col)
5
The number of locations that "attack" all occupied squares
with a Queen's move
Row 1 . . . .C . C . . . . .C . . .
number of occupied squares
Row 2
Row 3
Row 4
Col 1
Col 2
Col 3
Col 4
Row 1 . . . .B . B . . B . .B . B .
Row 2
Row 3
Row 4
Col 1
Col 2
Col 3
Col 4
![Page 35: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/35.jpg)
The Screens ProblemInput
Output
# of test cases
Vertices of the room
Data Set 1:90.00%
The total fraction of the presentation you can observe (all screens' contributions!)
# of projector screens
# of room vertices
(x,y) location of "you"
Line segments of the screens
room
oriented screens
![Page 36: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/36.jpg)
The EE ProblemInput
Output
# of test cases
Data Set 1:10.813.420.00The strength of the signal at each test location ==
1.0/(closest visible router ** 2)
# of room vertices, # of routers, # of test points
vertices of the room
Locations of the routers
test locations
routers
example input
Locations of the test points
+
+
+
A
B
C
C
A B
![Page 37: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/37.jpg)
1 4 4 0.1 0.1 0.0 0.9 1.0 0.05 1.1 -0.1 -0.1 -0.1 0.8 0 1.1 0.5 0.7 0 0.3 0.5 0 0.3
The IE ProblemInput
Output
# of test cases
Data Set 1:2.32
The minimum total cost to supply all stores from some warehouse(s).
# of stores and possible warehouse locations
(x,y) location of stores
(x,y,price) location of warehouses and their cost to build in Mega$
S
S
S
SW
W
WW
$.3$.3
$.5
$.8
delivery cost = Euclidean distance
Industrial Engineering
![Page 38: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/38.jpg)
Convex Hull Problems…
• read over these problems…
• which ones are convex hull?
• which ones could be convex hull?
and the rest?
![Page 39: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/39.jpg)
Current Jotto standings…
Sophs Jrs Srs Others
icily 0 icily 0 icily 1 icily 1
strep 2 strep 2 strep 2 strep 1
spork 1 spork 3 spork 0 spork 0
spend 2 spend 2 spend 2 spend 2
peeps 2 peeps 1 peeps 2 peeps 1
furls 1 furls 1 furls 0 furls 1
Ghost 2 Ghost 1 Ghost 1 Ghost 0
Tanks 2 Tanks 1 Tanks 2 Tanks 1
Gecko 2 Gecko 1 Gecko 1 Gecko 1
Win! Quine 5
![Page 40: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/40.jpg)
What are these?
public int mystery1(Point A, Point B, Point P) { int cp1 = (B.x-A.x)*(P.y-A.y) - (B.y-A.y)*(P.x-A.x); if (cp1>0) return 1; else return -1;}
public int mystery2(Point A, Point B, Point C) { int ABx = B.x-A.x; int ABy = B.y-A.y; int num = ABx*(A.y-C.y)-ABy*(A.x-C.x); if (num < 0) num = -num; return num; }
![Page 41: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/41.jpg)
What are these?
public int mystery1(Point A, Point B, Point P) { int cp1 = (B.x-A.x)*(P.y-A.y) - (B.y-A.y)*(P.x-A.x); if (cp1>0) return 1; else return -1;}
public int mystery2(Point A, Point B, Point C) { int ABx = B.x-A.x; int ABy = B.y-A.y; int num = ABx*(A.y-C.y)-ABy*(A.x-C.x); if (num < 0) num = -num; return num; }
Hints:sortOfDistancewhichSide
![Page 42: ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring](https://reader030.vdocuments.net/reader030/viewer/2022032801/56649ddb5503460f94ad27e3/html5/thumbnails/42.jpg)