static Point project(Line l, Point p) { Point p1 = l.getP1(); Point p2 = l.getP2(); Vector base = new Vector(p2, p1); double r = Vector.dot(new Vector(p, p1), base) / base.norm(); return base.scalarMul(r).plus(p1).toPoint(); }
protected float[] linesAsFloats(ArrayList<Line> lines) { float[] floats = new float[lines.size() * 4]; int i = 0; for (Line line : lines) { floats[i] = line.getP1().getX(); floats[i + 1] = line.getP1().getY(); floats[i + 2] = line.getP2().getX(); floats[i + 3] = line.getP2().getY(); i += 4; } return floats; }