PVector distance = PVector.sub(a.location, location); float d = distance.mag(); if (d < 5) { return true; } else { return false; }
/** * ( begin auto-generated from PVector_normalize.xml ) * * Normalize the vector to length 1 (make it a unit vector). * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @brief Normalize the vector to a length of 1 */ public void normalize() { float m = mag(); if (m != 0 && m != 1) { div(m); } }
/** * ( begin auto-generated from PVector_normalize.xml ) * * Normalize the vector to length 1 (make it a unit vector). * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @brief Normalize the vector to a length of 1 */ public PVector normalize() { float m = mag(); if (m != 0 && m != 1) { div(m); } return this; }
/** * @param target Set to null to create a new vector * @return a new vector (if target was null), or target */ public PVector normalize(PVector target) { if (target == null) { target = new PVector(); } float m = mag(); if (m > 0) { target.set(x/m, y/m, z/m); } else { target.set(x, y, z); } return target; }
/** * @param target Set to null to create a new vector * @return a new vector (if target was null), or target */ public PVector normalize(PVector target) { if (target == null) { target = new PVector(); } float m = mag(); if (m > 0) { target.set(x/m, y/m, z/m); } else { target.set(x, y, z); } return target; }
float bVectMag = bVect.mag();
float bVectMag = bVect.mag();