Package org.gnome.graphene
Class Triangle
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.graphene.Triangle
-
Constructor Summary
ConstructorsConstructorDescriptionTriangle()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 Trianglealloc()Allocates a newgraphene_triangle_t.booleanChecks whether the given triangle this Triangle contains the pointp.booleanChecks whether the two givengraphene_triangle_tare equal.voidfree()Frees the resources allocated by graphene_triangle_alloc().floatgetArea()Computes the area of the givengraphene_triangle_t.booleangetBarycoords(@Nullable Point3D p, Vec2 res) Computes the barycentric coordinates of the given pointp.voidgetBoundingBox(Box res) Computes the bounding box of the givengraphene_triangle_t.static MemoryLayoutThe memory layout of the native struct.voidgetMidpoint(Point3D res) Computes the coordinates of the midpoint of the givengraphene_triangle_t.voidComputes the normal vector of the givengraphene_triangle_t.voidComputes the plane based on the vertices of the givengraphene_triangle_t.voidRetrieves the three vertices of the givengraphene_triangle_tand returns their coordinates asgraphene_point3d_t.static @Nullable TypegetType()Get the GType of the Triangle classbooleanComputes the UV coordinates of the given pointp.voidgetVertices(@Nullable Vec3 a, @Nullable Vec3 b, @Nullable Vec3 c) Retrieves the three vertices of the givengraphene_triangle_t.initFromFloat(@org.jspecify.annotations.Nullable float @Nullable [] a, @org.jspecify.annotations.Nullable float @Nullable [] b, @org.jspecify.annotations.Nullable float @Nullable [] c) Initializes agraphene_triangle_tusing 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_tusing the three given 3D points.initFromVec3(@Nullable Vec3 a, @Nullable Vec3 b, @Nullable Vec3 c) Initializes agraphene_triangle_tusing the three given vectors.@Nullable Vec3readA()Read the value of the fielda.@Nullable Vec3readB()Read the value of the fieldb.@Nullable Vec3readC()Read the value of the fieldc.voidWrite a value in the fielda.voidWrite a value in the fieldb.voidWrite a value in the fieldc.Methods inherited from class org.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 fieldab- value for the fieldbc- 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_tstructure. Use graphene_triangle_free() to free the resources allocated by this function - Since:
- 1.2
-
containsPoint
Checks whether the given triangle this Triangle contains the pointp.- Parameters:
p- agraphene_point3d_t- Returns:
trueif the point is inside the triangle- Since:
- 1.2
-
equal
Checks whether the two givengraphene_triangle_tare equal.- Parameters:
b- agraphene_triangle_t- Returns:
trueif 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 givengraphene_triangle_t.- Returns:
- the area of the triangle
- Since:
- 1.2
-
getBarycoords
Computes the barycentric coordinates of the given pointp.The point
pmust lie on the same plane as the trianglet;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; andvwhich is on the AB vector:
The returned
graphene_vec2_tcontains the following values, in order:res.x = ures.y = v
- Parameters:
p- agraphene_point3d_tres- return location for the vector with the barycentric coordinates- Returns:
trueif the barycentric coordinates are valid- Since:
- 1.2
-
getBoundingBox
Computes the bounding box of the givengraphene_triangle_t.- Parameters:
res- return location for the box- Since:
- 1.2
-
getMidpoint
-
getNormal
Computes the normal vector of the givengraphene_triangle_t.- Parameters:
res- return location for the normal vector- Since:
- 1.2
-
getPlane
Computes the plane based on the vertices of the givengraphene_triangle_t.- Parameters:
res- return location for the plane- Since:
- 1.2
-
getPoints
Retrieves the three vertices of the givengraphene_triangle_tand 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- Since:
- 1.2
-
getUv
Computes the UV coordinates of the given pointp.The point
pmust lie on the same plane as the trianglet;if the point is not coplanar, the result of this function is undefined. Ifpisnull, the point will be set in (0, 0, 0).The UV coordinates will be placed in the
resvector:res.x = ures.y = v
See also: graphene_triangle_get_barycoords()
- Parameters:
p- agraphene_point3d_tuvA- 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:
trueif the coordinates are valid- Since:
- 1.10
-
getVertices
-
initFromFloat
public Triangle initFromFloat(@org.jspecify.annotations.Nullable float @Nullable [] a, @org.jspecify.annotations.Nullable float @Nullable [] b, @org.jspecify.annotations.Nullable float @Nullable [] c) Initializes agraphene_triangle_tusing 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 - Throws:
IllegalArgumentException- when length ofais less than 3IllegalArgumentException- when length ofbis less than 3IllegalArgumentException- when length ofcis less than 3- Since:
- 1.10
-
initFromPoint3d
Initializes agraphene_triangle_tusing the three given 3D points.- Parameters:
a- agraphene_point3d_tb- agraphene_point3d_tc- agraphene_point3d_t- Returns:
- the initialized
graphene_triangle_t - Since:
- 1.2
-
initFromVec3
-