Class Triangle

All Implemented Interfaces:
PointerInterface

public class Triangle extends Record
  • Field Details

  • Constructor Details

    • Triangle

      public Triangle(PointerContainer pointer)
    • Triangle

      public Triangle()
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • allocTriangle

      public static Triangle allocTriangle()
      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
    • containsPoint

      public boolean containsPoint(@Nonnull Point3D p)
      Checks whether the given triangle @t contains the point @p.
      Parameters:
      p - a #graphene_point3d_t
      Returns:
      `true` if the point is inside the triangle
    • equal

      public boolean equal(@Nonnull 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
    • free

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

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

      public boolean getBarycoords(@Nullable Point3D p, @Nonnull Vec2 res)
      Computes the [barycentric coordinates](http://en.wikipedia.org/wiki/Barycentric_coordinate_system)
      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:

      ![](triangle-barycentric.png)

      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
    • getBoundingBox

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

      public void getMidpoint(@Nonnull Point3D res)
      Computes the coordinates of the midpoint of the given #graphene_triangle_t.

      The midpoint G is the [centroid](https://en.wikipedia.org/wiki/Centroid#Triangle_centroid)
      of the triangle, i.e. the intersection of its medians.
      Parameters:
      res - return location for the coordinates of the midpoint
    • getNormal

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

      public void getPlane(@Nonnull Plane res)
      Computes the plane based on the vertices of the given #graphene_triangle_t.
      Parameters:
      res - return location for the plane
    • 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
    • getUv

      public boolean getUv(@Nullable Point3D p, @Nonnull Vec2 uv_a, @Nonnull Vec2 uv_b, @Nonnull Vec2 uv_c, @Nonnull 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
      uv_a - the UV coordinates of the first point
      uv_b - the UV coordinates of the second point
      uv_c - 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
    • 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
    • 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
    • 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
    • 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()