Class Plane

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Plane extends ProxyInstance

A 2D plane that extends infinitely in a 3D volume.

The contents of the graphene_plane_t are private, and should not be modified directly.

Since:
1.2
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    static Plane
    Allocates a new graphene_plane_t structure.
    float
    Computes the distance of point from a graphene_plane_t.
    boolean
    Checks whether the two given graphene_plane_t are equal.
    void
    Frees the resources allocated by graphene_plane_alloc().
    float
    Retrieves the distance along the normal vector of the given graphene_plane_t from the origin.
    The memory layout of the native struct.
    void
    getNormal(Vec3 normal)
    Retrieves the normal vector pointing towards the origin of the given graphene_plane_t.
    static @Nullable Type
    Get the GType of the Plane class.
    init(@Nullable Vec3 normal, float constant)
    Initializes the given graphene_plane_t using the given normal vector and constant values.
    Initializes the given graphene_plane_t using the normal vector and constant of another graphene_plane_t.
    initFromPoint(Vec3 normal, Point3D point)
    Initializes the given graphene_plane_t using the given normal vector and an arbitrary co-planar point.
    Initializes the given graphene_plane_t using the 3 provided co-planar points.
    Initializes the given graphene_plane_t using the components of the given graphene_vec4_t vector.
    void
    Negates the normal vector and constant of a graphene_plane_t, effectively mirroring the plane across the origin.
    void
    Normalizes the vector of the given graphene_plane_t, and adjusts the constant accordingly.
    float
    Read the value of the field constant.
    @Nullable Vec3
    Read the value of the field normal.
    void
    transform(Matrix matrix, @Nullable Matrix normalMatrix, Plane res)
    Transforms a graphene_plane_t this Plane using the given matrix and normalMatrix.
    void
    writeConstant(float constant)
    Write a value in the field constant.
    void
    writeNormal(@Nullable Vec3 normal)
    Write a value in the field normal.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

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

    • Plane

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

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

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

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

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

    • getType

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

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

      public @Nullable Vec3 readNormal()
      Read the value of the field normal.
      Returns:
      The value of the field normal
    • writeNormal

      public void writeNormal(@Nullable Vec3 normal)
      Write a value in the field normal.
      Parameters:
      normal - The new value for the field normal
    • readConstant

      public float readConstant()
      Read the value of the field constant.
      Returns:
      The value of the field constant
    • writeConstant

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

      public static Plane alloc()

      Allocates a new graphene_plane_t structure.

      The contents of the returned structure are undefined.

      Returns:
      the newly allocated graphene_plane_t. Use graphene_plane_free() to free the resources allocated by this function
      Since:
      1.2
    • distance

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

      public boolean equal(Plane b)
      Checks whether the two given graphene_plane_t are equal.
      Parameters:
      b - a graphene_plane_t
      Returns:
      true if the given planes are equal
      Since:
      1.2
    • free

      public void free()
      Frees the resources allocated by graphene_plane_alloc().
      Since:
      1.2
    • getConstant

      public float getConstant()
      Retrieves the distance along the normal vector of the given graphene_plane_t from the origin.
      Returns:
      the constant value of the plane
      Since:
      1.2
    • getNormal

      public void getNormal(Vec3 normal)
      Retrieves the normal vector pointing towards the origin of the given graphene_plane_t.
      Parameters:
      normal - return location for the normal vector
      Since:
      1.2
    • init

      public Plane init(@Nullable Vec3 normal, float constant)
      Initializes the given graphene_plane_t using the given normal vector and constant values.
      Parameters:
      normal - a unit length normal vector defining the plane pointing towards the origin; if unset, we use the X axis by default
      constant - the distance from the origin to the plane along the normal vector; the sign determines the half-space occupied by the plane
      Returns:
      the initialized plane
      Since:
      1.2
    • initFromPlane

      public Plane initFromPlane(Plane src)
      Initializes the given graphene_plane_t using the normal vector and constant of another graphene_plane_t.
      Parameters:
      src - a graphene_plane_t
      Returns:
      the initialized plane
      Since:
      1.2
    • initFromPoint

      public Plane initFromPoint(Vec3 normal, Point3D point)
      Initializes the given graphene_plane_t using the given normal vector and an arbitrary co-planar point.
      Parameters:
      normal - a normal vector defining the plane pointing towards the origin
      point - a graphene_point3d_t
      Returns:
      the initialized plane
      Since:
      1.2
    • initFromPoints

      public Plane initFromPoints(Point3D a, Point3D b, Point3D c)

      Initializes the given graphene_plane_t using the 3 provided co-planar points.

      The winding order is counter-clockwise, and determines which direction the normal vector will point.

      Parameters:
      a - a graphene_point3d_t
      b - a graphene_point3d_t
      c - a graphene_point3d_t
      Returns:
      the initialized plane
      Since:
      1.2
    • initFromVec4

      public Plane initFromVec4(Vec4 src)
      Initializes the given graphene_plane_t using the components of the given graphene_vec4_t vector.
      Parameters:
      src - a graphene_vec4_t containing the normal vector in its first three components, and the distance in its fourth component
      Returns:
      the initialized plane
      Since:
      1.2
    • negate

      public void negate(Plane res)
      Negates the normal vector and constant of a graphene_plane_t, effectively mirroring the plane across the origin.
      Parameters:
      res - return location for the negated plane
      Since:
      1.2
    • normalize

      public void normalize(Plane res)
      Normalizes the vector of the given graphene_plane_t, and adjusts the constant accordingly.
      Parameters:
      res - return location for the normalized plane
      Since:
      1.2
    • transform

      public void transform(Matrix matrix, @Nullable Matrix normalMatrix, Plane res)

      Transforms a graphene_plane_t this Plane using the given matrix and normalMatrix.

      If normalMatrix is null, a transformation matrix for the plane normal will be computed from matrix. If you are transforming multiple planes using the same matrix it's recommended to compute the normal matrix beforehand to avoid incurring in the cost of recomputing it every time.

      Parameters:
      matrix - a graphene_matrix_t
      normalMatrix - a graphene_matrix_t
      res - the transformed plane
      Since:
      1.10