Line (Reflectional) Symmetry Detector
A shape has reflectional (line) symmetry if you can reflect it across some line
(a mirror line) and the reflected shape lands exactly on top of the original.
This calculator checks reflection symmetry for a polygon given by its vertices.
1) What “line symmetry” means
Let \(\ell\) be a line in the plane. If reflecting the polygon across \(\ell\) produces the same polygon,
then \(\ell\) is a line of symmetry.
Common symmetry lines include:
- \(x=0\) (the y-axis),
- \(y=0\) (the x-axis),
- \(y=x\) and \(y=-x\) (the diagonals through the origin),
- lines through the polygon’s center (for many symmetric shapes).
2) Reflection of a point across a line
A line can be written in the form:
\[
ax + by + c = 0,
\]
where \((a,b)\neq(0,0)\) is a normal vector to the line.
If \(P=(x,y)\), the reflection \(P'=(x',y')\) across the line can be computed by projecting \(P\) onto the normal direction.
A useful vector form is:
\[
P' = P - 2\bigl((P-P_0)\cdot \hat{n}\bigr)\hat{n},
\]
where:
- \(P_0\) is any point on the line,
- \(\hat{n}\) is a unit normal vector to the line.
3) How symmetry is tested for a polygon
A polygon is defined by vertices \(V_1,V_2,\dots,V_n\) in order (clockwise or counterclockwise).
Reflection flips orientation, so a symmetric polygon typically matches the original vertices
in the reverse cyclic order after reflection.
In practice, the tool:
- reflects every vertex across a candidate line, producing \(V_1',\dots,V_n'\),
- checks whether the reflected list matches the original list up to a cyclic shift
(and allowing for reversal due to reflection),
- uses a small numerical tolerance \(\varepsilon\) to handle rounding.
4) Why the centroid matters
If a set of points is symmetric with respect to a line, its average point (centroid of the set) must lie on that line.
That’s why many symmetry candidates are built from lines passing through the polygon’s centroid
\(\bigl(\bar{x},\bar{y}\bigr)\), where:
\[
\bar{x}=\frac{1}{n}\sum_{i=1}^n x_i,\qquad
\bar{y}=\frac{1}{n}\sum_{i=1}^n y_i.
\]
5) Auto-detect vs. common vs. custom line
-
Auto-detect: generates many candidate mirror lines (especially through the centroid)
and tests them all. This is best when you don’t know the symmetry line.
-
Common lines: tests only typical symmetry lines (axes and centroid-based diagonals).
This is fast and useful for standard shapes.
-
Custom line: lets you test a specific mirror line using:
- two points on the line, or
- an equation \(ax+by+c=0\).
6) Example: square symmetry lines
A square has 4 reflection symmetry lines:
- vertical through its center,
- horizontal through its center,
- the two diagonals through its center.
That’s why the sample “Square” preset returns “Yes, 4 lines”.
7) Reading the graph
- The polygon is drawn in one color.
- Detected symmetry lines are drawn as dashed/solid lines (selected line is emphasized).
- The reflected polygon overlay helps you verify the match visually.
- Play animates the reflection across the selected symmetry line.
8) Common mistakes
- Vertices not in order (the polygon “walk” must go around the shape).
- Repeating points or giving a self-intersecting polygon unexpectedly.
- Using too strict a tolerance for decimal-heavy inputs (try \(10^{-5}\) or \(10^{-4}\)).