Distance between two points & Angle between two vectors

If v1 and v2 are normalised so that |v1|=|v2|=1, then angle = acos(v1•v2)

http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/

// 두 점 간의 거리 구하기
public static double distance(Point p1, Point p2) {
    return Math.sqrt((p2.getX() – p1.getX()) * (p2.getX() – p1.getX()) + (p2.getY() – p1.getY()) * (p2.getY() – p1.getY()));
}

// 벡터의 길이
public static double length(Point p) {
    return Math.sqrt(p.getX() * p.getX() + p.getY() * p.getY());
}

// 두 벡터간의 내적(dot product)
public static double dot(Point p1, Point p2) {
    return p1.getX() * p2.getX() + p1.getY() * p2.getY();
}

// 세 점으로부터 도형의 내각 구하기 = acos(dot(v1, v2) / |v1|*|v2|)
public static double innerAngle(Point p1, Point p2, Point p3) {
    Point v1 = new Point(p1.getX() – p2.getX(), p1.getY() – p2.getY()); // v1 = p1 – p2
    Point v2 = new Point(p3.getX() – p2.getX(), p3.getY() – p2.getY()); // v2 = p3 – p2
    double len1 = length(v1);
    double len2 = length(v2);
    double dot = dot(v1, v2);
    double radian = Math.acos(dot / len1 * len2);
    double angle = Math.toDegrees(radian);
    return angle;
}