Skip to content

Coordinate Geometry

Updated Β· Equations updated; Sections updated; Examples or practice updated; Explanations expanded What changed?
  1. β€” Equations updated; Sections updated; Examples or practice updated; Explanations expanded

Coordinates replace geometric relations by equations. A good placement reduces the number of variables before the calculation begins.

Place a convenient vertex at the origin, a useful side on the horizontal axis, or a symmetry line on an axis. Use (0,0),(u,0),(v,w)(0,0),(u,0),(v,w) for a general triangle rather than assigning six unrelated coordinates. Normalize a length to one only when the requested result is unchanged by scaling, or restore the scale at the end.

Example. A triangle has AB=6AB=6, AC=5AC=5, and BC=5BC=5. Find its altitude from CC to ABAB using coordinates.

Place A=(βˆ’3,0)A=(-3,0) and B=(3,0)B=(3,0). Equal distances to A,BA,B put CC on the vertical axis, so write C=(0,h)C=(0,h) with h>0h>0. Then 9+h2=259+h^2=25, giving h=4h=4.


For A=(x1,y1)A=(x_1,y_1) and B=(x2,y2)B=(x_2,y_2),

AB2=(x2βˆ’x1)2+(y2βˆ’y1)2.AB^2=(x_2-x_1)^2+(y_2-y_1)^2.

The midpoint is the coordinate average. If PP divides ABAB internally in the ratio AP:PB=m:nAP:PB=m:n, then

P=nA+mBm+n.P=\frac{nA+mB}{m+n}.

The larger weight is attached to the endpoint toward which PP moves. This vector formula applies to each coordinate separately.

Example. Points A=(1,2)A=(1,2) and B=(7,5)B=(7,5) have an internal division point PP with AP:PB=2:1AP:PB=2:1. Find PP.

The point is two-thirds of the way from AA to BB:

P=A+2B3=(5,4).P=\frac{A+2B}{3}=\left(5,4\right).

A line can be written as ax+by=cax+by=c or parametrically as A+tuA+t\mathbf u, where u\mathbf u is a nonzero direction vector. The parametric form handles vertical lines without a special slope.

For finite slopes, parallel lines have equal slopes and perpendicular lines satisfy m1m2=βˆ’1m_1m_2=-1. Vectors give a version that also handles vertical and horizontal lines:

uβŠ₯vβ€…β€ŠβŸΊβ€…β€Šuβ‹…v=0,\mathbf u\perp\mathbf v\iff\mathbf u\cdot\mathbf v=0,

where (u1,u2)β‹…(v1,v2)=u1v1+u2v2(u_1,u_2)\cdot(v_1,v_2)=u_1v_1+u_2v_2. The dot product also gives the angle through uβ‹…v=βˆ₯uβˆ₯βˆ₯vβˆ₯cos⁑θ\mathbf u\cdot\mathbf v=\lVert\mathbf u\rVert\lVert\mathbf v\rVert\cos\theta.

Example. Find the foot of the perpendicular from P=(4,3)P=(4,3) to the line through the origin with direction vector u=(2,1)\mathbf u=(2,1).

The foot has the form F=tuF=t\mathbf u. Perpendicularity requires (Pβˆ’tu)β‹…u=0(P-t\mathbf u)\cdot\mathbf u=0, so

t=Pβ‹…uuβ‹…u=115.t=\frac{P\cdot\mathbf u}{\mathbf u\cdot\mathbf u}=\frac{11}{5}.

Thus F=(22/5,11/5)F=(22/5,11/5).

More generally, the distance from (x0,y0)(x_0,y_0) to ax+by=cax+by=c is ∣ax0+by0βˆ’c∣/a2+b2\lvert ax_0+by_0-c\rvert/\sqrt{a^2+b^2} for (a,b)β‰ (0,0)(a,b)\ne(0,0).


A circle with center (h,k)(h,k) and radius rr has equation (xβˆ’h)2+(yβˆ’k)2=r2(x-h)^2+(y-k)^2=r^2. Completing squares identifies its center from an expanded equation.

When two circle equations have the same quadratic terms, subtract them. The squared terms cancel, leaving the line containing their common points, if any.

Example. Find the intersection points of x2+y2=25x^2+y^2=25 and (xβˆ’6)2+y2=25(x-6)^2+y^2=25.

Subtracting the first equation from the second gives βˆ’12x+36=0-12x+36=0, so x=3x=3. Substitution into the first circle gives y2=16y^2=16. The intersections are (3,4)(3,4) and (3,βˆ’4)(3,-4).

The subtraction gives the radical axis, introduced in more detail on the radical axes and inversion page.


For vectors u=(u1,u2)\mathbf u=(u_1,u_2) and v=(v1,v2)\mathbf v=(v_1,v_2) from the same vertex, the triangle area is half the absolute determinant:

K=12∣u1v2βˆ’u2v1∣.K=\frac12\lvert u_1v_2-u_2v_1\rvert.

For a simple polygon whose vertices (xi,yi)(x_i,y_i) are listed in boundary order, the shoelace formula is

K=12βˆ£βˆ‘i=1n(xiyi+1βˆ’yixi+1)∣,K=\frac12\left\lvert\sum_{i=1}^n(x_iy_{i+1}-y_ix_{i+1})\right\rvert,

where the final vertex wraps back to the first. A scrambled vertex order does not trace the intended polygon.

For a simple polygon with integer-coordinate vertices, Pick’s theorem gives K=I+B/2βˆ’1K=I+B/2-1, where II counts interior lattice points and BB counts boundary lattice points.

Example. Find the number of lattice points strictly inside the triangle with vertices (0,0),(6,0),(0,4)(0,0),(6,0),(0,4).

Its area is 1212. A lattice segment with displacement (a,b)(a,b) has gcd⁑(∣a∣,∣b∣)+1\gcd(\lvert a\rvert,\lvert b\rvert)+1 lattice points including endpoints. Summing the GCDs around the triangle counts each boundary point once, so

B=gcd⁑(6,0)+gcd⁑(6,4)+gcd⁑(0,4)=6+2+4=12.B=\gcd(6,0)+\gcd(6,4)+\gcd(0,4)=6+2+4=12.

Pick’s theorem then gives I=12βˆ’12/2+1=7I=12-12/2+1=7.

For plane vectors, write det⁑(u,v)=u1v2βˆ’u2v1\det(\mathbf u,\mathbf v)=u_1v_2-u_2v_1. The determinant is zero exactly when the vectors are parallel, and its absolute value is the parallelogram area they span.

Suppose two lines are A+tuA+t\mathbf u and B+svB+s\mathbf v. If det⁑(u,v)β‰ 0\det(\mathbf u,\mathbf v)\ne0, take determinants of their intersection equation with each direction to get

t=det⁑(Bβˆ’A,v)det⁑(u,v),s=det⁑(Bβˆ’A,u)det⁑(u,v).t=\frac{\det(B-A,\mathbf v)}{\det(\mathbf u,\mathbf v)},\qquad s=\frac{\det(B-A,\mathbf u)}{\det(\mathbf u,\mathbf v)}.

This avoids vertical-line exceptions. The parameter values also locate the intersection: 0≀t≀10\le t\le1 means it lies on the segment from AA to A+uA+\mathbf u, rather than merely on its supporting line.

Example. Find the intersection of A+t(2,1)A+t(2,1) with B+s(1,βˆ’1)B+s(1,-1), where A=(0,0)A=(0,0) and B=(0,3)B=(0,3).

The common denominator is det⁑((2,1),(1,βˆ’1))=βˆ’3\det((2,1),(1,-1))=-3. The numerator for tt is det⁑((0,3),(1,βˆ’1))=βˆ’3\det((0,3),(1,-1))=-3, so t=1t=1. The intersection is (2,1)(2,1); substitution into the other line gives s=2s=2.

Thus the point is an endpoint of the first unit-parameter segment but lies beyond the second segment’s endpoint.

A zero determinant means the directions are parallel. Check one point to distinguish disjoint parallel lines from coincident lines rather than dividing by zero and treating the formula as meaningful.


Write a circle in the form

x2+y2+Dx+Ey+F=0.x^2+y^2+Dx+Ey+F=0.

Three noncollinear points give three linear equations for D,E,FD,E,F. The center is (βˆ’D/2,βˆ’E/2)(-D/2,-E/2) and the radius squared is (D2+E2)/4βˆ’F(D^2+E^2)/4-F. This is usually simpler than introducing the center and radius as three nonlinear unknowns.

Example. Find the circumcircle of the triangle with vertices (0,0),(6,0),(2,4)(0,0),(6,0),(2,4).

The first point gives F=0F=0. The second gives 36+6D=036+6D=0, so D=βˆ’6D=-6. The third gives 20βˆ’12+4E=020-12+4E=0, so E=βˆ’2E=-2.

The circle is

x2+y2βˆ’6xβˆ’2y=0,x^2+y^2-6x-2y=0,

or (xβˆ’3)2+(yβˆ’1)2=10(x-3)^2+(y-1)^2=10. Its center is (3,1)(3,1) and its radius is 10\sqrt{10}.

If the three points are collinear, no ordinary circle passes through them. The coefficient system then fails to determine a valid circle. Noncollinearity is the geometric condition behind the algebraic denominator.


A line at distance dd from a radius-RR circle’s center cuts a chord of length 2R2βˆ’d22\sqrt{R^2-d^2} when d<Rd<R. At d=Rd=R it is tangent, and for d>Rd>R there is no intersection.

This gives an efficient vector construction: find the perpendicular foot FF from the center to the line, take a unit direction u\mathbf u along the line, and write the intersections as

FΒ±R2βˆ’d2 u.F\pm\sqrt{R^2-d^2}\,\mathbf u.

Example. Find the intersections of x2+y2=25x^2+y^2=25 and 3x+4y=103x+4y=10.

The line’s normal vector is (3,4)(3,4) with length five, so the center-to-line distance is two. The foot is F=(6/5,8/5)F=(6/5,8/5). A unit direction along the line is (4,βˆ’3)/5(4,-3)/5.

The half-chord length is 21\sqrt{21}. Thus the two points are

(6+4215,8βˆ’3215),(6βˆ’4215,8+3215).\left(\frac{6+4\sqrt{21}}5,\frac{8-3\sqrt{21}}5\right),\qquad \left(\frac{6-4\sqrt{21}}5,\frac{8+3\sqrt{21}}5\right).

The projection approach keeps the symmetry of the two roots visible.

For a tangent line y=mx+by=mx+b to an origin-centered circle of radius RR, the distance condition becomes b2=R2(1+m2)b^2=R^2(1+m^2). This is the same condition obtained by setting the substitution quadratic’s discriminant to zero.


Reflection can turn a path that bends at a line into one straight segment. If PP is reflected across nβ‹…X=c\mathbf n\cdot X=c, then

Pβ€²=Pβˆ’2nβ‹…Pβˆ’cnβ‹…nn.P'=P-2\frac{\mathbf n\cdot P-c}{\mathbf n\cdot\mathbf n}\mathbf n.

The fraction gives the signed normal displacement to the line. Subtracting it twice crosses to the mirror image. The midpoint of PPβ€²PP' lies on the mirror line and the joining segment is perpendicular to it.

Example. Points A=(1,2)A=(1,2) and B=(7,4)B=(7,4) are above the horizontal axis. Find the point MM on that axis minimizing AM+MBAM+MB.

Reflect BB to Bβ€²=(7,βˆ’4)B'=(7,-4). For every allowed MM, MB=MBβ€²MB=MB', so the path length is at least ABβ€²AB' by the triangle inequality.

The segment from AA to Bβ€²B' crosses the axis one-third of the way along, at M=(3,0)M=(3,0). Equality is attained there, and the minimum is

ABβ€²=62+(βˆ’6)2=62.AB'=\sqrt{6^2+(-6)^2}=6\sqrt2.

If MM were restricted to a finite segment of the axis, the crossing point would need to lie on that segment. Otherwise the minimum may occur at an endpoint. A reflection proves a lower bound, but attainability still depends on the allowed set.


A general affine transformation preserves collinearity, parallelism, ratios along one line, and ratios of areas. It does not generally preserve angles, lengths, or circles.

For a problem involving only those preserved quantities, any nondegenerate triangle can be mapped to A=(0,0),B=(1,0),C=(0,1)A=(0,0),B=(1,0),C=(0,1). This reduces arithmetic while keeping the desired conclusion intact. Do not use this normalization in a metric problem without accounting for the distortion.

Example. Points P∈ABP\in AB and Q∈ACQ\in AC satisfy AP:PB=2:1AP:PB=2:1 and AQ:QC=1:2AQ:QC=1:2. Find [APQ]/[ABC][APQ]/[ABC].

In the reference triangle, P=(2/3,0)P=(2/3,0) and Q=(0,1/3)Q=(0,1/3). Determinants give

[APQ][ABC]=23β‹…13=29.\frac{[APQ]}{[ABC]}=\frac23\cdot\frac13=\frac29.

Because an affine transformation multiplies both areas by the same factor, this ratio holds in every nondegenerate triangle.

The same method proves the midpoint quadrilateral theorem: the four side midpoints of any convex quadrilateral form a parallelogram. Its adjacent side vectors are half the original diagonals, so parallelism follows immediately. Expanding the determinant area shows its area is half the original quadrilateral’s.


For a segment joining lattice points with displacement (a,b)(a,b), its boundary count depends on gcd⁑(∣a∣,∣b∣)\gcd(\lvert a\rvert,\lvert b\rvert). The intermediate lattice points occur at equal fractions of the segment after reducing the direction vector to coprime coordinates.

A right triangle with vertices (0,0),(a,0),(0,b)(0,0),(a,0),(0,b), for positive integers a,ba,b, has area ab/2ab/2 and boundary count a+b+gcd⁑(a,b)a+b+\gcd(a,b). Pick’s theorem therefore gives

I=abβˆ’aβˆ’bβˆ’gcd⁑(a,b)+22.I=\frac{ab-a-b-\gcd(a,b)+2}{2}.

For a slanted lattice triangle, use the determinant for area and the three edge GCDs for boundary points. Counting endpoints separately on every side would count each vertex twice.

Example. Find the number of interior lattice points in the triangle (0,0),(8,0),(3,6)(0,0),(8,0),(3,6).

The area is twenty-four. The boundary count is

B=gcd⁑(8,0)+gcd⁑(5,6)+gcd⁑(3,6)=8+1+3=12.B=\gcd(8,0)+\gcd(5,6)+\gcd(3,6)=8+1+3=12.

Thus I=24βˆ’12/2+1=19I=24-12/2+1=19.

Pick’s theorem requires a simple polygon with lattice vertices. A rational-coordinate polygon cannot be substituted directly without first changing the lattice and adjusting the area consistently.


For A=(0,0),B=(c,0),C=(u,h)A=(0,0),B=(c,0),C=(u,h) with h≠0h\ne0, the circumcenter lies on x=c/2x=c/2. Equating its squared distances to A,CA,C gives

O=(c2,u2+h2βˆ’cu2h).O=\left(\frac c2,\frac{u^2+h^2-cu}{2h}\right).

The altitude from CC has equation x=ux=u. The altitude from AA is perpendicular to vector (uβˆ’c,h)(u-c,h), so its points satisfy (uβˆ’c)x+hy=0(u-c)x+hy=0. Therefore

H=(u,u(cβˆ’u)h).H=\left(u,\frac{u(c-u)}h\right).

Example. Find the circumcenter and orthocenter for A=(0,0),B=(10,0),C=(4,6)A=(0,0),B=(10,0),C=(4,6).

The formulas give O=(5,1)O=(5,1) and H=(4,4)H=(4,4). The centroid is G=(14/3,2)G=(14/3,2), and 3Gβˆ’2O=(4,4)=H3G-2O=(4,4)=H checks the Euler-line relation.

No inverse trigonometric functions are needed; perpendicular-bisector and altitude equations determine the centers directly.


Let GG be the average of fixed points A1,…,AnA_1,\ldots,A_n. Expanding Pβˆ’Ai=(Pβˆ’G)+(Gβˆ’Ai)P-A_i=(P-G)+(G-A_i) gives

βˆ‘iβˆ₯Pβˆ’Aiβˆ₯2=nβˆ₯Pβˆ’Gβˆ₯2+βˆ‘iβˆ₯Gβˆ’Aiβˆ₯2,\sum_i\lVert P-A_i\rVert^2 =n\lVert P-G\rVert^2+\sum_i\lVert G-A_i\rVert^2,

because the cross terms contain βˆ‘i(Gβˆ’Ai)=0\sum_i(G-A_i)=0. The sum is minimized uniquely at P=GP=G.

Example. Find the minimum of the sum of squared distances from a point PP to (0,0),(6,0),(0,6)(0,0),(6,0),(0,6).

Their average is (2,2)(2,2). At that point the three squared distances are eight, twenty, twenty, totaling forty-eight. The identity shows every other point adds 3βˆ₯Pβˆ’(2,2)βˆ₯2>03\lVert P-(2,2)\rVert^2>0, so the minimum is forty-eight.

This minimizes squared distances, not ordinary distances. The point minimizing a sum of unsquared lengths can be different. Before importing a geometric β€œcenter,” check exactly which objective the problem specifies.


The centroid identity also solves a constrained problem. If PP must lie on a line, the constant term in the squared-distance sum stays unchanged, so minimize PG2PG^2 by projecting the centroid onto that line.

Example. A point PP lies on 3x+4y=103x+4y=10. Find the minimum sum of its squared distances to (0,0),(6,0),(0,6)(0,0),(6,0),(0,6).

The unconstrained centroid is G=(2,2)G=(2,2) and the unconstrained minimum is forty-eight. Its distance to the required line is ∣14βˆ’10∣/5=4/5\lvert14-10\rvert/5=4/5. Therefore the constrained minimum is

48+3(45)2=124825.48+3\left(\frac45\right)^2=\frac{1248}{25}.

The attaining point is the perpendicular projection,

P=(2,2)βˆ’425(3,4)=(3825,3425).P=(2,2)-\frac4{25}(3,4)=\left(\frac{38}{25},\frac{34}{25}\right).

It satisfies the line equation, so the lower bound is attained within the allowed set.

The same identity describes a locus. A prescribed sum of squared distances equals a constant plus nPG2nPG^2. Above the minimum, the locus is a circle centered at the centroid; at the minimum it is a single point; below the minimum it is empty.

This converts a seemingly complicated sum involving many fixed points into one distance from their average. It is especially useful when the problem combines an area or line constraint with several squared distances.