gi-graphene-1.0.8: Graphene bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Graphene.Structs.Triangle

Contents

- Exported types
- Methods
  - alloc
  - containsPoint
  - equal
  - free
  - getArea
  - getBarycoords
  - getBoundingBox
  - getMidpoint
  - getNormal
  - getPlane
  - getPoints
  - getUv
  - getVertices
  - initFromFloat
  - initFromPoint3d
  - initFromVec3

Description

A triangle.

Since: 1.2

Synopsis

- newtype Triangle = Triangle (ManagedPtr Triangle)
- newZeroTriangle :: MonadIO m => m Triangle
- triangleAlloc :: (HasCallStack, MonadIO m) => m Triangle
- triangleContainsPoint :: (HasCallStack, MonadIO m) => Triangle -> Point3D -> m Bool
- triangleEqual :: (HasCallStack, MonadIO m) => Triangle -> Triangle -> m Bool
- triangleFree :: (HasCallStack, MonadIO m) => Triangle -> m ()
- triangleGetArea :: (HasCallStack, MonadIO m) => Triangle -> m Float
- triangleGetBarycoords :: (HasCallStack, MonadIO m) => Triangle -> Maybe Point3D -> m (Bool, Vec2)
- triangleGetBoundingBox :: (HasCallStack, MonadIO m) => Triangle -> m Box
- triangleGetMidpoint :: (HasCallStack, MonadIO m) => Triangle -> m Point3D
- triangleGetNormal :: (HasCallStack, MonadIO m) => Triangle -> m Vec3
- triangleGetPlane :: (HasCallStack, MonadIO m) => Triangle -> m Plane
- triangleGetPoints :: (HasCallStack, MonadIO m) => Triangle -> m (Point3D, Point3D, Point3D)
- triangleGetUv :: (HasCallStack, MonadIO m) => Triangle -> Maybe Point3D -> Vec2 -> Vec2 -> Vec2 -> m (Bool, Vec2)
- triangleGetVertices :: (HasCallStack, MonadIO m) => Triangle -> m (Vec3, Vec3, Vec3)
- triangleInitFromFloat :: (HasCallStack, MonadIO m) => Triangle -> [Float] -> [Float] -> [Float] -> m Triangle
- triangleInitFromPoint3d :: (HasCallStack, MonadIO m) => Triangle -> Maybe Point3D -> Maybe Point3D -> Maybe Point3D -> m Triangle
- triangleInitFromVec3 :: (HasCallStack, MonadIO m) => Triangle -> Maybe Vec3 -> Maybe Vec3 -> Maybe Vec3 -> m Triangle

# Exported types

newtype Triangle Source #

Memory-managed wrapper type.

Constructors

Triangle (ManagedPtr Triangle) |

#### Instances

Instances details

Eq Triangle Source # |
Instance details Defined in GI.Graphene.Structs.Triangle Methods (==) :: Triangle -> Triangle -> Bool Source # (/=) :: Triangle -> Triangle -> Bool Source #
GBoxed Triangle Source # |
Instance details Defined in GI.Graphene.Structs.Triangle
ManagedPtrNewtype Triangle Source # |
Instance details Defined in GI.Graphene.Structs.Triangle Methods toManagedPtr :: Triangle -> ManagedPtr Triangle Source #
TypedObject Triangle Source # |
Instance details Defined in GI.Graphene.Structs.Triangle Methods glibType :: IO GType Source #
HasParentTypes Triangle Source # |
Instance details Defined in GI.Graphene.Structs.Triangle
tag ~ 'AttrSet => Constructible Triangle tag Source # |
Instance details Defined in GI.Graphene.Structs.Triangle Methods new :: MonadIO m => (ManagedPtr Triangle -> Triangle) -> [AttrOp Triangle tag] -> m Triangle Source #
IsGValue (Maybe Triangle) Source # | Convert `Triangle` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Graphene.Structs.Triangle Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Triangle -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Triangle) Source #
type ParentTypes Triangle Source # |
Instance details Defined in GI.Graphene.Structs.Triangle type ParentTypes Triangle = '[] :: [Type]

newZeroTriangle :: MonadIO m => m Triangle Source #

Construct a `Triangle` struct initialized to zero.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

containsPoint, equal, free, initFromFloat, initFromPoint3d, initFromVec3.

#### Getters

getArea, getBarycoords, getBoundingBox, getMidpoint, getNormal, getPlane, getPoints, getUv, getVertices.

#### Setters

None.

## alloc

triangleAlloc Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m Triangle | Returns: the newly allocated `Triangle` structure. Use `triangleFree` to free the resources allocated by this function

Allocates a new `Triangle`.

The contents of the returned structure are undefined.

Since: 1.2

## containsPoint

triangleContainsPoint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> Point3D | `p`: a `Point3D`
-> m Bool | Returns: `true` if the point is inside the triangle

Checks whether the given triangle `t` contains the point `p`.

Since: 1.2

## equal

triangleEqual Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `a`: a `Triangle`
-> Triangle | `b`: a `Triangle`
-> m Bool | Returns: `true` if the triangles are equal

Checks whether the two given `Triangle` are equal.

Since: 1.2

## free

triangleFree Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> m () |

Frees the resources allocated by `triangleAlloc`.

Since: 1.2

## getArea

triangleGetArea Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> m Float | Returns: the area of the triangle

Computes the area of the given `Triangle`.

Since: 1.2

## getBarycoords

triangleGetBarycoords Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> Maybe Point3D | `p`: a `Point3D`
-> m (Bool, Vec2) | Returns: `true` if the barycentric coordinates are valid

Computes the barycentric 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 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:

The returned `Vec2` contains the following values, in order:

-     res.x = u

-     res.y = v

Since: 1.2

## getBoundingBox

triangleGetBoundingBox Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> m Box |

Computes the bounding box of the given `Triangle`.

Since: 1.2

## getMidpoint

triangleGetMidpoint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> m Point3D |

Computes the coordinates of the midpoint of the given `Triangle`.

The midpoint G is the centroid of the triangle, i.e. the intersection of its medians.

Since: 1.2

## getNormal

triangleGetNormal Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> m Vec3 |

Computes the normal vector of the given `Triangle`.

Since: 1.2

## getPlane

triangleGetPlane Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> m Plane |

Computes the plane based on the vertices of the given `Triangle`.

Since: 1.2

## getPoints

triangleGetPoints Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> m (Point3D, Point3D, Point3D) |

Retrieves the three vertices of the given `Triangle` and returns their coordinates as `Point3D`.

Since: 1.2

## getUv

triangleGetUv Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> Maybe Point3D | `p`: a `Point3D`
-> Vec2 | `uvA`: the UV coordinates of the first point
-> Vec2 | `uvB`: the UV coordinates of the second point
-> Vec2 | `uvC`: the UV coordinates of the third point
-> m (Bool, Vec2) | Returns: `true` if the coordinates are valid

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 `Nothing`, 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: `triangleGetBarycoords`

Since: 1.10

## getVertices

triangleGetVertices Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: a `Triangle`
-> m (Vec3, Vec3, Vec3) |

Retrieves the three vertices of the given `Triangle`.

Since: 1.2

## initFromFloat

triangleInitFromFloat Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: the `Triangle` to initialize
-> [Float] | `a`: an array of 3 floating point values
-> [Float] | `b`: an array of 3 floating point values
-> [Float] | `c`: an array of 3 floating point values
-> m Triangle | Returns: the initialized `Triangle`

Initializes a `Triangle` using the three given arrays of floating point values, each representing the coordinates of a point in 3D space.

Since: 1.10

## initFromPoint3d

triangleInitFromPoint3d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: the `Triangle` to initialize
-> Maybe Point3D | `a`: a `Point3D`
-> Maybe Point3D | `b`: a `Point3D`
-> Maybe Point3D | `c`: a `Point3D`
-> m Triangle | Returns: the initialized `Triangle`

Initializes a `Triangle` using the three given 3D points.

Since: 1.2

## initFromVec3

triangleInitFromVec3 Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Triangle | `t`: the `Triangle` to initialize
-> Maybe Vec3 | `a`: a `Vec3`
-> Maybe Vec3 | `b`: a `Vec3`
-> Maybe Vec3 | `c`: a `Vec3`
-> m Triangle | Returns: the initialized `Triangle`

Initializes a `Triangle` using the three given vectors.

Since: 1.2