Package org.gnome.graphene
Class Triangle
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.graphene.Triangle
-
Constructor Summary
ConstructorDescriptionTriangle()
Allocate a new Triangle.Allocate a new Triangle.Triangle
(MemorySegment address) Create a Triangle proxy instance for the provided memory address.Allocate a new Triangle with the fields set to the provided values.Allocate a new Triangle with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionstatic Triangle
alloc()
Allocates a newgraphene_triangle_t
.boolean
Checks whether the given triangle this Triangle contains the pointp
.boolean
Checks whether the two givengraphene_triangle_t
are equal.void
free()
Frees the resources allocated by graphene_triangle_alloc().float
getArea()
Computes the area of the givengraphene_triangle_t
.boolean
getBarycoords
(@Nullable Point3D p, Vec2 res) Computes the barycentric coordinates of the given pointp
.void
getBoundingBox
(Box res) Computes the bounding box of the givengraphene_triangle_t
.static MemoryLayout
The memory layout of the native struct.void
getMidpoint
(Point3D res) Computes the coordinates of the midpoint of the givengraphene_triangle_t
.void
Computes the normal vector of the givengraphene_triangle_t
.void
Computes the plane based on the vertices of the givengraphene_triangle_t
.void
Retrieves the three vertices of the givengraphene_triangle_t
and returns their coordinates asgraphene_point3d_t
.static Type
getType()
Get the GType of the Triangle classboolean
Computes the UV coordinates of the given pointp
.void
getVertices
(@Nullable Vec3 a, @Nullable Vec3 b, @Nullable Vec3 c) Retrieves the three vertices of the givengraphene_triangle_t
.initFromFloat
(float[] a, float[] b, float[] c) Initializes agraphene_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 agraphene_triangle_t
using the three given 3D points.initFromVec3
(@Nullable Vec3 a, @Nullable Vec3 b, @Nullable Vec3 c) Initializes agraphene_triangle_t
using the three given vectors.readA()
Read the value of the fielda
.readB()
Read the value of the fieldb
.readC()
Read the value of the fieldc
.void
Write a value in the fielda
.void
Write a value in the fieldb
.void
Write a value in the fieldc
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Triangle
Create a Triangle proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Triangle
Allocate a new Triangle.- Parameters:
arena
- to control the memory allocation scope
-
Triangle
public Triangle()Allocate a new Triangle. The memory is allocated withArena.ofAuto()
. -
Triangle
-
Triangle
Allocate a new Triangle with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
a
- value for the fielda
b
- value for the fieldb
c
- value for the fieldc
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readA
-
writeA
Write a value in the fielda
.- Parameters:
a
- The new value for the fielda
-
readB
-
writeB
Write a value in the fieldb
.- Parameters:
b
- The new value for the fieldb
-
readC
-
writeC
Write a value in the fieldc
.- Parameters:
c
- The new value for the fieldc
-
alloc
Allocates a newgraphene_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
Checks whether the given triangle this Triangle contains the pointp
.- Parameters:
p
- agraphene_point3d_t
- Returns:
true
if the point is inside the triangle
-
equal
Checks whether the two givengraphene_triangle_t
are equal.- Parameters:
b
- agraphene_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 givengraphene_triangle_t
.- Returns:
- the area of the triangle
-
getBarycoords
Computes the barycentric coordinates of the given pointp
.The point
p
must lie on the same plane as the triangle this Triangle; 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; andv
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
- agraphene_point3d_t
res
- return location for the vector with the barycentric coordinates- Returns:
true
if the barycentric coordinates are valid
-
getBoundingBox
Computes the bounding box of the givengraphene_triangle_t
.- Parameters:
res
- return location for the box
-
getMidpoint
-
getNormal
Computes the normal vector of the givengraphene_triangle_t
.- Parameters:
res
- return location for the normal vector
-
getPlane
Computes the plane based on the vertices of the givengraphene_triangle_t
.- Parameters:
res
- return location for the plane
-
getPoints
public void getPoints(@Nullable @Nullable Point3D a, @Nullable @Nullable Point3D b, @Nullable @Nullable Point3D c) Retrieves the three vertices of the givengraphene_triangle_t
and returns their coordinates asgraphene_point3d_t
.- Parameters:
a
- return location for the coordinates of the first vertexb
- return location for the coordinates of the second vertexc
- return location for the coordinates of the third vertex
-
getUv
Computes the UV coordinates of the given pointp
.The point
p
must lie on the same plane as the triangle this Triangle; if the point is not coplanar, the result of this function is undefined. Ifp
isnull
, 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
- agraphene_point3d_t
uvA
- the UV coordinates of the first pointuvB
- the UV coordinates of the second pointuvC
- the UV coordinates of the third pointres
- a vector containing the UV coordinates of the given pointp
- Returns:
true
if the coordinates are valid
-
getVertices
public void getVertices(@Nullable @Nullable Vec3 a, @Nullable @Nullable Vec3 b, @Nullable @Nullable Vec3 c) Retrieves the three vertices of the givengraphene_triangle_t
.- Parameters:
a
- return location for the first vertexb
- return location for the second vertexc
- return location for the third vertex
-
initFromFloat
Initializes agraphene_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 valuesb
- an array of 3 floating point valuesc
- an array of 3 floating point values- Returns:
- the initialized
graphene_triangle_t
-
initFromPoint3d
public Triangle initFromPoint3d(@Nullable @Nullable Point3D a, @Nullable @Nullable Point3D b, @Nullable @Nullable Point3D c) Initializes agraphene_triangle_t
using the three given 3D points.- Parameters:
a
- agraphene_point3d_t
b
- agraphene_point3d_t
c
- agraphene_point3d_t
- Returns:
- the initialized
graphene_triangle_t
-
initFromVec3
public Triangle initFromVec3(@Nullable @Nullable Vec3 a, @Nullable @Nullable Vec3 b, @Nullable @Nullable Vec3 c) Initializes agraphene_triangle_t
using the three given vectors.- Parameters:
a
- agraphene_vec3_t
b
- agraphene_vec3_t
c
- agraphene_vec3_t
- Returns:
- the initialized
graphene_triangle_t
-