Class Sphere

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Sphere extends ProxyInstance
A sphere, represented by its center and radius.
Since:
1.2
  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new Sphere.
    Sphere(Arena arena)
    Allocate a new Sphere.
    Create a Sphere proxy instance for the provided memory address.
    Sphere(Vec3 center, float radius)
    Allocate a new Sphere with the fields set to the provided values.
    Sphere(Vec3 center, float radius, Arena arena)
    Allocate a new Sphere with the fields set to the provided values.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Sphere
    Allocates a new graphene_sphere_t.
    boolean
    Checks whether the given point is contained in the volume of a graphene_sphere_t.
    float
    Computes the distance of the given point from the surface of a graphene_sphere_t.
    boolean
    Checks whether two graphene_sphere_t are equal.
    void
    Frees the resources allocated by graphene_sphere_alloc().
    void
    Computes the bounding box capable of containing the given graphene_sphere_t.
    void
    Retrieves the coordinates of the center of a graphene_sphere_t.
    The memory layout of the native struct.
    float
    Retrieves the radius of a graphene_sphere_t.
    static @Nullable Type
    Get the GType of the Sphere class.
    init(@Nullable Point3D center, float radius)
    Initializes the given graphene_sphere_t with the given center and radius.
    initFromPoints(@Nullable Point3D @Nullable [] points, @Nullable Point3D center)
    Initializes the given graphene_sphere_t using the given array of 3D coordinates so that the sphere includes them.
    initFromVectors(@Nullable Vec3 @Nullable [] vectors, @Nullable Point3D center)
    Initializes the given graphene_sphere_t using the given array of 3D coordinates so that the sphere includes them.
    boolean
    Checks whether the sphere has a zero radius.
    @Nullable Vec3
    Read the value of the field center.
    float
    Read the value of the field radius.
    void
    translate(Point3D point, Sphere res)
    Translates the center of the given graphene_sphere_t using the point coordinates as the delta of the translation.
    void
    writeCenter(@Nullable Vec3 center)
    Write a value in the field center.
    void
    writeRadius(float radius)
    Write a value in the field radius.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Sphere

      public Sphere(MemorySegment address)
      Create a Sphere proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Sphere

      public Sphere(Arena arena)
      Allocate a new Sphere.
      Parameters:
      arena - to control the memory allocation scope
    • Sphere

      public Sphere()
      Allocate a new Sphere. The memory is allocated with Arena.ofAuto().
    • Sphere

      public Sphere(Vec3 center, float radius, Arena arena)
      Allocate a new Sphere with the fields set to the provided values.
      Parameters:
      center - value for the field center
      radius - value for the field radius
      arena - to control the memory allocation scope
    • Sphere

      public Sphere(Vec3 center, float radius)
      Allocate a new Sphere with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      center - value for the field center
      radius - value for the field radius
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Sphere class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readCenter

      public @Nullable Vec3 readCenter()
      Read the value of the field center.
      Returns:
      The value of the field center
    • writeCenter

      public void writeCenter(@Nullable Vec3 center)
      Write a value in the field center.
      Parameters:
      center - The new value for the field center
    • readRadius

      public float readRadius()
      Read the value of the field radius.
      Returns:
      The value of the field radius
    • writeRadius

      public void writeRadius(float radius)
      Write a value in the field radius.
      Parameters:
      radius - The new value for the field radius
    • alloc

      public static Sphere alloc()

      Allocates a new graphene_sphere_t.

      The contents of the newly allocated structure are undefined.

      Returns:
      the newly allocated graphene_sphere_t. Use graphene_sphere_free() to free the resources allocated by this function
      Since:
      1.2
    • containsPoint

      public boolean containsPoint(Point3D point)
      Checks whether the given point is contained in the volume of a graphene_sphere_t.
      Parameters:
      point - a graphene_point3d_t
      Returns:
      true if the sphere contains the point
      Since:
      1.2
    • distance

      public float distance(Point3D point)
      Computes the distance of the given point from the surface of a graphene_sphere_t.
      Parameters:
      point - a graphene_point3d_t
      Returns:
      the distance of the point
      Since:
      1.2
    • equal

      public boolean equal(Sphere b)
      Checks whether two graphene_sphere_t are equal.
      Parameters:
      b - a graphene_sphere_t
      Returns:
      true if the spheres are equal
      Since:
      1.2
    • free

      public void free()
      Frees the resources allocated by graphene_sphere_alloc().
      Since:
      1.2
    • getBoundingBox

      public void getBoundingBox(Box box)
      Computes the bounding box capable of containing the given graphene_sphere_t.
      Parameters:
      box - return location for the bounding box
      Since:
      1.2
    • getCenter

      public void getCenter(Point3D center)
      Retrieves the coordinates of the center of a graphene_sphere_t.
      Parameters:
      center - return location for the coordinates of the center
      Since:
      1.2
    • getRadius

      public float getRadius()
      Retrieves the radius of a graphene_sphere_t.
      Since:
      1.2
    • init

      public Sphere init(@Nullable Point3D center, float radius)
      Initializes the given graphene_sphere_t with the given center and radius.
      Parameters:
      center - the coordinates of the center of the sphere, or null for a center in (0, 0, 0)
      radius - the radius of the sphere
      Returns:
      the initialized graphene_sphere_t
      Since:
      1.2
    • initFromPoints

      public Sphere initFromPoints(@Nullable Point3D @Nullable [] points, @Nullable Point3D center)

      Initializes the given graphene_sphere_t using the given array of 3D coordinates so that the sphere includes them.

      The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all points.

      Parameters:
      points - an array of graphene_point3d_t
      center - the center of the sphere
      Returns:
      the initialized graphene_sphere_t
      Since:
      1.2
    • initFromVectors

      public Sphere initFromVectors(@Nullable Vec3 @Nullable [] vectors, @Nullable Point3D center)

      Initializes the given graphene_sphere_t using the given array of 3D coordinates so that the sphere includes them.

      The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all vectors.

      Parameters:
      vectors - an array of graphene_vec3_t
      center - the center of the sphere
      Returns:
      the initialized graphene_sphere_t
      Since:
      1.2
    • isEmpty

      public boolean isEmpty()
      Checks whether the sphere has a zero radius.
      Returns:
      true if the sphere is empty
      Since:
      1.2
    • translate

      public void translate(Point3D point, Sphere res)
      Translates the center of the given graphene_sphere_t using the point coordinates as the delta of the translation.
      Parameters:
      point - the coordinates of the translation
      res - return location for the translated sphere
      Since:
      1.2