Class Triangle

java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.graphene.Triangle
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Triangle extends ProxyInstance
A triangle.
Since:
1.2
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    static Triangle
    Allocates a new graphene_triangle_t.
    boolean
    Checks whether the given triangle this Triangle contains the point p.
    boolean
    Checks whether the two given graphene_triangle_t are equal.
    void
    Frees the resources allocated by graphene_triangle_alloc().
    float
    Computes the area of the given graphene_triangle_t.
    boolean
    getBarycoords(@Nullable Point3D p, Vec2 res)
    Computes the barycentric coordinates of the given point p.
    void
    Computes the bounding box of the given graphene_triangle_t.
    The memory layout of the native struct.
    void
    Computes the coordinates of the midpoint of the given graphene_triangle_t.
    void
    Computes the normal vector of the given graphene_triangle_t.
    void
    Computes the plane based on the vertices of the given graphene_triangle_t.
    void
    getPoints(@Nullable Point3D a, @Nullable Point3D b, @Nullable Point3D c)
    Retrieves the three vertices of the given graphene_triangle_t and returns their coordinates as graphene_point3d_t.
    static @Nullable Type
    Get the GType of the Triangle class.
    boolean
    getUv(@Nullable Point3D p, Vec2 uvA, Vec2 uvB, Vec2 uvC, Vec2 res)
    Computes the UV coordinates of the given point p.
    void
    getVertices(@Nullable Vec3 a, @Nullable Vec3 b, @Nullable Vec3 c)
    Retrieves the three vertices of the given graphene_triangle_t.
    initFromFloat(@Nullable float @Nullable [] a, @Nullable float @Nullable [] b, @Nullable float @Nullable [] c)
    Initializes a graphene_triangle_t using the three given arrays of floating point values, each representing the coordinates of a point in 3D space.
    initFromPoint3d(@Nullable Point3D a, @Nullable Point3D b, @Nullable Point3D c)
    Initializes a graphene_triangle_t using the three given 3D points.
    initFromVec3(@Nullable Vec3 a, @Nullable Vec3 b, @Nullable Vec3 c)
    Initializes a graphene_triangle_t using the three given vectors.
    @Nullable Vec3
    Read the value of the field a.
    @Nullable Vec3
    Read the value of the field b.
    @Nullable Vec3
    Read the value of the field c.
    void
    writeA(@Nullable Vec3 a)
    Write a value in the field a.
    void
    writeB(@Nullable Vec3 b)
    Write a value in the field b.
    void
    writeC(@Nullable Vec3 c)
    Write a value in the field c.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

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

    • Triangle

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

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

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

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

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

    • getType

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

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

      public @Nullable Vec3 readA()
      Read the value of the field a.
      Returns:
      The value of the field a
    • writeA

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

      public @Nullable Vec3 readB()
      Read the value of the field b.
      Returns:
      The value of the field b
    • writeB

      public void writeB(@Nullable Vec3 b)
      Write a value in the field b.
      Parameters:
      b - The new value for the field b
    • readC

      public @Nullable Vec3 readC()
      Read the value of the field c.
      Returns:
      The value of the field c
    • writeC

      public void writeC(@Nullable Vec3 c)
      Write a value in the field c.
      Parameters:
      c - The new value for the field c
    • alloc

      public static Triangle alloc()

      Allocates a new graphene_triangle_t.

      The contents of the returned structure are undefined.

      Returns:
      the newly allocated graphene_triangle_t structure. Use graphene_triangle_free() to free the resources allocated by this function
      Since:
      1.2
    • containsPoint

      public boolean containsPoint(Point3D p)
      Checks whether the given triangle this Triangle contains the point p.
      Parameters:
      p - a graphene_point3d_t
      Returns:
      true if the point is inside the triangle
      Since:
      1.2
    • equal

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

      public void free()
      Frees the resources allocated by graphene_triangle_alloc().
      Since:
      1.2
    • getArea

      public float getArea()
      Computes the area of the given graphene_triangle_t.
      Returns:
      the area of the triangle
      Since:
      1.2
    • getBarycoords

      public boolean getBarycoords(@Nullable Point3D p, Vec2 res)

      Computes the barycentric coordinates of the given point p.

      The point p must lie on the same plane as the triangle t; if the point is not coplanar, the result of this function is undefined.

      If we place the origin in the coordinates of the triangle's A point, the barycentric coordinates are u, which is on the AC vector; and v which is on the AB vector:

      The returned graphene_vec2_t contains the following values, in order:

      • res.x = u
      • res.y = v
      Parameters:
      p - a graphene_point3d_t
      res - return location for the vector with the barycentric coordinates
      Returns:
      true if the barycentric coordinates are valid
      Since:
      1.2
    • getBoundingBox

      public void getBoundingBox(Box res)
      Computes the bounding box of the given graphene_triangle_t.
      Parameters:
      res - return location for the box
      Since:
      1.2
    • getMidpoint

      public void getMidpoint(Point3D res)

      Computes the coordinates of the midpoint of the given graphene_triangle_t.

      The midpoint G is the centroid of the triangle, i.e. the intersection of its medians.

      Parameters:
      res - return location for the coordinates of the midpoint
      Since:
      1.2
    • getNormal

      public void getNormal(Vec3 res)
      Computes the normal vector of the given graphene_triangle_t.
      Parameters:
      res - return location for the normal vector
      Since:
      1.2
    • getPlane

      public void getPlane(Plane res)
      Computes the plane based on the vertices of the given graphene_triangle_t.
      Parameters:
      res - return location for the plane
      Since:
      1.2
    • getPoints

      public void getPoints(@Nullable Point3D a, @Nullable Point3D b, @Nullable Point3D c)
      Retrieves the three vertices of the given graphene_triangle_t and returns their coordinates as graphene_point3d_t.
      Parameters:
      a - return location for the coordinates of the first vertex
      b - return location for the coordinates of the second vertex
      c - return location for the coordinates of the third vertex
      Since:
      1.2
    • getUv

      public boolean getUv(@Nullable Point3D p, Vec2 uvA, Vec2 uvB, Vec2 uvC, Vec2 res)

      Computes the UV coordinates of the given point p.

      The point p must lie on the same plane as the triangle t; if the point is not coplanar, the result of this function is undefined. If p is null, the point will be set in (0, 0, 0).

      The UV coordinates will be placed in the res vector:

      • res.x = u
      • res.y = v

      See also: graphene_triangle_get_barycoords()

      Parameters:
      p - a graphene_point3d_t
      uvA - the UV coordinates of the first point
      uvB - the UV coordinates of the second point
      uvC - the UV coordinates of the third point
      res - a vector containing the UV coordinates of the given point p
      Returns:
      true if the coordinates are valid
      Since:
      1.10
    • getVertices

      public void getVertices(@Nullable Vec3 a, @Nullable Vec3 b, @Nullable Vec3 c)
      Retrieves the three vertices of the given graphene_triangle_t.
      Parameters:
      a - return location for the first vertex
      b - return location for the second vertex
      c - return location for the third vertex
      Since:
      1.2
    • initFromFloat

      public Triangle initFromFloat(@Nullable float @Nullable [] a, @Nullable float @Nullable [] b, @Nullable float @Nullable [] c)
      Initializes a graphene_triangle_t using the three given arrays of floating point values, each representing the coordinates of a point in 3D space.
      Parameters:
      a - an array of 3 floating point values
      b - an array of 3 floating point values
      c - an array of 3 floating point values
      Returns:
      the initialized graphene_triangle_t
      Throws:
      IllegalArgumentException - when length of a is less than 3
      IllegalArgumentException - when length of b is less than 3
      IllegalArgumentException - when length of c is less than 3
      Since:
      1.10
    • initFromPoint3d

      public Triangle initFromPoint3d(@Nullable Point3D a, @Nullable Point3D b, @Nullable Point3D c)
      Initializes a graphene_triangle_t using the three given 3D points.
      Parameters:
      a - a graphene_point3d_t
      b - a graphene_point3d_t
      c - a graphene_point3d_t
      Returns:
      the initialized graphene_triangle_t
      Since:
      1.2
    • initFromVec3

      public Triangle initFromVec3(@Nullable Vec3 a, @Nullable Vec3 b, @Nullable Vec3 c)
      Initializes a graphene_triangle_t using the three given vectors.
      Parameters:
      a - a graphene_vec3_t
      b - a graphene_vec3_t
      c - a graphene_vec3_t
      Returns:
      the initialized graphene_triangle_t
      Since:
      1.2