Class Ray

All Implemented Interfaces:
PointerInterface

public class Ray extends Record
A ray emitted from an origin in a given direction.

The contents of the `graphene_ray_t` structure are private, and should not
be modified directly.

https://ebassi.github.io/graphene/docs/

  • Field Details

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • allocRay

      public static Ray allocRay()
      Allocates a new #graphene_ray_t structure.

      The contents of the returned structure are undefined.
      Returns:
      the newly allocated #graphene_ray_t. Use graphene_ray_free() to free the resources allocated by this function
    • equal

      public boolean equal(@Nonnull Ray b)
      Checks whether the two given #graphene_ray_t are equal.
      Parameters:
      b - a #graphene_ray_t
      Returns:
      `true` if the given rays are equal
    • free

      public void free()
      Frees the resources allocated by graphene_ray_alloc().
    • getClosestPointToPoint

      public void getClosestPointToPoint(@Nonnull Point3D p, @Nonnull Point3D res)
      Computes the point on the given #graphene_ray_t that is closest to the
      given point @p.
      Parameters:
      p - a #graphene_point3d_t
      res - return location for the closest point3d
    • getDirection

      public void getDirection(@Nonnull Vec3 direction)
      Retrieves the direction of the given #graphene_ray_t.
      Parameters:
      direction - return location for the direction
    • getDistanceToPlane

      public float getDistanceToPlane(@Nonnull Plane p)
      Computes the distance of the origin of the given #graphene_ray_t from the
      given plane.

      If the ray does not intersect the plane, this function returns `INFINITY`.
      Parameters:
      p - a #graphene_plane_t
      Returns:
      the distance of the origin of the ray from the plane
    • getDistanceToPoint

      public float getDistanceToPoint(@Nonnull Point3D p)
      Computes the distance of the closest approach between the
      given #graphene_ray_t @r and the point @p.

      The closest approach to a ray from a point is the distance
      between the point and the projection of the point on the
      ray itself.
      Parameters:
      p - a #graphene_point3d_t
      Returns:
      the distance of the point
    • getOrigin

      public void getOrigin(@Nonnull Point3D origin)
      Retrieves the origin of the given #graphene_ray_t.
      Parameters:
      origin - return location for the origin
    • getPositionAt

      public void getPositionAt(float t, @Nonnull Point3D position)
      Retrieves the coordinates of a point at the distance @t along the
      given #graphene_ray_t.
      Parameters:
      t - the distance along the ray
      position - return location for the position
    • init

      public Ray init(@Nullable Point3D origin, @Nullable Vec3 direction)
      Initializes the given #graphene_ray_t using the given @origin
      and @direction values.
      Parameters:
      origin - the origin of the ray
      direction - the direction vector
      Returns:
      the initialized ray
    • initFromRay

      public Ray initFromRay(@Nonnull Ray src)
      Initializes the given #graphene_ray_t using the origin and direction
      values of another #graphene_ray_t.
      Parameters:
      src - a #graphene_ray_t
      Returns:
      the initialized ray
    • initFromVec3

      public Ray initFromVec3(@Nullable Vec3 origin, @Nullable Vec3 direction)
      Initializes the given #graphene_ray_t using the given vectors.
      Parameters:
      origin - a #graphene_vec3_t
      direction - a #graphene_vec3_t
      Returns:
      the initialized ray
    • intersectBox

      public int intersectBox(@Nonnull Box b, @Nonnull Flt t_out)
      Intersects the given #graphene_ray_t @r with the given
      #graphene_box_t @b.
      Parameters:
      b - a #graphene_box_t
      t_out - the distance of the point on the ray that intersects the box
      Returns:
      the type of intersection
    • intersectSphere

      public int intersectSphere(@Nonnull Sphere s, @Nonnull Flt t_out)
      Intersects the given #graphene_ray_t @r with the given
      #graphene_sphere_t @s.
      Parameters:
      s - a #graphene_sphere_t
      t_out - the distance of the point on the ray that intersects the sphere
      Returns:
      the type of intersection
    • intersectTriangle

      public int intersectTriangle(@Nonnull Triangle t, @Nonnull Flt t_out)
      Intersects the given #graphene_ray_t @r with the given
      #graphene_triangle_t @t.
      Parameters:
      t - a #graphene_triangle_t
      t_out - the distance of the point on the ray that intersects the triangle
      Returns:
      the type of intersection
    • intersectsBox

      public boolean intersectsBox(@Nonnull Box b)
      Checks whether the given #graphene_ray_t @r intersects the
      given #graphene_box_t @b.

      See also: graphene_ray_intersect_box()
      Parameters:
      b - a #graphene_box_t
      Returns:
      `true` if the ray intersects the box
    • intersectsSphere

      public boolean intersectsSphere(@Nonnull Sphere s)
      Checks if the given #graphene_ray_t @r intersects the
      given #graphene_sphere_t @s.

      See also: graphene_ray_intersect_sphere()
      Parameters:
      s - a #graphene_sphere_t
      Returns:
      `true` if the ray intersects the sphere
    • intersectsTriangle

      public boolean intersectsTriangle(@Nonnull Triangle t)
      Checks whether the given #graphene_ray_t @r intersects the
      given #graphene_triangle_t @b.

      See also: graphene_ray_intersect_triangle()
      Parameters:
      t - a #graphene_triangle_t
      Returns:
      `true` if the ray intersects the triangle
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()