Geometry. Zachary Friggstad. Programming Club Meeting

Similar documents
Basics of Computational Geometry

2-D Geometry for Programming Contests 1

Computational Geometry. Geometry Cross Product Convex Hull Problem Sweep Line Algorithm

Section 10.1 Polar Coordinates

Lecture 7: Computational Geometry

Lecture 13 Geometry and Computational Geometry

Section 4.1: Introduction to Trigonometry

You ll use the six trigonometric functions of an angle to do this. In some cases, you will be able to use properties of the = 46

If three points A (h, 0), P (a, b) and B (0, k) lie on a line, show that: a b 1.

Differential Geometry: Circle Patterns (Part 1) [Discrete Conformal Mappinngs via Circle Patterns. Kharevych, Springborn and Schröder]

Computational Geometry. HKU ACM ICPC Training 2010

Lecture 14: Computational Geometry Steven Skiena. skiena

Prof. Gill Barequet. Center for Graphics and Geometric Computing, Technion. Dept. of Computer Science The Technion Haifa, Israel

Geometry Reasons for Proofs Chapter 1

Planar convex hulls (I) Computational Geometry [csci 3250] Laura Toma Bowdoin College

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6. ) is graphed below:

Voronoi Diagrams and Delaunay Triangulations. O Rourke, Chapter 5

2D Geometry. Pierre Alliez Inria Sophia Antipolis

Geometry - Chapter 1 - Corrective #1

Geometric Computations for Simulation

CSE 5311 Notes 13: Computational Geometry

Grids Geometry Computational Geometry

Unit Circle. Project Response Sheet

2 Geometry Solutions

COMPUTATIONAL GEOMETRY

A trigonometric ratio is a,

Computational Geometry

Computational Geometry Algorithmische Geometrie

Park Forest Math Team. Meet #3. Self-study Packet

Optimal Compression of a Polyline with Segments and Arcs

GCSE-AS Mathematics Bridging Course. Chellaston School. Dr P. Leary (KS5 Coordinator) Monday Objectives. The Equation of a Line.

Triangulation and Convex Hull. 8th November 2018

CS 97SI: INTRODUCTION TO PROGRAMMING CONTESTS. Jaehyun Park

1. Use the Trapezium Rule with five ordinates to find an approximate value for the integral

COS 226 Lecture 15: Geometric algorithms. Warning: intuition may mislead (continued)

CS 532: 3D Computer Vision 14 th Set of Notes

Week 8 Voronoi Diagrams

Trigonometry and the Unit Circle. Chapter 4

3. Voronoi Diagrams. 3.1 Definitions & Basic Properties. Examples :

ICS 161 Algorithms Winter 1998 Final Exam. 1: out of 15. 2: out of 15. 3: out of 20. 4: out of 15. 5: out of 20. 6: out of 15.

Point A location in geometry. A point has no dimensions without any length, width, or depth. This is represented by a dot and is usually labelled.

Math 1 Plane Geometry part 3 Unit Updated July 28, 2016

MEI Casio Tasks for A2 Core

Videos, Constructions, Definitions, Postulates, Theorems, and Properties

Unit 1, Lesson 1: Moving in the Plane

Math 3C Section 9.1 & 9.2

(Refer Slide Time: 00:02:00)

Weighted Graph Algorithms Presented by Jason Yuan

by Kevin M. Chevalier

Transform 1: Translate, Matrices

Mathematics Curriculum

Lecture 3: Art Gallery Problems and Polygon Triangulation

Moore Catholic High School Math Department

3D convex hulls. Computational Geometry [csci 3250] Laura Toma Bowdoin College

Intersection of an Oriented Box and a Cone

EOC Review: Practice: 1. In the circle below, AB = 2BC. What is the probability of hitting the shaded region with a random dart?

6 Mathematics Curriculum

CS 130 Final. Fall 2015

Unit 6: Connecting Algebra and Geometry Through Coordinates

3.0 Trigonometry Review

Forces acting on a lamina

Unit 7. Transformations

The Art Gallery Problem: An Overview and Extension to Chromatic Coloring and Mobile Guards

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6

MEI GeoGebra Tasks for A2 Core

Geometric Algorithms. 1. Objects

Polar Coordinates. 2, π and ( )

pine cone Ratio = 13:8 or 8:5

Study Guide - Geometry

Computational Geometry. Lecture 17

Vector Addition. Qty Item Part Number 1 Force Table ME-9447B 1 Mass and Hanger Set ME Carpenter s level 1 String

Math 144 Activity #2 Right Triangle Trig and the Unit Circle

Lecture 13: Geometry Steven Skiena. skiena

Minimum-Area Rectangle Containing a Set of Points

Hidden-Surface Removal.

Algebra II. Slide 1 / 162. Slide 2 / 162. Slide 3 / 162. Trigonometric Functions. Trig Functions

Lesson 1. Unit 2 Practice Problems. Problem 2. Problem 1. Solution 1, 4, 5. Solution. Problem 3

Parallel Lines Investigation

Computational Geometry

Solution Notes. COMP 151: Terms Test

Unit 13: Periodic Functions and Trig

Computational Geometry

MA 154 Lesson 1 Delworth

Angles. An angle is: the union of two rays having a common vertex.

Math 2 Coordinate Geometry Part 3 Inequalities & Quadratics

DEFINITIONS. Perpendicular Two lines are called perpendicular if they form a right angle.

B.Stat / B.Math. Entrance Examination 2017

1 Affine and Projective Coordinate Notation

Voronoi diagrams Delaunay Triangulations. Pierre Alliez Inria

Chapter 4: Trigonometry

Mathematics. Jaehyun Park. CS 97SI Stanford University. June 29, 2015

with slopes m 1 and m 2 ), if and only if its coordinates satisfy the equation y y 0 = 0 and Ax + By + C 2

Generalized barycentric coordinates

Module Four: Connecting Algebra and Geometry Through Coordinates

Polygon Triangulation

Flavor of Computational Geometry. Voronoi Diagrams. Shireen Y. Elhabian Aly A. Farag University of Louisville

8. The triangle is rotated around point D to create a new triangle. This looks like a rigid transformation.

Math for Geometric Optics

SNAP Centre Workshop. Introduction to Trigonometry

F dr = f dx + g dy + h dz. Using that dz = q x dx + q y dy we get. (g + hq y ) x (f + hq x ) y da.

Transcription:

Geometry Zachary Friggstad Programming Club Meeting

Points #i n c l u d e <complex> typedef complex<double> p o i n t ; p o i n t p ( 1. 0, 5. 7 ) ; p. r e a l ( ) ; // x component p. imag ( ) ; // y component

Points #i n c l u d e <complex> typedef complex<double> p o i n t ; p o i n t p ( 1. 0, 5. 7 ) ; p. r e a l ( ) ; // x component p. imag ( ) ; // y component Helpful operations p o i n t p, q ; p+q ; // exactly what you expect p = p o l a r ( 1, t h e t a ) ; // rotate around (0,0) by theta radians abs ( p q ) ; // distance between p and q a r g ( p ) ; // angle from positive x- axis, measured in (-pi, pi]

Points #i n c l u d e <complex> typedef complex<double> p o i n t ; p o i n t p ( 1. 0, 5. 7 ) ; p. r e a l ( ) ; // x component p. imag ( ) ; // y component Helpful operations p o i n t p, q ; p+q ; // exactly what you expect p = p o l a r ( 1, t h e t a ) ; // rotate around (0,0) by theta radians abs ( p q ) ; // distance between p and q a r g ( p ) ; // angle from positive x- axis, measured in (-pi, pi] One Annoyance: we can t update the x and y components without creating a new point.

Dot Product p q = p x q x + p y q y = p q cos θ double dot ( p o i n t p, p o i n t q ) { return r e a l ( p c o n j ( q ) ) ; } negative side p positive side q

Dot Product p q = p x q x + p y q y = p q cos θ double dot ( p o i n t p, p o i n t q ) { return r e a l ( p c o n j ( q ) ) ; } negative side p positive side q p q = 0 if p q (or one of them is 0) p p = p 2 p q > 0: q lies in the same general direction as p p q < 0: q lies in the opposite general direction as p

Cross Product p q = p x q y p y q x = p q sin θ double c r o s s ( p o i n t p, p o i n t q ) { return imag ( p c o n j ( q ) ) ; } q positive side (CCW turn from p) p negative side (CW turn from p)

Cross Product p q = p x q y p y q x = p q sin θ double c r o s s ( p o i n t p, p o i n t q ) { return imag ( p c o n j ( q ) ) ; } q positive side (CCW turn from p) p negative side (CW turn from p) p q = 0 if p and q are collinear with 0 (or one of them is 0) p q > 0: (p, q) is counterclockwise p q < 0: (p, q) is clockwise

1 2 (p r) (q r) is the area of the triangle with corners p, q, r. q r p

1 2 (p r) (q r) is the area of the triangle with corners p, q, r. q r p Tip: p lies on the line passing through points q and r if and only if (q p) (r p) = 0. r p q Additionally: if p lies on this line then it lies between q and r if and only if (q p) (r p) 0.

Parametric representation of a line passing through p and q: r(t) = (1 t) p + t q, t R p q Note r(0) = p and r(1) = q.

Parametric representation of a line passing through p and q: r(t) = (1 t) p + t q, t R p q Note r(0) = p and r(1) = q. The line segment connecting p and q is parameterized this way, with the restriction 0 t 1.

Given two lines passing through p, q and p, q respectively, compute their intersection point (if any). Solve (1 t) p + t q = (1 t )p + t q for t, t R.

Given two lines passing through p, q and p, q respectively, compute their intersection point (if any). Solve (1 t) p + t q = (1 t )p + t q for t, t R. [ qx p x p x q x ] [ ] [ ] t p q y p y p y q y t = x p x p y p y

Given two lines passing through p, q and p, q respectively, compute their intersection point (if any). Solve (1 t) p + t q = (1 t )p + t q for t, t R. [ qx p x p x q x ] [ ] [ ] t p q y p y p y q y t = x p x p y p y Use Cramer s rule: for A x = b we have x i = det A i det A Where A i is the matrix obtained by replacing column i of A with b.

Given two lines passing through p, q and p, q respectively, compute their intersection point (if any). Solve (1 t) p + t q = (1 t )p + t q for t, t R. [ qx p x p x q x ] [ ] [ ] t p q y p y p y q y t = x p x p y p y Use Cramer s rule: for A x = b we have x i = det A i det A Where A i is the matrix obtained by replacing column i of A with b. [ ] a b Tip: det = ad bc. c d det A = 0 means the lines are parallel.

Code Note the 2 2 determinants can just be replaced by cross products! // find where lines p1q1 and p2q2 intersect // assumes p1!= q1, p2!= q2 p o i n t i s e c t ( p o i n t p1, p o i n t q1, p o i n t p2, p o i n t q2 ) { double den = c r o s s ( q1 p1, p2 q2 ) ; if ( f a b s ( den ) < EPS) { // parallel lines, do whatever you want // they coincide iff fabs( cross(p1 -p2, q1 - p2)) < 1e-8 } double t = c r o s s ( p2 p1, p2 q2 )/ den ; } return (1 t ) p1 + t q1 ;

Computing the intersection of two line segments. q' p' p q If the infinite lines intersect (i.e. not parallel), get values t, t. Ensure 0 t 1 and 0 t 1.

Computing the intersection of two line segments. q' p' p q If the infinite lines intersect (i.e. not parallel), get values t, t. Ensure 0 t 1 and 0 t 1. If lines are colinear: q' q p' p q' p If p = p and q = q or vice versa, they overlap. Else if a point is in the interior of the other segment, they overlap. Else if the segments share a point, they touch only at that point. Else they do not touch. q p'

Closest point on a line. Given a line passing through p, q and another point c, find the point r on the line pq nearest to c. c p r q

Closest point on a line. Given a line passing through p, q and another point c, find the point r on the line pq nearest to c. c p r q Assume c = (0, 0) by shifting if necessary. Minimize (1 t)p + t q 2 over t R (avoids the square root).

Closest point on a line. Given a line passing through p, q and another point c, find the point r on the line pq nearest to c. c p r q Assume c = (0, 0) by shifting if necessary. Minimize (1 t)p + t q 2 over t R (avoids the square root). This is just minimizing some quadratic: A t 2 + B t + C Tip: the minimum is at B 2A. If A = 0, then p = q.

Code After working out details... // return the point on the line pq closest to c p o i n t c l o s e s t p o i n t ( p o i n t p, p o i n t q, p o i n t c ) { p = c ; q = c ; double den = norm ( p q ) ; if ( f a b s ( den ) < 1e 8) { // p=q, do whatever you want } double t = dot ( p, p q )/ den ; return (1 t ) p + t q + c ; }

Line-Circle Intersection A line pq and a circle (r, c) (radius/center point) does the line puncture the circle? p q r c

Line-Circle Intersection A line pq and a circle (r, c) (radius/center point) does the line puncture the circle? p q r c Assume c = 0 by shifting and solve (1 t) p + t q 2 = r 2 for t.

Line-Circle Intersection A line pq and a circle (r, c) (radius/center point) does the line puncture the circle? p q r c Assume c = 0 by shifting and solve (1 t) p + t q 2 = r 2 for t. Rearrange: A t 2 + B t + C = 0. A = 0 means p = q. Tip: Use the quadratic formula B ± 2A where = B 2 4AC.

Line-Circle Intersection A line pq and a circle (r, c) (radius/center point) does the line puncture the circle? p q r c Assume c = 0 by shifting and solve (1 t) p + t q 2 = r 2 for t. Rearrange: A t 2 + B t + C = 0. A = 0 means p = q. Tip: Use the quadratic formula B ± where = B 2 4AC. 2A < 0: line misses, = 0: line tangent, > 0: line punctures.

Code // return # of intersections and set parameters // z1, z2 to these points ( if applicable ) int l i n e c i r c l e ( p o i n t c, double r, p o i n t p, p o i n t q, p o i n t& z1, p o i n t& z2 ) { p = c ; q = c ; double A = norm ( p q ), B = 2 dot ( p, q p ), C = norm ( p) r r ; double d i s c = B B 4 A C ; if ( d i s c + EPS < 0) return 0 ; double r t = s q r t ( f a b s ( d i s c ) ) ; double t1 = ( B+r t )/(2 A ) ; double t2 = ( B r t )/(2 A ) ; } z1 = (1 t1 ) p + t1 q + c ; z2 = (1 t2 ) p + t2 q + c ; return ( d i s c < EPS? 1 : 2 ) ;

Point q in Polygon P : p 1,..., p n? Intuition: walk about the polygon with a rope taut with post q. starting point rope q If q is inside, the rope wraps around once. If q is outside, the rope doesn t wrap around.

Point q in Polygon P : p 1,..., p n? Intuition: walk about the polygon with a rope taut with post q. starting point rope q If q is inside, the rope wraps around once. If q is outside, the rope doesn t wrap around. double d e l t a = 0 ; for ( int i = 0, j = n 1; i < n ; j = i ++) d e l t a += arg ( ( p [ i ] q ) / ( p [ j ] q ) ) ; // change in angle return f a b s ( d e l t a ) > 1 ; // delta is 0 or 2*pi

Point q in Polygon P : p 1,..., p n? Intuition: walk about the polygon with a rope taut with post q. starting point rope q If q is inside, the rope wraps around once. If q is outside, the rope doesn t wrap around. double d e l t a = 0 ; for ( int i = 0, j = n 1; i < n ; j = i ++) d e l t a += arg ( ( p [ i ] q ) / ( p [ j ] q ) ) ; // change in angle return f a b s ( d e l t a ) > 1 ; // delta is 0 or 2*pi Have to add a bit more to check if q lies on the boundary (cross and dot product test mentioned earlier).

Area of a Polygon P : p 1,..., p n 2 1 2 1 5 5 3 4 origin 3 4 origin blue triangle: count the area positively (CCW turn about origin) red triangle: count the area negatively (CW turn about origin)

Area of a Polygon P : p 1,..., p n 2 1 2 1 5 5 3 4 origin 3 4 origin blue triangle: count the area positively (CCW turn about origin) red triangle: count the area negatively (CW turn about origin) double a r e a = 0 ; for ( int i = 0, j = n 1; i < n ; j = i ++) // signed area of triangle [ origin, p[i-1], p[i]] a r e a += c r o s s ( p [ i ], p [ j ] ) 0. 5 ; return f a b s ( a r e a ) ;

Area of a Polygon P : p 1,..., p n 2 1 2 1 5 5 3 4 origin 3 4 origin blue triangle: count the area positively (CCW turn about origin) red triangle: count the area negatively (CW turn about origin) double a r e a = 0 ; for ( int i = 0, j = n 1; i < n ; j = i ++) // signed area of triangle [ origin, p[i-1], p[i]] a r e a += c r o s s ( p [ i ], p [ j ] ) 0. 5 ; return f a b s ( a r e a ) ; Points outside are cancelled, points inside are counted +1 times (after cancelling). The net sum is the area of P.

Convex Hull Given points p 1,..., p n, what is their convex hull? Output: The points on the convex hull in CCW order.

Convex Hull Given points p 1,..., p n, what is their convex hull? Output: The points on the convex hull in CCW order.

Convex Hull The bottom-most point must be on the convex hull. If there are many, choose the leftmost. Suppose this point is (0, 0) by shifting all points if needed. 10 9 8 6 7 5 4 3 2 1 Sort all other points by their angle with the positive x-axis. To check if p i < p j according to this order:

Convex Hull The bottom-most point must be on the convex hull. If there are many, choose the leftmost. Suppose this point is (0, 0) by shifting all points if needed. 10 9 8 6 7 5 4 3 2 1 Sort all other points by their angle with the positive x-axis. To check if p i < p j according to this order: check p i p j > 0.

The origin and the first point after sorting are on the hull for sure. Build the hull one point at a time: add the points in the sorted order. 9 8 7 5 4 10 6 3 2 1 If one creates a clockwise turn with the previous two on the hull, then pop the end of the current hull.

The origin and the first point after sorting are on the hull for sure. Build the hull one point at a time: add the points in the sorted order. 9 8 7 CW turn 5 4 10 6 3 2 1 If one creates a clockwise turn with the previous two on the hull, then pop the end of the current hull.

The origin and the first point after sorting are on the hull for sure. Build the hull one point at a time: add the points in the sorted order. 9 8 7 CW turn 5 4 10 6 3 2 1 If one creates a clockwise turn with the previous two on the hull, then pop the end of the current hull.

The origin and the first point after sorting are on the hull for sure. Build the hull one point at a time: add the points in the sorted order. 9 8 7 CCW turn 5 4 10 6 3 2 1 If one creates a clockwise turn with the previous two on the hull, then pop the end of the current hull.

The origin and the first point after sorting are on the hull for sure. Build up the hull one point at a time: add the points in the sorted order. 9 8 7 CCW turn 5 4 10 6 3 2 1 If one creates a clockwise turn with the previous two on the hull, then pop the end of the current hull.

bool cmp( p o i n t a, p o i n t b ) { return c r o s s ( a, b ) > 0 ; } p o i n t p [MAXN], h u l l [MAXN] ; // Assume p[n -1] is the lowest point ( breaking ties by // taking leftmost ) and no 3 points are collinear for ( int i = 0 ; i < n 1; ++i ) p [ i ] = p [ n 1]; s o r t ( p, p+n 1, cmp ) ; // sort by angle from x-axis h u l l [ 0 ] = p o i n t ( 0, 0 ) ; h u l l [ 1 ] = p [ 0 ] ; int hs = 2 ; for ( int i = 1 ; i < n 1; ++i ) { while ( c r o s s ( h u l l [ hs 1] h u l l [ hs 2], p [ i ] h u l l [ hs 2]) < 0) hs ; h u l l [ hs++] = p [ i ] ; } for ( int i = 0 ; i < hs ; ++i ) h u l l [ i ] += p [ n 1]; Running time: O(n log n)

Tips Never use float, not enough precision. Use double.

Tips Never use float, not enough precision. Use double. const double PI = acos ( 1.0);

Tips Never use float, not enough precision. Use double. const double PI = acos ( 1.0); Sometimes values that should be equal aren t quite due to floating point errors.

Tips Never use float, not enough precision. Use double. const double PI = acos ( 1.0); Sometimes values that should be equal aren t quite due to floating point errors. Safer comparisons. #d e f i n e EPS 1e 8 double a, b ; if ( f a b s ( a b ) < EPS)... // check if a == b if ( a + EPS < b )... // check if a < b if ( a < b + EPS)... // check if a <= b

Tips Never use float, not enough precision. Use double. const double PI = acos ( 1.0); Sometimes values that should be equal aren t quite due to floating point errors. Safer comparisons. #d e f i n e EPS 1e 8 double a, b ; if ( f a b s ( a b ) < EPS)... // check if a == b if ( a + EPS < b )... // check if a < b if ( a < b + EPS)... // check if a <= b Can there be 3 collinear points? Can points be equal? How can you deal with this?

Missing Topics Voronoi diagrams/delaunay triangulations, 3D convex hull, closest pair of points, furthest pair of points, triangulating a polygon. Next Time Number Theory Some Topics To Come Combinatorics and Arithmetic String Processing Matchings and Network Flow Probability Theory

Open Kattis - polygonarea https://open.kattis.com/problems/polygonarea

Open Kattis - polygonarea https://open.kattis.com/problems/polygonarea We already talked about how to compute the area of a polygon.

Open Kattis - polygonarea https://open.kattis.com/problems/polygonarea We already talked about how to compute the area of a polygon. How can you check if it is in CW or CCW order?

Open Kattis - polygonarea https://open.kattis.com/problems/polygonarea We already talked about how to compute the area of a polygon. How can you check if it is in CW or CCW order? Solution: check if the area is positive before returning the absolute value: > 0 means CCW, < 0 means CW.

Open Kattis - rafting https://open.kattis.com/problems/wrapping

Open Kattis - rafting https://open.kattis.com/problems/wrapping Think: what can we say about the polygon at the tightest squeeze point of the ride.

Open Kattis - rafting https://open.kattis.com/problems/wrapping Think: what can we say about the polygon at the tightest squeeze point of the ride. Will there be a vertex of a polygon at the tightest squeeze?

Open Kattis - rafting https://open.kattis.com/problems/wrapping Think: what can we say about the polygon at the tightest squeeze point of the ride. Will there be a vertex of a polygon at the tightest squeeze? For each vertex, find the shortest distance to all other line segments on the other polygon (do for both polygons). Running time:

Open Kattis - rafting https://open.kattis.com/problems/wrapping Think: what can we say about the polygon at the tightest squeeze point of the ride. Will there be a vertex of a polygon at the tightest squeeze? For each vertex, find the shortest distance to all other line segments on the other polygon (do for both polygons). Running time: O(n 2 ).

Open Kattis - wrapping https://open.kattis.com/problems/wrapping

Open Kattis - wrapping https://open.kattis.com/problems/wrapping Basic approach: The total area of the objects is simple, you know the width and height of each (rectangle area = w h).

Open Kattis - wrapping https://open.kattis.com/problems/wrapping Basic approach: The total area of the objects is simple, you know the width and height of each (rectangle area = w h). You need the actual corners to compute the convex hull. Rotate the four corners of the axis-parallel rectangles. by the given angle: simple using complex points (recall: radians = π 180 degrees).

Open Kattis - wrapping https://open.kattis.com/problems/wrapping Basic approach: The total area of the objects is simple, you know the width and height of each (rectangle area = w h). You need the actual corners to compute the convex hull. Rotate the four corners of the axis-parallel rectangles. by the given angle: simple using complex points (recall: radians = π 180 degrees). Find the convex hull.

Open Kattis - wrapping https://open.kattis.com/problems/wrapping Basic approach: The total area of the objects is simple, you know the width and height of each (rectangle area = w h). You need the actual corners to compute the convex hull. Rotate the four corners of the axis-parallel rectangles. by the given angle: simple using complex points (recall: radians = π 180 degrees). Find the convex hull. Compute the area of the convex hull using the algorithm discussed earlier. Running time:

Open Kattis - wrapping https://open.kattis.com/problems/wrapping Basic approach: The total area of the objects is simple, you know the width and height of each (rectangle area = w h). You need the actual corners to compute the convex hull. Rotate the four corners of the axis-parallel rectangles. by the given angle: simple using complex points (recall: radians = π 180 degrees). Find the convex hull. Compute the area of the convex hull using the algorithm discussed earlier. Running time: O(n log n)

Open Kattis - goofy https://open.kattis.com/problems/wrapping

Open Kattis - goofy https://open.kattis.com/problems/wrapping Basic approach: Consider the line L passing through the given point p and point y (a parameter) on the vertical axis.

Open Kattis - goofy https://open.kattis.com/problems/wrapping Basic approach: Consider the line L passing through the given point p and point y (a parameter) on the vertical axis. Use the quadratic expression (1 t) (0, y) + t p 2 = 1. Expand and rearrange in terms of t.

Open Kattis - goofy https://open.kattis.com/problems/wrapping Basic approach: Consider the line L passing through the given point p and point y (a parameter) on the vertical axis. Use the quadratic expression (1 t) (0, y) + t p 2 = 1. Expand and rearrange in terms of t. The line L is tangent to the circle if the discriminant.

Open Kattis - goofy https://open.kattis.com/problems/wrapping Basic approach: Consider the line L passing through the given point p and point y (a parameter) on the vertical axis. Use the quadratic expression (1 t) (0, y) + t p 2 = 1. Expand and rearrange in terms of t. The line L is tangent to the circle if the discriminant. The discriminant is a quadratic in y, solve for = 0 using the quadratic formula to get the two values of y.

Open Kattis - goofy https://open.kattis.com/problems/wrapping Basic approach: Consider the line L passing through the given point p and point y (a parameter) on the vertical axis. Use the quadratic expression (1 t) (0, y) + t p 2 = 1. Expand and rearrange in terms of t. The line L is tangent to the circle if the discriminant. The discriminant is a quadratic in y, solve for = 0 using the quadratic formula to get the two values of y. Caution: carefully check each step of your calculations!