예제 #1
0
파일: Ray.java 프로젝트: hakurai/kvs4j
  public final boolean isIntersected(final Vector3f v0, final Vector3f v1, final Vector3f v2) {
    final Vector3f v01 = v1.sub(v0);
    final Vector3f v02 = v2.sub(v0);

    final Vector3f pvec = this.direction().cross(v02);

    final float det = v01.dot(pvec);

    if (det > 1e-6f) {
      final Vector3f tvec = this.from().sub(v0);
      final float u = tvec.dot(pvec);
      if (u < 0.0f || u > det) {
        return (false);
      }

      final Vector3f qvec = tvec.cross(v01);
      final float v = this.direction().dot(qvec);
      if (v < 0.0f || u + v > det) {
        return (false);
      }

      final float t = v02.dot(qvec) / det;
      this.setT(t);

      return (true); // hit!!
    }

    return (false);
  }
예제 #2
0
 public SlicePlane(Vector3f point, Vector3f norm, TransferFunction transfer_function) {
   super(transfer_function);
   m_coefficients = new Vector4f(norm, -point.dot(norm));
 }
예제 #3
0
 public SlicePlane(Vector3f point, Vector3f norm) {
   super();
   m_coefficients = new Vector4f(norm, -point.dot(norm));
 }