예제 #1
0
 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;
 }
예제 #2
0
파일: AOJ0081.java 프로젝트: t8m8/AOJ
  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();
  }