OFFSET
1,2
COMMENTS
A detailed example for n=5 is given at the Pfoertner link.
LINKS
Jessica Gonzalez, Illustration of a(4)=166
Hugo Pfoertner, Intersections of diagonals in polygons of triangular shape.
Bjorn Poonen and Michael Rubinstein, The number of intersection points made by the diagonals of a regular polygon.
Cynthia Miaina Rasamimanananivo and Max Alekseyev, Sage program for this sequence
Index to OEIS, Sequences formed by drawing all diagonals in regular polygon
FORMULA
a(n) = A274585(n) - 3n.
EXAMPLE
a(2)=4 because there are 3 intersection points between the triangle medians and the line segments connecting the midpoints of the sides plus the intersection of the 3 medians at the centroid.
MAPLE
Inter:= proc(p1x, p1y, p2x, p2y, q1x, q1y, q2x, q2y)
local det, x, y;
det:= p1x*q1y-p1x*q2y-p1y*q1x+p1y*q2x-p2x*q1y+p2x*q2y+p2y*q1x-p2y*q2x;
if det = 0 then return NULL fi;
x:= (p1x*p2y*q1x-p1x*p2y*q2x-p1x*q1x*q2y+p1x*q1y*q2x-p1y*p2x*q1x+p1y*p2x*q2x+p2x*q1x*q2y-p2x*q1y*q2x)/det;
y:= (p1x*p2y*q1y-p1x*p2y*q2y-p1y*p2x*q1y+p1y*p2x*q2y-p1y*q1x*q2y+p1y*q1y*q2x+p2y*q1x*q2y-p2y*q1y*q2x)/det;
if x >0 and y > 0 and x + y < 1 then [x, y]
else NULL
fi
end proc:
F:= proc(n) local A, B, C, Pairs, Pts;
A:= [seq([j/n, 0], j=0..n)];
B:= [seq([0, j/n], j=0..n)];
C:= [seq([j/n, 1-j/n], j=0..n)];
Pairs:= [seq(seq([A[i], B[j]], i=2..n+1), j=2..n+1),
seq(seq([A[i], C[j]], i=1..n), j=1..n),
seq(seq([B[i], C[j]], i=1..n), j=2..n+1)];
Pts:= {seq(seq(Inter(op(Pairs[i][1]), op(Pairs[i][2]), op(Pairs[j][1]), op(Pairs[j][2])), j=1..i-1), i=2..nops(Pairs))};
nops(Pts);
end proc:
map(F, [$1..20]); # Robert Israel, Jun 30 2016
MATHEMATICA
Inter[{p1x_, p1y_}, {p2x_, p2y_}, {q1x_, q1y_}, {q2x_, q2y_}] := Module[ {det, x, y}, det = p1x q1y - p1x q2y - p1y q1x + p1y q2x - p2x q1y + p2x q2y + p2y q1x - p2y q2x; If[det == 0, Return[Nothing]]; x = (p1x p2y q1x - p1x p2y q2x - p1x q1x q2y + p1x q1y q2x - p1y p2x q1x + p1y p2x q2x + p2x q1x q2y - p2x q1y q2x)/det; y = (p1x p2y q1y - p1x p2y q2y - p1y p2x q1y + p1y p2x q2y - p1y q1x q2y + p1y q1y q2x + p2y q1x q2y - p2y q1y q2x)/det; If[x > 0 && y > 0 && x + y < 1, {x, y}, Nothing]];
F[n_] := F[n] = Module[{A, B, K, Pairs, Pts}, A = Table[{j/n, 0}, {j, 0, n}]; B = Table[{0, j/n}, {j, 0, n}]; K = Table[{j/n, 1 - j/n}, {j, 0, n}]; Pairs = {Table[Table[{A[[i]], B[[j]]}, {i, 2, n+1}], {j, 2, n+1}], Table[Table[{A[[i]], K[[j]]}, {i, 1, n}], {j, 1, n}], Table[Table[ {B[[i]], K[[j]]}, {i, 1, n}], {j, 2, n+1}]} // Flatten[#, 2]&; Pts = Table[Table[Inter[Pairs[[i, 1]], Pairs[[i, 2]], Pairs[[j, 1]], Pairs[[j, 2]]], {j, 1, i-1}], {i, 2, Length[Pairs]}]; Flatten[Pts, 1] // Union // Length];
Table[Print[n, " ", F[n]]; F[n], {n, 1, 20}] (* Jean-François Alcover, Apr 11 2019, after Robert Israel *)
CROSSREFS
Cf. A092867 (regions formed by the diagonals), A274585 (points both inside and on the triangle sides), A274586 (edges).
Cf. A006561 (number of intersections of diagonals of regular n-gon), A091908 (intersections between line segments connecting vertices with subdivision points on opposite side).
If the boundary points are in general position, we get A367117, A213827, A367118, A367119. - N. J. A. Sloane, Nov 09 2023
KEYWORD
nonn
AUTHOR
Hugo Pfoertner, Mar 10 2004
EXTENSIONS
a(1) = 0 prepended by Max Alekseyev, Jun 29 2016
a(4) corrected and a(6)-a(20) added by Cynthia Miaina Rasamimanananivo, Jun 28 2016
a(20) corrected by Robert Israel, Jun 30 2016
a(21)-a(50) from Cynthia Miaina Rasamimanananivo, Jun 30 - Aug 23, 2016
"Equilateral" added to definition by N. J. A. Sloane, May 13 2020
STATUS
approved