Example #1
0
  /** Returns the function's value at the given point. */
  public static float getValueAt(Vector3f p, ArrayList<Primitive> primitives) {
    float bestValue = Float.MAX_VALUE;

    // Find the primitive which surface is the closest to the isosurface.
    for (Primitive primitive : primitives) {
      bestValue = Math.min(primitive.getPointValue(p), bestValue);
    }

    return bestValue;
  }
Example #2
0
  /** Returns the function's normal at the given point. */
  public static Vector3f getNormalAt(Vector3f p, ArrayList<Primitive> primitives) {
    float bestValue = Float.MAX_VALUE;
    Primitive bestPrimitive = null;

    // Find the primitive which surface is the closest to the isosurface.
    for (Primitive primitive : primitives) {
      float newValue = Math.abs(primitive.getPointValue(p));
      if (newValue < bestValue) {
        bestValue = newValue;
        bestPrimitive = primitive;
      }
    }

    // Get the normal from that primitive.
    Vector3f result = bestPrimitive.getPointNormal(p);

    return result;
  }