Package ch.bailu.gtk.graphene
Class Triangle
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.graphene.Triangle
- All Implemented Interfaces:
PointerInterface
A triangle.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Triangle
Allocates a new #graphene_triangle_t.boolean
Checks whether the given triangle @t contains the point @p.boolean
Checks whether the two given #graphene_triangle_t are equal.void
free()
Frees the resources allocated by graphene_triangle_alloc().float
getArea()
Computes the area of the given #graphene_triangle_t.boolean
getBarycoords
(Point3D p, Vec2 res) Computes the [barycentric coordinates](http://en.wikipedia.org/wiki/Barycentric_coordinate_system)
of the given point @p.void
getBoundingBox
(Box res) Computes the bounding box of the given #graphene_triangle_t.static ClassHandler
static int
void
getMidpoint
(Point3D res) Computes the coordinates of the midpoint of the given #graphene_triangle_t.void
Computes the normal vector of the given #graphene_triangle_t.static long
static TypeSystem.TypeSize
void
Computes the plane based on the vertices of the given #graphene_triangle_t.void
Retrieves the three vertices of the given #graphene_triangle_t and returns
their coordinates as #graphene_point3d_t.static long
static TypeSystem.TypeSize
boolean
Computes the UV coordinates of the given point @p.void
getVertices
(Vec3 a, Vec3 b, Vec3 c) Retrieves the three vertices of the given #graphene_triangle_t.initFromPoint3d
(Point3D a, Point3D b, Point3D c) Initializes a #graphene_triangle_t using the three given 3D points.initFromVec3
(Vec3 a, Vec3 b, Vec3 c) Initializes a #graphene_triangle_t using the three given vectors.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
A
Private field: direct-type- See Also:
-
B
Private field: direct-type- See Also:
-
C
Private field: direct-type- See Also:
-
-
Constructor Details
-
Triangle
-
Triangle
public Triangle()
-
-
Method Details
-
getClassHandler
-
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
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
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
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_tres
- return location for the vector with the barycentric coordinates- Returns:
- `true` if the barycentric coordinates are valid
-
getBoundingBox
Computes the bounding box of the given #graphene_triangle_t.- Parameters:
res
- return location for the box
-
getMidpoint
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
Computes the normal vector of the given #graphene_triangle_t.- Parameters:
res
- return location for the normal vector
-
getPlane
Computes the plane based on the vertices of the given #graphene_triangle_t.- Parameters:
res
- return location for the plane
-
getPoints
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 vertexb
- return location for the coordinates of the second vertexc
- 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_tuv_a
- the UV coordinates of the first pointuv_b
- the UV coordinates of the second pointuv_c
- the UV coordinates of the third pointres
- a vector containing the UV coordinates of the given point @p- Returns:
- `true` if the coordinates are valid
-
getVertices
Retrieves the three vertices of the given #graphene_triangle_t.- Parameters:
a
- return location for the first vertexb
- return location for the second vertexc
- return location for the third vertex
-
initFromPoint3d
Initializes a #graphene_triangle_t using the three given 3D points.- Parameters:
a
- a #graphene_point3d_tb
- a #graphene_point3d_tc
- a #graphene_point3d_t- Returns:
- the initialized #graphene_triangle_t
-
initFromVec3
Initializes a #graphene_triangle_t using the three given vectors.- Parameters:
a
- a #graphene_vec3_tb
- a #graphene_vec3_tc
- a #graphene_vec3_t- Returns:
- the initialized #graphene_triangle_t
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-