@Override // from IPlane public float distance (IVector3 pt) { return _normal.dot(pt) + constant; }
@Override // from IPlane public float distance (IVector3 pt) { return _normal.dot(pt) + constant; }
@Override // from IPlane public float distance (IRay3 ray) { float dividend = -distance(ray.origin()); float divisor = _normal.dot(ray.direction()); if (Math.abs(dividend) < MathUtil.EPSILON) { return 0f; // origin is on plane } else if (Math.abs(divisor) < MathUtil.EPSILON) { return Float.NaN; // ray is parallel to plane } else { return dividend / divisor; } }
@Override // from IPlane public float distance (IRay3 ray) { float dividend = -distance(ray.origin()); float divisor = _normal.dot(ray.direction()); if (Math.abs(dividend) < MathUtil.EPSILON) { return 0f; // origin is on plane } else if (Math.abs(divisor) < MathUtil.EPSILON) { return Float.NaN; // ray is parallel to plane } else { return dividend / divisor; } }
@Override // from interface IVector3 public float angle (IVector3 other) { return FloatMath.acos(dot(other) / (length() * other.length())); }
@Override // from interface IVector3 public float angle (IVector3 other) { return FloatMath.acos(dot(other) / (length() * other.length())); }
/** * Sets this plane based on the three points provided. * * @return a reference to the plane (for chaining). */ public Plane fromPoints (IVector3 p1, IVector3 p2, IVector3 p3) { // compute the normal by taking the cross product of the two vectors formed p2.subtract(p1, _v1); p3.subtract(p1, _v2); _v1.cross(_v2, _normal).normalizeLocal(); // use the first point to determine the constant constant = -_normal.dot(p1); return this; }
/** * Sets this plane based on the three points provided. * * @return a reference to the plane (for chaining). */ public Plane fromPoints (IVector3 p1, IVector3 p2, IVector3 p3) { // compute the normal by taking the cross product of the two vectors formed p2.subtract(p1, _v1); p3.subtract(p1, _v2); _v1.cross(_v2, _normal).normalizeLocal(); // use the first point to determine the constant constant = -_normal.dot(p1); return this; }