Exemple #1
0
  protected double intersectsAt(
      Plane plane, double effectiveRadius, Vec4 endpoint1, Vec4 endpoint2) {
    // Test the distance from the first end-point.
    double dq1 = plane.dot(endpoint1);
    boolean bq1 = dq1 <= -effectiveRadius;

    // Test the distance from the possibly reduced second end-point.
    double dq2 = plane.dot(endpoint2);
    boolean bq2 = dq2 <= -effectiveRadius;

    if (bq1
        && bq2) // endpoints more distant from plane than effective radius; box is on neg. side of
      // plane
      return -1;

    if (bq1 == bq2) // endpoints less distant from plane than effective radius; can't draw any
      // conclusions
      return 0;

    // Compute and return the endpoints of the cylinder on the positive side of the plane.
    this.tmp3.subtract3AndSet(endpoint1, endpoint2);
    double t = (effectiveRadius + dq1) / plane.getNormal().dot3(this.tmp3);

    this.tmp3.subtract3AndSet(endpoint2, endpoint1).multiply3AndSet(t).add3AndSet(endpoint1);
    // truncate the line to only that in the positive halfspace (e.g., inside the frustum)
    if (bq1) endpoint1.set(this.tmp3);
    else endpoint2.set(this.tmp3);

    return t;
  }
Exemple #2
0
  /** {@inheritDoc} */
  public double getEffectiveRadius(Plane plane) {
    if (plane == null) return 0;

    // Determine the effective radius of the box axis relative to the plane.
    Vec4 n = plane.getNormal();
    return 0.5 * (Math.abs(this.s.dot3(n)) + Math.abs(this.t.dot3(n)));
  }