java.lang.Object
com.github.stephengold.joltjni.ClosestPoint

public final class ClosestPoint extends Object
Utilities to locate the closest point on a line segment, triangle or tetrahedron. (native namespace: ClosestPoint)
  • Method Details

    • getBaryCentricCoordinates

      public static boolean getBaryCentricCoordinates(Vec3Arg a, Vec3Arg b, float[] storeUv)
      Calculate the barycentric coordinates of the point on the specified (infinite) line that's closest to the origin.
      Parameters:
      a - the location of a reference point on the line (not null, unaffected)
      b - the location of another reference point on the line (not null, unaffected)
      storeUv - storage for the coordinates (not null, length≥2, modified)
      Returns:
      true if successful, false if the points do not define a line
    • getBaryCentricCoordinates

      public static boolean getBaryCentricCoordinates(Vec3Arg a, Vec3Arg b, Vec3Arg c, float[] storeUvw)
      Calculate the barycentric coordinates of the point on the specified plane that's closest to the origin.
      Parameters:
      a - the location of a reference point on the plane (not null, unaffected)
      b - the location of another reference point on the plane (not null, unaffected)
      c - the location of a 3rd reference point on the plane (not null, unaffected)
      storeUvw - storage for the coordinates (not null, length≥3, modified)
      Returns:
      true if successful, false if the points do not define a plane
    • getClosestPointOnLine

      public static Vec3 getClosestPointOnLine(Vec3Arg a, Vec3Arg b, int[] storeSet)
      Locate the point on the specified line segment that's closest to the origin.
      Parameters:
      a - the location of the first end-point of the segment (not null, unaffected)
      b - the location of the 2nd end-point of the segment (not null, unaffected)
      storeSet - storage for the closest feature(s) (not null, length≥1, modified)
      Returns:
      a new location vector
    • getClosestPointOnTetrahedron

      public static Vec3 getClosestPointOnTetrahedron(Vec3Arg a, Vec3Arg b, Vec3Arg c, Vec3Arg d, int[] storeSet)
      Locate the point on the specified tetrahedron that's closest to the origin.
      Parameters:
      a - the location of the first vertex of the tetrahedron (not null, unaffected)
      b - the location of the 2nd vertex of the tetrahedron (not null, unaffected)
      c - the location of the 3rd vertex of the tetrahedron (not null, unaffected)
      d - the location of the 4th vertex of the tetrahedron (not null, unaffected)
      storeSet - storage for the closest feature(s) (not null, length≥1, modified)
      Returns:
      a new location vector
    • getClosestPointOnTriangle

      public static Vec3 getClosestPointOnTriangle(Vec3Arg a, Vec3Arg b, Vec3Arg c, int[] storeSet)
      Locate the point on the specified triangle that's closest to the origin.
      Parameters:
      a - the location of the first vertex of the triangle (not null, unaffected)
      b - the location of the 2nd vertex of the triangle (not null, unaffected)
      c - the location of the 3rd vertex of the triangle (not null, unaffected)
      storeSet - storage for the closest feature(s) (not null, length≥1, modified)
      Returns:
      a new location vector