Package org.gnome.graphene
Class Plane
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.graphene.Plane
- All Implemented Interfaces:
Proxy
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.
-
Constructor Summary
ConstructorDescriptionPlane()
Allocate a new Plane.Allocate a new Plane.Plane
(MemorySegment address) Create a Plane proxy instance for the provided memory address.Allocate a new Plane with the fields set to the provided values.Allocate a new Plane with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionstatic Plane
alloc()
Allocates a newgraphene_plane_t
structure.float
Computes the distance ofpoint
from agraphene_plane_t
.boolean
Checks whether the two givengraphene_plane_t
are equal.void
free()
Frees the resources allocated by graphene_plane_alloc().float
Retrieves the distance along the normal vector of the givengraphene_plane_t
from the origin.static MemoryLayout
The memory layout of the native struct.void
Retrieves the normal vector pointing towards the origin of the givengraphene_plane_t
.static Type
getType()
Get the GType of the Plane classInitializes the givengraphene_plane_t
using the givennormal
vector andconstant
values.initFromPlane
(Plane src) Initializes the givengraphene_plane_t
using the normal vector and constant of anothergraphene_plane_t
.initFromPoint
(Vec3 normal, Point3D point) Initializes the givengraphene_plane_t
using the given normal vector and an arbitrary co-planar point.initFromPoints
(Point3D a, Point3D b, Point3D c) Initializes the givengraphene_plane_t
using the 3 provided co-planar points.initFromVec4
(Vec4 src) Initializes the givengraphene_plane_t
using the components of the givengraphene_vec4_t
vector.void
Negates the normal vector and constant of agraphene_plane_t
, effectively mirroring the plane across the origin.void
Normalizes the vector of the givengraphene_plane_t
, and adjusts the constant accordingly.float
Read the value of the fieldconstant
.Read the value of the fieldnormal
.void
Transforms agraphene_plane_t
this Plane using the givenmatrix
andnormalMatrix
.void
writeConstant
(float constant) Write a value in the fieldconstant
.void
writeNormal
(Vec3 normal) Write a value in the fieldnormal
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Plane
Create a Plane proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Plane
Allocate a new Plane.- Parameters:
arena
- to control the memory allocation scope
-
Plane
public Plane()Allocate a new Plane. The memory is allocated withArena.ofAuto()
. -
Plane
-
Plane
Allocate a new Plane with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
normal
- value for the fieldnormal
constant
- value for the fieldconstant
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readNormal
-
writeNormal
Write a value in the fieldnormal
.- Parameters:
normal
- The new value for the fieldnormal
-
readConstant
public float readConstant()Read the value of the fieldconstant
.- Returns:
- The value of the field
constant
-
writeConstant
public void writeConstant(float constant) Write a value in the fieldconstant
.- Parameters:
constant
- The new value for the fieldconstant
-
alloc
Allocates a newgraphene_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
-
distance
Computes the distance ofpoint
from agraphene_plane_t
.- Parameters:
point
- agraphene_point3d_t
- Returns:
- the distance of the given
graphene_point3d_t
from the plane
-
equal
Checks whether the two givengraphene_plane_t
are equal.- Parameters:
b
- agraphene_plane_t
- Returns:
true
if the given planes are equal
-
free
public void free()Frees the resources allocated by graphene_plane_alloc(). -
getConstant
public float getConstant()Retrieves the distance along the normal vector of the givengraphene_plane_t
from the origin.- Returns:
- the constant value of the plane
-
getNormal
Retrieves the normal vector pointing towards the origin of the givengraphene_plane_t
.- Parameters:
normal
- return location for the normal vector
-
init
Initializes the givengraphene_plane_t
using the givennormal
vector andconstant
values.- Parameters:
normal
- a unit length normal vector defining the plane pointing towards the origin; if unset, we use the X axis by defaultconstant
- 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
-
initFromPlane
-
initFromPoint
Initializes the givengraphene_plane_t
using the given normal vector and an arbitrary co-planar point.- Parameters:
normal
- a normal vector defining the plane pointing towards the originpoint
- agraphene_point3d_t
- Returns:
- the initialized plane
-
initFromPoints
Initializes the givengraphene_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
- agraphene_point3d_t
b
- agraphene_point3d_t
c
- agraphene_point3d_t
- Returns:
- the initialized plane
-
initFromVec4
Initializes the givengraphene_plane_t
using the components of the givengraphene_vec4_t
vector.- Parameters:
src
- agraphene_vec4_t
containing the normal vector in its first three components, and the distance in its fourth component- Returns:
- the initialized plane
-
negate
Negates the normal vector and constant of agraphene_plane_t
, effectively mirroring the plane across the origin.- Parameters:
res
- return location for the negated plane
-
normalize
Normalizes the vector of the givengraphene_plane_t
, and adjusts the constant accordingly.- Parameters:
res
- return location for the normalized plane
-
transform
Transforms agraphene_plane_t
this Plane using the givenmatrix
andnormalMatrix
.If
normalMatrix
isnull
, a transformation matrix for the plane normal will be computed frommatrix
. If you are transforming multiple planes using the samematrix
it's recommended to compute the normal matrix beforehand to avoid incurring in the cost of recomputing it every time.- Parameters:
matrix
- agraphene_matrix_t
normalMatrix
- agraphene_matrix_t
res
- the transformed plane
-