Skip to content

Commit 45ae5ab

Browse files
committed
Geometry updates
- Add reminder about line equations - Fix tangent_outer - Add tangent_inner
1 parent 84f2742 commit 45ae5ab

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎code/geometry/circles.cpp‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ int tangent(P(A), C(O, r), point &r1, point &r2) {
2222
v = normalize(v, L);
2323
r1 = A + rotate(v, alpha), r2 = A + rotate(v, -alpha);
2424
return 1 + (abs(v) > EPS); }
25-
void tangent_outer(point A, double rA,
26-
point B, double rB, PP(P), PP(Q)) {
27-
if (rA - rB > EPS) { swap(rA, rB); swap(A, B); }
25+
void tangent_outer(C(A,rA), C(B,rB), PP(P), PP(Q)) {
26+
// if (rA - rB > EPS) { swap(rA, rB); swap(A, B); }
2827
double theta = asin((rB - rA)/abs(A - B));
2928
point v = rotate(B - A, theta + pi/2),
3029
u = rotate(B - A, -(theta + pi/2));
@@ -33,4 +32,8 @@ void tangent_outer(point A, double rA,
3332
P.second = B + normalize(v, rB);
3433
Q.first = A + normalize(u, rA);
3534
Q.second = B + normalize(u, rB); }
35+
void tangent_inner(C(A,rA), C(B,rB), PP(P), PP(Q)) {
36+
point ip = (rA*B + rB*A)/(rA+rB);
37+
assert(tangent(ip, A, rA, P.first, Q.first) == 2);
38+
assert(tangent(ip, B, rB, P.second, Q.second) == 2); }
3639
// vim: cc=60 ts=2 sts=2 sw=2:

‎comprog.pdf‎

946 Bytes
Binary file not shown.

‎comprog.tex‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ \section{Geometry}
751751
\item $a\times b$ is equal to the area of the parallelogram with
752752
two of its sides formed by $a$ and $b$. Half of that is the
753753
area of the triangle formed by $a$ and $b$.
754+
\item The line going through $a$ and $b$ is $Ax+By=C$ where $A=b_y-a_y$, $B=a_x-b_x$, $C=Aa_x+Ba_y$.
755+
\item Two lines $A_1x+B_1y=C_1$, $A_2x+B_2y=C_2$ are parallel iff.\ $D=A_1B_2-A_2B_1$ is zero. Otherwise their unique intersection is $(B_2C_1-B_1C_2,A_1C_2-A_2C_1)/D$.
754756
\item \textbf{Euler's formula:} $V - E + F = 2$
755757
\item Side lengths $a,b,c$ can form a triangle iff.\ $a+b>c$, $b+c>a$ and $a+c>b$.
756758
\item Sum of internal angles of a regular convex $n$-gon is $(n-2)\pi$.

0 commit comments

Comments
 (0)