Integer triangles with perimeter less than n Definition

An "integer triangle" is one with integer coordinates. For example the following triangle is an integer triangle:

(0, 0), (0, 1), (1, 2) with perimeter 1 + sqrt(2) + sqrt(5) ≈ 4.650.


Task

The goal of this challenge is to count all integer triangles (up to congruence) with perimeter less than n.

Input and Output

The argument will be given as an integer, and the output should be the number of triangles with perimeter strictly less than the argument.

Examples

The smallest integer triangle by perimeter is congruent to

(0, 0), (0, 1), (1, 0) which has perimeter 2 + sqrt(2) ≈ 3.414


The next smallest are:

(0, 0), (0, 1), (1, 2) with perimeter 1 + sqrt(2) + sqrt(5) ≈ 4.650,
(0, 0), (0, 2), (1, 1) with perimeter 2 + 2sqrt(2)          ≈ 4.828,
(0, 0), (0, 2), (1, 0) with perimeter 3 + sqrt(5)           ≈ 5.236, and
(0, 0), (1, 2), (2, 1) with perimeter sqrt(2) + 2sqrt(5)    ≈ 5.886


Test cases:

a(1) = 0
a(2) = 0
a(3) = 0
a(4) = 1
a(5) = 3
a(6) = 5
a(7) = 11
a(8) = 18
a(9) = 29
a(10) = 44
a(12) = 94
a(20) = 738
a(30) = 3756
a(40) = 11875


I have coordinates for each of the triangles in this Gist.

Warnings

Notice that two non-congruent triangles can have the same perimeter:

(0, 0), (0, 3), (3, 0) and (0, 0), (0, 1), (3, 4) both have perimeter 6 + 3sqrt(2).


Also keep in mind that the inequality is strict; the 3-4-5 pythagorean triangle should be counted by a(13), not a(12).

Scoring

This is code-golf—the shortest code wins!
Jelly, 28 27 25 23 bytes

pḶŒcÆḊÐfḅı;I$€AṢ€QS€&lt;¹S


Try it online!

How it works

pḶŒcÆḊÐfḅı;I$€AṢ€QS€&lt;¹S  Main link. Argument: n

 Ḷ                       Unlength; yield [0,...,n-1].
p                        Take the Cartesian product of [1,...,n] and [0,...,n-1].
  Œc                     Take all combinations of the resulting pairs.
                         The result are of the form [[a, b], [c, d]].
    ÆḊÐf                 Filter by determinant; keep only pairs of pairs for which
                         the determinant (ad - bc) is non-zero, i.e., those such
                         that [0, 0], [a, b], and [c, d] are not collinear.
        ḅı               Convert each pair [a, b] from base i (imaginary unit) to
                         integer, mapping it to ai + b.
             €           For each pair of complex numbers [p, q]: 
          ;I$              append their forward differences, yielding [p, q, p-q].
              A          Take the absolute value of each resulting complex number.
               Ṣ€        Sort each resulting array of side lengths.
                 Q       Unique; remove duplicates.
                  S€     Take the sum of each array, computing the perimeters.
                    &lt;¹   Compare them with n.
                      S  Take the sum of the resulting Booleans.