/** * Computes the length of this vector * <br> * <b>Note:</b> If you are working with raw vectors from PDF, be careful - * the Z axis will generally be set to 1. If you want to compute the * length of a vector, subtract it from the origin first (this will set * the Z axis to 0). * <br> * For example: * <code>aVector.subtract(originVector).length();</code> * * @return the length of this vector */ public float length() { return (float) Math.sqrt(lengthSquared()); }
float dist = (x2.subtract(x1)).cross((x1.subtract(start))).lengthSquared() / x2.subtract(x1).lengthSquared();