Class Point

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Point extends ProxyInstance
A point with two coordinates.
Since:
1.0
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    static Point
    Allocates a new graphene_point_t structure.
    float
    distance(Point b, @Nullable Out<Float> dX, @Nullable Out<Float> dY)
    Computes the distance between this Point and b.
    boolean
    Checks if the two points this Point and b point to the same coordinates.
    void
    Frees the resources allocated by graphene_point_alloc().
    The memory layout of the native struct.
    static @Nullable Type
    Get the GType of the Point class.
    init(float x, float y)
    Initializes this Point to the given x and y coordinates.
    Initializes this Point with the same coordinates of src.
    Initializes this Point with the coordinates inside the given graphene_vec2_t.
    void
    interpolate(Point b, double factor, Point res)
    Linearly interpolates the coordinates of this Point and b using the given factor.
    boolean
    near(Point b, float epsilon)
    Checks whether the two points this Point and b are within the threshold of epsilon.
    float
    Read the value of the field x.
    float
    Read the value of the field y.
    void
    Stores the coordinates of the given graphene_point_t into a graphene_vec2_t.
    void
    writeX(float x)
    Write a value in the field x.
    void
    writeY(float y)
    Write a value in the field y.
    static Point
    Returns a point fixed at (0, 0).

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

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

    • Point

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

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

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

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

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

    • getType

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

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

      public float readX()
      Read the value of the field x.
      Returns:
      The value of the field x
    • writeX

      public void writeX(float x)
      Write a value in the field x.
      Parameters:
      x - The new value for the field x
    • readY

      public float readY()
      Read the value of the field y.
      Returns:
      The value of the field y
    • writeY

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

      public static Point alloc()

      Allocates a new graphene_point_t structure.

      The coordinates of the returned point are (0, 0).

      It's possible to chain this function with graphene_point_init() or graphene_point_init_from_point(), e.g.:

        graphene_point_t *
        point_new (float x, float y)
        {
          return graphene_point_init (graphene_point_alloc (), x, y);
        }
      
        graphene_point_t *
        point_copy (const graphene_point_t *p)
        {
          return graphene_point_init_from_point (graphene_point_alloc (), p);
        }
      
      Returns:
      the newly allocated graphene_point_t. Use graphene_point_free() to free the resources allocated by this function.
      Since:
      1.0
    • zero

      public static Point zero()
      Returns a point fixed at (0, 0).
      Returns:
      a fixed point
      Since:
      1.0
    • distance

      public float distance(Point b, @Nullable Out<Float> dX, @Nullable Out<Float> dY)
      Computes the distance between this Point and b.
      Parameters:
      b - a graphene_point_t
      dX - distance component on the X axis
      dY - distance component on the Y axis
      Returns:
      the distance between the two points
      Since:
      1.0
    • equal

      public boolean equal(Point b)

      Checks if the two points this Point and b point to the same coordinates.

      This function accounts for floating point fluctuations; if you want to control the fuzziness of the match, you can use graphene_point_near() instead.

      Parameters:
      b - a graphene_point_t
      Returns:
      true if the points have the same coordinates
      Since:
      1.0
    • free

      public void free()
      Frees the resources allocated by graphene_point_alloc().
      Since:
      1.0
    • init

      public Point init(float x, float y)

      Initializes this Point to the given x and y coordinates.

      It's safe to call this function multiple times.

      Parameters:
      x - the X coordinate
      y - the Y coordinate
      Returns:
      the initialized point
      Since:
      1.0
    • initFromPoint

      public Point initFromPoint(Point src)
      Initializes this Point with the same coordinates of src.
      Parameters:
      src - the graphene_point_t to use
      Returns:
      the initialized point
      Since:
      1.0
    • initFromVec2

      public Point initFromVec2(Vec2 src)
      Initializes this Point with the coordinates inside the given graphene_vec2_t.
      Parameters:
      src - a graphene_vec2_t
      Returns:
      the initialized point
      Since:
      1.4
    • interpolate

      public void interpolate(Point b, double factor, Point res)
      Linearly interpolates the coordinates of this Point and b using the given factor.
      Parameters:
      b - a graphene_point_t
      factor - the linear interpolation factor
      res - return location for the interpolated point
      Since:
      1.0
    • near

      public boolean near(Point b, float epsilon)
      Checks whether the two points this Point and b are within the threshold of epsilon.
      Parameters:
      b - a graphene_point_t
      epsilon - threshold between the two points
      Returns:
      true if the distance is within epsilon
      Since:
      1.0
    • toVec2

      public void toVec2(Vec2 v)
      Stores the coordinates of the given graphene_point_t into a graphene_vec2_t.
      Parameters:
      v - return location for the vertex
      Since:
      1.4