Help In A Simple Geometry Problem

Правка en2, от yashi, 2016-04-08 01:03:36

Hello Codeforces,

Recently I decided to start learning geometry so I found out that I have to start with the simple geometry, basic shapes, basic laws and cakewalk problems to set off my journey with geometry and computational geometry then, so I came across this problem from the gym,

Given a circle (the center of the circle |x|,|y| <= 1000, and the radius r <= 10000) .
Given a rectangle (the coordinates of the bottom-left corner and the upper-right corner, |x|,|y| <= 1000 as well) .
It's guaranteed that the upper-left corner of the rectangle is inside the circle, the width and the height of the rectangle are longer than 2.r .
you're to calculate the area of the intersection between the circle and the rectangle .

Here's what I did :



- Obtain the two lines P2-P3 let's say L1 and P2-P1 let's say L2 .
- Find the points of the intersection between the lines L1,L2 and the the circle, They're CL1, CL2 .
- Compute the angle (CL1 C CL2) theta .
- Compute the area of the circular sector determined by theta, say A .
- Subtract the area of the triangle (CL1 C CL2) from A .
- Add the area of the triangle (CL1 P2 CL2) to A and A is the answer .

So I keep getting WA for the couple past days. Since it's being the first time I write a geometry code I know it'd be so buggy and really it was, I've been debugging it for hours and I re-wrote it several times, and eventually I had no thing to do with it, I badly ran out of my shots :(
Here's my code .

It would be really appreciated if someone tells me what's going wrong (maybe it's my algorithm though, Now I doubt it's absolutely correct) Thanks in advance .

By the way, any advice, references, and problems would help a noob to kick-off in geometry would be highly appreciated as well .

Теги geometry, problem, gym

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский yashi 2016-04-08 01:03:36 16 Tiny change: 'tebin.com/S1Mkpmsv) . <br />' -> 'tebin.com/XRdBtLcY) . <br />'
en1 Английский yashi 2016-04-07 16:00:41 2231 Initial revision (published)