/** * Check a triangle... if it is null or its points are invalid, return false. Else return true. * * @param triangle * the triangle to check * @return true or false as stated above. */ public static boolean isValid(final Triangle triangle) { if (triangle == null) { return false; } if (!Vector3.isValid(triangle._pointA) || !Vector3.isValid(triangle._pointB) || !Vector3.isValid(triangle._pointC)) { return false; } return true; }
/** * Check a triangle... if it is null or its points are invalid, return false. Else return true. * * @param triangle * the triangle to check * @return true or false as stated above. */ public static boolean isValid(final Triangle triangle) { if (triangle == null) { return false; } if (!Vector3.isValid(triangle._pointA) || !Vector3.isValid(triangle._pointB) || !Vector3.isValid(triangle._pointC)) { return false; } return true; }
/** * Check a line... if it is null or the values of its origin or direction are NaN or infinite, return false. Else * return true. * * @param line * the line to check * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyLine3 line) { if (line == null) { return false; } return Vector3.isValid(line.getDirection()) && Vector3.isValid(line.getOrigin()); }
/** * Check a ray... if it is null or the values of its origin or direction are NaN or infinite, return false. Else * return true. * * @param ray * the ray to check * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyRay3 ray) { if (ray == null) { return false; } return Vector3.isValid(ray.getDirection()) && Vector3.isValid(ray.getOrigin()); }
/** * Check a ray... if it is null or the values of its origin or direction are NaN or infinite, return false. Else * return true. * * @param ray * the ray to check * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyRay3 ray) { if (ray == null) { return false; } return Vector3.isValid(ray.getDirection()) && Vector3.isValid(ray.getOrigin()); }
/** * Check a line... if it is null or the values of its origin or direction are NaN or infinite, return false. Else * return true. * * @param line * the line to check * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyLine3 line) { if (line == null) { return false; } return Vector3.isValid(line.getDirection()) && Vector3.isValid(line.getOrigin()); }
/** * Check a segment... if it is null or the values of its origin or direction or extent are NaN or infinite, return * false. Else return true. * * @param segment * the segment to check * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyLineSegment3 segment) { if (segment == null) { return false; } return Vector3.isValid(segment.getDirection()) && Vector3.isValid(segment.getOrigin()) && !Double.isInfinite(segment.getExtent()) && !Double.isNaN(segment.getExtent()); }
/** * Check a segment... if it is null or the values of its origin or direction or extent are NaN or infinite, return * false. Else return true. * * @param segment * the segment to check * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyLineSegment3 segment) { if (segment == null) { return false; } return Vector3.isValid(segment.getDirection()) && Vector3.isValid(segment.getOrigin()) && !Double.isInfinite(segment.getExtent()) && !Double.isNaN(segment.getExtent()); }
/** * Check a plane... if it is null or its constant, or the doubles of its normal are NaN or infinite, return false. * Else return true. * * @param plane * the plane to check * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyPlane plane) { if (plane == null) { return false; } if (Double.isNaN(plane.getConstant()) || Double.isInfinite(plane.getConstant())) { return false; } return Vector3.isValid(plane.getNormal()); }
/** * Check a transform... if it is null or one of its members are invalid, return false. Else return true. * * @param transform * the transform to check * * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyTransform transform) { if (transform == null) { return false; } if (!Vector3.isValid(transform.getScale()) || !Vector3.isValid(transform.getTranslation()) || !Matrix3.isValid(transform.getMatrix())) { return false; } return true; }
@Override public boolean intersectsSphere(final BoundingSphere bs) { if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) { return false; } final Vector3 diff = _compVect1.set(getCenter()).subtractLocal(bs.getCenter()); final double rsum = getRadius() + bs.getRadius(); return (diff.dot(diff) <= rsum * rsum); }
@Override public boolean intersectsSphere(final BoundingSphere bs) { if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) { return false; } final Vector3 diff = _compVect1.set(getCenter()).subtractLocal(bs.getCenter()); final double rsum = getRadius() + bs.getRadius(); return (diff.dot(diff) <= rsum * rsum); }
@Override public boolean intersectsBoundingBox(final BoundingBox bb) { if (!Vector3.isValid(_center) || !Vector3.isValid(bb._center)) { return false; } if (Math.abs(bb._center.getX() - getCenter().getX()) < getRadius() + bb.getXExtent() && Math.abs(bb._center.getY() - getCenter().getY()) < getRadius() + bb.getYExtent() && Math.abs(bb._center.getZ() - getCenter().getZ()) < getRadius() + bb.getZExtent()) { return true; } return false; }
@Override public boolean intersectsBoundingBox(final BoundingBox bb) { if (!Vector3.isValid(_center) || !Vector3.isValid(bb._center)) { return false; } if (Math.abs(bb._center.getX() - getCenter().getX()) < getRadius() + bb.getXExtent() && Math.abs(bb._center.getY() - getCenter().getY()) < getRadius() + bb.getYExtent() && Math.abs(bb._center.getZ() - getCenter().getZ()) < getRadius() + bb.getZExtent()) { return true; } return false; }
@Override public boolean intersectsSphere(final BoundingSphere bs) { if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) { return false; } if (Math.abs(_center.getX() - bs.getCenter().getX()) < bs.getRadius() + getXExtent() && Math.abs(_center.getY() - bs.getCenter().getY()) < bs.getRadius() + getYExtent() && Math.abs(_center.getZ() - bs.getCenter().getZ()) < bs.getRadius() + getZExtent()) { return true; } return false; }
@Override public boolean intersectsSphere(final BoundingSphere bs) { if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) { return false; } if (Math.abs(_center.getX() - bs.getCenter().getX()) < bs.getRadius() + getXExtent() && Math.abs(_center.getY() - bs.getCenter().getY()) < bs.getRadius() + getYExtent() && Math.abs(_center.getZ() - bs.getCenter().getZ()) < bs.getRadius() + getZExtent()) { return true; } return false; }
@Override public boolean intersectsSphere(final BoundingSphere bs) { if (!Vector3.isValid(_center) || !Vector3.isValid(bs._center)) { return false; } _compVect1.set(bs.getCenter()).subtractLocal(_center); final Matrix3 tempMa = Matrix3.fetchTempInstance().fromAxes(_xAxis, _yAxis, _zAxis); tempMa.applyPost(_compVect1, _compVect1); boolean result = false; if (Math.abs(_compVect1.getX()) < bs.getRadius() + _extent.getX() && Math.abs(_compVect1.getY()) < bs.getRadius() + _extent.getY() && Math.abs(_compVect1.getZ()) < bs.getRadius() + _extent.getZ()) { result = true; } Matrix3.releaseTempInstance(tempMa); return result; }
@Override public boolean intersects(final ReadOnlyRay3 ray) { if (!Vector3.isValid(_center)) { return false; } final Vector3 diff = ray.getOrigin().subtract(getCenter(), _compVect1); final double radiusSquared = getRadius() * getRadius(); final double a = diff.dot(diff) - radiusSquared; if (a <= 0.0) { // in sphere return true; } // outside sphere final Vector3 dir = _compVect2.set(ray.getDirection()); final double b = dir.dot(diff); if (b >= 0.0) { return false; } return b * b >= a; }
@Override public boolean intersectsBoundingBox(final BoundingBox bb) { if (!Vector3.isValid(_center) || !Vector3.isValid(bb._center)) { return false; } if (_center.getX() + getXExtent() < bb._center.getX() - bb.getXExtent() || _center.getX() - getXExtent() > bb._center.getX() + bb.getXExtent()) { return false; } else if (_center.getY() + getYExtent() < bb._center.getY() - bb.getYExtent() || _center.getY() - getYExtent() > bb._center.getY() + bb.getYExtent()) { return false; } else if (_center.getZ() + getZExtent() < bb._center.getZ() - bb.getZExtent() || _center.getZ() - getZExtent() > bb._center.getZ() + bb.getZExtent()) { return false; } else { return true; } }
@Override public boolean intersectsBoundingBox(final BoundingBox bb) { if (!Vector3.isValid(_center) || !Vector3.isValid(bb._center)) { return false; } if (_center.getX() + getXExtent() < bb._center.getX() - bb.getXExtent() || _center.getX() - getXExtent() > bb._center.getX() + bb.getXExtent()) { return false; } else if (_center.getY() + getYExtent() < bb._center.getY() - bb.getYExtent() || _center.getY() - getYExtent() > bb._center.getY() + bb.getYExtent()) { return false; } else if (_center.getZ() + getZExtent() < bb._center.getZ() - bb.getZExtent() || _center.getZ() - getZExtent() > bb._center.getZ() + bb.getZExtent()) { return false; } else { return true; } }