graphene

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const PI = 3.141593
View Source
const PI_2 = 1.570796
View Source
const VEC2_LEN = 2

VEC2_LEN evaluates to the number of components of a #graphene_vec2_t.

This symbol is useful when declaring a C array of floating point values to be used with graphene_vec2_init_from_float() and graphene_vec2_to_float(), e.g.

float v[GRAPHENE_VEC2_LEN];

// vec is defined elsewhere
graphene_vec2_to_float (&vec, v);

for (int i = 0; i < GRAPHENE_VEC2_LEN; i++)
  fprintf (stdout, "component d: g\n", i, v[i]);.
View Source
const VEC3_LEN = 3

VEC3_LEN evaluates to the number of components of a #graphene_vec3_t.

This symbol is useful when declaring a C array of floating point values to be used with graphene_vec3_init_from_float() and graphene_vec3_to_float(), e.g.

float v[GRAPHENE_VEC3_LEN];

// vec is defined elsewhere
graphene_vec3_to_float (&vec, v);

for (int i = 0; i < GRAPHENE_VEC2_LEN; i++)
  fprintf (stdout, "component d: g\n", i, v[i]);.
View Source
const VEC4_LEN = 4

VEC4_LEN evaluates to the number of components of a #graphene_vec4_t.

This symbol is useful when declaring a C array of floating point values to be used with graphene_vec4_init_from_float() and graphene_vec4_to_float(), e.g.

float v[GRAPHENE_VEC4_LEN];

// vec is defined elsewhere
graphene_vec4_to_float (&vec, v);

for (int i = 0; i < GRAPHENE_VEC4_LEN; i++)
  fprintf (stdout, "component d: g\n", i, v[i]);.

Variables

GType values.

Functions

This section is empty.

Types

type Box

type Box struct {
	// contains filtered or unexported fields
}

Box: 3D box, described as the volume between a minimum and a maximum vertices.

An instance of this type is always passed by reference.

func BoxEmpty

func BoxEmpty() *Box

BoxEmpty: degenerate #graphene_box_t that can only be expanded.

The returned value is owned by Graphene and should not be modified or freed.

The function returns the following values:

  • box: #graphene_box_t.

func BoxInfinite

func BoxInfinite() *Box

BoxInfinite: degenerate #graphene_box_t that cannot be expanded.

The returned value is owned by Graphene and should not be modified or freed.

The function returns the following values:

  • box: #graphene_box_t.

func BoxMinusOne

func BoxMinusOne() *Box

BoxMinusOne with the minimum vertex set at (-1, -1, -1) and the maximum vertex set at (0, 0, 0).

The returned value is owned by Graphene and should not be modified or freed.

The function returns the following values:

  • box: #graphene_box_t.

func BoxOne

func BoxOne() *Box

BoxOne with the minimum vertex set at (0, 0, 0) and the maximum vertex set at (1, 1, 1).

The returned value is owned by Graphene and should not be modified or freed.

The function returns the following values:

  • box: #graphene_box_t.

func BoxOneMinusOne

func BoxOneMinusOne() *Box

BoxOneMinusOne with the minimum vertex set at (-1, -1, -1) and the maximum vertex set at (1, 1, 1).

The returned value is owned by Graphene and should not be modified or freed.

The function returns the following values:

  • box: #graphene_box_t.

func BoxZero

func BoxZero() *Box

BoxZero with both the minimum and maximum vertices set at (0, 0, 0).

The returned value is owned by Graphene and should not be modified or freed.

The function returns the following values:

  • box: #graphene_box_t.

func NewBoxAlloc

func NewBoxAlloc() *Box

NewBoxAlloc constructs a struct Box.

func (*Box) BoundingSphere

func (box *Box) BoundingSphere() *Sphere

BoundingSphere computes the bounding #graphene_sphere_t capable of containing the given #graphene_box_t.

The function returns the following values:

  • sphere: return location for the bounding sphere.

func (*Box) Center

func (box *Box) Center() *Point3D

Center retrieves the coordinates of the center of a #graphene_box_t.

The function returns the following values:

  • center: return location for the coordinates of the center.

func (*Box) ContainsBox

func (a *Box) ContainsBox(b *Box) bool

ContainsBox checks whether the #graphene_box_t a contains the given #graphene_box_t b.

The function takes the following parameters:

  • b: #graphene_box_t.

The function returns the following values:

  • ok: true if the box is contained in the given box.

func (*Box) ContainsPoint

func (box *Box) ContainsPoint(point *Point3D) bool

ContainsPoint checks whether box contains the given point.

The function takes the following parameters:

  • point coordinates to check.

The function returns the following values:

  • ok: true if the point is contained in the given box.

func (*Box) Depth

func (box *Box) Depth() float32

Depth retrieves the size of the box on the Z axis.

The function returns the following values:

  • gfloat: depth of the box.

func (*Box) Equal

func (a *Box) Equal(b *Box) bool

Equal checks whether the two given boxes are equal.

The function takes the following parameters:

  • b: #graphene_box_t.

The function returns the following values:

  • ok: true if the boxes are equal.

func (*Box) Expand

func (box *Box) Expand(point *Point3D) *Box

Expand expands the dimensions of box to include the coordinates at point.

The function takes the following parameters:

  • point coordinates of the point to include.

The function returns the following values:

  • res: return location for the expanded box.

func (*Box) ExpandScalar

func (box *Box) ExpandScalar(scalar float32) *Box

ExpandScalar expands the dimensions of box by the given scalar value.

If scalar is positive, the #graphene_box_t will grow; if scalar is negative, the #graphene_box_t will shrink.

The function takes the following parameters:

  • scalar value.

The function returns the following values:

  • res: return location for the expanded box.

func (*Box) ExpandVec3

func (box *Box) ExpandVec3(vec *Vec3) *Box

ExpandVec3 expands the dimensions of box to include the coordinates of the given vector.

The function takes the following parameters:

  • vec coordinates of the point to include, as a #graphene_vec3_t.

The function returns the following values:

  • res: return location for the expanded box.

func (*Box) Height

func (box *Box) Height() float32

Height retrieves the size of the box on the Y axis.

The function returns the following values:

  • gfloat: height of the box.

func (*Box) Init

func (box *Box) Init(min *Point3D, max *Point3D) *Box

Init initializes the given #graphene_box_t with two vertices.

The function takes the following parameters:

  • min (optional) coordinates of the minimum vertex.
  • max (optional) coordinates of the maximum vertex.

The function returns the following values:

  • ret: initialized #graphene_box_t.

func (*Box) InitFromBox

func (box *Box) InitFromBox(src *Box) *Box

InitFromBox initializes the given #graphene_box_t with the vertices of another #graphene_box_t.

The function takes the following parameters:

  • src: #graphene_box_t.

The function returns the following values:

  • ret: initialized #graphene_box_t.

func (*Box) InitFromPoints

func (box *Box) InitFromPoints(points []Point3D) *Box

InitFromPoints initializes the given #graphene_box_t with the given array of vertices.

If n_points is 0, the returned box is initialized with graphene_box_empty().

The function takes the following parameters:

  • points: array of #graphene_point3d_t.

The function returns the following values:

  • ret: initialized #graphene_box_t.

func (*Box) InitFromVec3

func (box *Box) InitFromVec3(min *Vec3, max *Vec3) *Box

InitFromVec3 initializes the given #graphene_box_t with two vertices stored inside #graphene_vec3_t.

The function takes the following parameters:

  • min (optional) coordinates of the minimum vertex.
  • max (optional) coordinates of the maximum vertex.

The function returns the following values:

  • ret: initialized #graphene_box_t.

func (*Box) InitFromVectors

func (box *Box) InitFromVectors(vectors []Vec3) *Box

InitFromVectors initializes the given #graphene_box_t with the given array of vertices.

If n_vectors is 0, the returned box is initialized with graphene_box_empty().

The function takes the following parameters:

  • vectors: array of #graphene_vec3_t.

The function returns the following values:

  • ret: initialized #graphene_box_t.

func (*Box) Intersection

func (a *Box) Intersection(b *Box) (*Box, bool)

Intersection intersects the two given #graphene_box_t.

If the two boxes do not intersect, res will contain a degenerate box initialized with graphene_box_empty().

The function takes the following parameters:

  • b: #graphene_box_t.

The function returns the following values:

  • res (optional): return location for the result.
  • ok: true if the two boxes intersect.

func (*Box) Max

func (box *Box) Max() *Point3D

Max retrieves the coordinates of the maximum point of the given #graphene_box_t.

The function returns the following values:

  • max: return location for the maximum point.

func (*Box) Min

func (box *Box) Min() *Point3D

Min retrieves the coordinates of the minimum point of the given #graphene_box_t.

The function returns the following values:

  • min: return location for the minimum point.

func (*Box) Size

func (box *Box) Size() *Vec3

Size retrieves the size of the box on all three axes, and stores it into the given size vector.

The function returns the following values:

  • size: return location for the size.

func (*Box) Union

func (a *Box) Union(b *Box) *Box

Union unions the two given #graphene_box_t.

The function takes the following parameters:

  • b: box to union to a.

The function returns the following values:

  • res: return location for the result.

func (*Box) Vertices

func (box *Box) Vertices() [8]Vec3

Vertices computes the vertices of the given #graphene_box_t.

The function returns the following values:

  • vertices: return location for an array of 8 #graphene_vec3_t.

func (*Box) Width

func (box *Box) Width() float32

Width retrieves the size of the box on the X axis.

The function returns the following values:

  • gfloat: width of the box.

type Euler

type Euler struct {
	// contains filtered or unexported fields
}

Euler: describe a rotation using Euler angles.

The contents of the #graphene_euler_t structure are private and should never be accessed directly.

An instance of this type is always passed by reference.

func NewEulerAlloc

func NewEulerAlloc() *Euler

NewEulerAlloc constructs a struct Euler.

func (*Euler) Alpha

func (e *Euler) Alpha() float32

Alpha retrieves the first component of the Euler angle vector, depending on the order of rotation.

See also: graphene_euler_get_x().

The function returns the following values:

  • gfloat: first component of the Euler angle vector, in radians.

func (*Euler) Beta

func (e *Euler) Beta() float32

Beta retrieves the second component of the Euler angle vector, depending on the order of rotation.

See also: graphene_euler_get_y().

The function returns the following values:

  • gfloat: second component of the Euler angle vector, in radians.

func (*Euler) Equal

func (a *Euler) Equal(b *Euler) bool

Equal checks if two #graphene_euler_t are equal.

The function takes the following parameters:

  • b: #graphene_euler_t.

The function returns the following values:

  • ok: true if the two #graphene_euler_t are equal.

func (*Euler) Gamma

func (e *Euler) Gamma() float32

Gamma retrieves the third component of the Euler angle vector, depending on the order of rotation.

See also: graphene_euler_get_z().

The function returns the following values:

  • gfloat: third component of the Euler angle vector, in radians.

func (*Euler) Init

func (e *Euler) Init(x float32, y float32, z float32) *Euler

Init initializes a #graphene_euler_t using the given angles.

The order of the rotations is GRAPHENE_EULER_ORDER_DEFAULT.

The function takes the following parameters:

  • x: rotation angle on the X axis, in degrees.
  • y: rotation angle on the Y axis, in degrees.
  • z: rotation angle on the Z axis, in degrees.

The function returns the following values:

  • euler: initialized #graphene_euler_t.

func (*Euler) InitFromEuler

func (e *Euler) InitFromEuler(src *Euler) *Euler

InitFromEuler initializes a #graphene_euler_t using the angles and order of another #graphene_euler_t.

If the #graphene_euler_t src is NULL, this function is equivalent to calling graphene_euler_init() with all angles set to 0.

The function takes the following parameters:

  • src (optional): #graphene_euler_t.

The function returns the following values:

  • euler: initialized #graphene_euler_t.

func (*Euler) InitFromMatrix

func (e *Euler) InitFromMatrix(m *Matrix, order EulerOrder) *Euler

InitFromMatrix initializes a #graphene_euler_t using the given rotation matrix.

If the #graphene_matrix_t m is NULL, the #graphene_euler_t will be initialized with all angles set to 0.

The function takes the following parameters:

  • m (optional): rotation matrix.
  • order used to apply the rotations.

The function returns the following values:

  • euler: initialized #graphene_euler_t.

func (*Euler) InitFromQuaternion

func (e *Euler) InitFromQuaternion(q *Quaternion, order EulerOrder) *Euler

InitFromQuaternion initializes a #graphene_euler_t using the given normalized quaternion.

If the #graphene_quaternion_t q is NULL, the #graphene_euler_t will be initialized with all angles set to 0.

The function takes the following parameters:

  • q (optional): normalized #graphene_quaternion_t.
  • order used to apply the rotations.

The function returns the following values:

  • euler: initialized #graphene_euler_t.

func (*Euler) InitFromRadians

func (e *Euler) InitFromRadians(x float32, y float32, z float32, order EulerOrder) *Euler

InitFromRadians initializes a #graphene_euler_t using the given angles and order of rotation.

The function takes the following parameters:

  • x: rotation angle on the X axis, in radians.
  • y: rotation angle on the Y axis, in radians.
  • z: rotation angle on the Z axis, in radians.
  • order of rotations.

The function returns the following values:

  • euler: initialized #graphene_euler_t.

func (*Euler) InitFromVec3

func (e *Euler) InitFromVec3(v *Vec3, order EulerOrder) *Euler

InitFromVec3 initializes a #graphene_euler_t using the angles contained in a #graphene_vec3_t.

If the #graphene_vec3_t v is NULL, the #graphene_euler_t will be initialized with all angles set to 0.

The function takes the following parameters:

  • v (optional) containing the rotation angles in degrees.
  • order used to apply the rotations.

The function returns the following values:

  • euler: initialized #graphene_euler_t.

func (*Euler) InitWithOrder

func (e *Euler) InitWithOrder(x float32, y float32, z float32, order EulerOrder) *Euler

InitWithOrder initializes a #graphene_euler_t with the given angles and order.

The function takes the following parameters:

  • x: rotation angle on the X axis, in degrees.
  • y: rotation angle on the Y axis, in degrees.
  • z: rotation angle on the Z axis, in degrees.
  • order used to apply the rotations.

The function returns the following values:

  • euler: initialized #graphene_euler_t.

func (*Euler) Order

func (e *Euler) Order() EulerOrder

Order retrieves the order used to apply the rotations described in the #graphene_euler_t structure, when converting to and from other structures, like #graphene_quaternion_t and #graphene_matrix_t.

This function does not return the GRAPHENE_EULER_ORDER_DEFAULT enumeration value; it will return the effective order of rotation instead.

The function returns the following values:

  • eulerOrder: order used to apply the rotations.

func (*Euler) Reorder

func (e *Euler) Reorder(order EulerOrder) *Euler

Reorder reorders a #graphene_euler_t using order.

This function is equivalent to creating a #graphene_quaternion_t from the given #graphene_euler_t, and then converting the quaternion into another #graphene_euler_t.

The function takes the following parameters:

  • order: new order.

The function returns the following values:

  • res: return location for the reordered #graphene_euler_t.

func (*Euler) ToMatrix

func (e *Euler) ToMatrix() *Matrix

ToMatrix converts a #graphene_euler_t into a transformation matrix expressing the extrinsic composition of rotations described by the Euler angles.

The rotations are applied over the reference frame axes in the order associated with the #graphene_euler_t; for instance, if the order used to initialize e is GRAPHENE_EULER_ORDER_XYZ:

  • the first rotation moves the body around the X axis with an angle φ
  • the second rotation moves the body around the Y axis with an angle of ϑ
  • the third rotation moves the body around the Z axis with an angle of ψ

The rotation sign convention is right-handed, to preserve compatibility between Euler-based, quaternion-based, and angle-axis-based rotations.

The function returns the following values:

  • res: return location for a #graphene_matrix_t.

func (*Euler) ToQuaternion

func (e *Euler) ToQuaternion() *Quaternion

ToQuaternion converts a #graphene_euler_t into a #graphene_quaternion_t.

The function returns the following values:

  • res: return location for a #graphene_quaternion_t.

func (*Euler) ToVec3

func (e *Euler) ToVec3() *Vec3

ToVec3 retrieves the angles of a #graphene_euler_t and initializes a #graphene_vec3_t with them.

The function returns the following values:

  • res: return location for a #graphene_vec3_t.

func (*Euler) X

func (e *Euler) X() float32

X retrieves the rotation angle on the X axis, in degrees.

The function returns the following values:

  • gfloat: rotation angle.

func (*Euler) Y

func (e *Euler) Y() float32

Y retrieves the rotation angle on the Y axis, in degrees.

The function returns the following values:

  • gfloat: rotation angle.

func (*Euler) Z

func (e *Euler) Z() float32

Z retrieves the rotation angle on the Z axis, in degrees.

The function returns the following values:

  • gfloat: rotation angle.

type EulerOrder

type EulerOrder C.gint

EulerOrder: specify the order of the rotations on each axis.

The GRAPHENE_EULER_ORDER_DEFAULT value is special, and is used as an alias for one of the other orders.

const (
	// EulerOrderDefault: rotate in the default order; the default order is one
	// of the following enumeration values.
	EulerOrderDefault EulerOrder = -1
	// EulerOrderXYZ: rotate in the X, Y, and Z order. Deprecated in Graphene
	// 1.10, it's an alias for GRAPHENE_EULER_ORDER_SXYZ.
	EulerOrderXYZ EulerOrder = 0
	// EulerOrderYZX: rotate in the Y, Z, and X order. Deprecated in Graphene
	// 1.10, it's an alias for GRAPHENE_EULER_ORDER_SYZX.
	EulerOrderYZX EulerOrder = 1
	// EulerOrderZXY: rotate in the Z, X, and Y order. Deprecated in Graphene
	// 1.10, it's an alias for GRAPHENE_EULER_ORDER_SZXY.
	EulerOrderZXY EulerOrder = 2
	// EulerOrderXZY: rotate in the X, Z, and Y order. Deprecated in Graphene
	// 1.10, it's an alias for GRAPHENE_EULER_ORDER_SXZY.
	EulerOrderXZY EulerOrder = 3
	// EulerOrderYXZ: rotate in the Y, X, and Z order. Deprecated in Graphene
	// 1.10, it's an alias for GRAPHENE_EULER_ORDER_SYXZ.
	EulerOrderYXZ EulerOrder = 4
	// EulerOrderZYX: rotate in the Z, Y, and X order. Deprecated in Graphene
	// 1.10, it's an alias for GRAPHENE_EULER_ORDER_SZYX.
	EulerOrderZYX EulerOrder = 5
	// EulerOrderSXYZ defines a static rotation along the X, Y, and Z axes
	// (Since: 1.10).
	EulerOrderSXYZ EulerOrder = 6
	// EulerOrderSXYX defines a static rotation along the X, Y, and X axes
	// (Since: 1.10).
	EulerOrderSXYX EulerOrder = 7
	// EulerOrderSXZY defines a static rotation along the X, Z, and Y axes
	// (Since: 1.10).
	EulerOrderSXZY EulerOrder = 8
	// EulerOrderSXZX defines a static rotation along the X, Z, and X axes
	// (Since: 1.10).
	EulerOrderSXZX EulerOrder = 9
	// EulerOrderSYZX defines a static rotation along the Y, Z, and X axes
	// (Since: 1.10).
	EulerOrderSYZX EulerOrder = 10
	// EulerOrderSYZY defines a static rotation along the Y, Z, and Y axes
	// (Since: 1.10).
	EulerOrderSYZY EulerOrder = 11
	// EulerOrderSYXZ defines a static rotation along the Y, X, and Z axes
	// (Since: 1.10).
	EulerOrderSYXZ EulerOrder = 12
	// EulerOrderSYXY defines a static rotation along the Y, X, and Y axes
	// (Since: 1.10).
	EulerOrderSYXY EulerOrder = 13
	// EulerOrderSZXY defines a static rotation along the Z, X, and Y axes
	// (Since: 1.10).
	EulerOrderSZXY EulerOrder = 14
	// EulerOrderSZXZ defines a static rotation along the Z, X, and Z axes
	// (Since: 1.10).
	EulerOrderSZXZ EulerOrder = 15
	// EulerOrderSZYX defines a static rotation along the Z, Y, and X axes
	// (Since: 1.10).
	EulerOrderSZYX EulerOrder = 16
	// EulerOrderSZYZ defines a static rotation along the Z, Y, and Z axes
	// (Since: 1.10).
	EulerOrderSZYZ EulerOrder = 17
	// EulerOrderRZYX defines a relative rotation along the Z, Y, and X axes
	// (Since: 1.10).
	EulerOrderRZYX EulerOrder = 18
	// EulerOrderRXYX defines a relative rotation along the X, Y, and X axes
	// (Since: 1.10).
	EulerOrderRXYX EulerOrder = 19
	// EulerOrderRYZX defines a relative rotation along the Y, Z, and X axes
	// (Since: 1.10).
	EulerOrderRYZX EulerOrder = 20
	// EulerOrderRXZX defines a relative rotation along the X, Z, and X axes
	// (Since: 1.10).
	EulerOrderRXZX EulerOrder = 21
	// EulerOrderRXZY defines a relative rotation along the X, Z, and Y axes
	// (Since: 1.10).
	EulerOrderRXZY EulerOrder = 22
	// EulerOrderRYZY defines a relative rotation along the Y, Z, and Y axes
	// (Since: 1.10).
	EulerOrderRYZY EulerOrder = 23
	// EulerOrderRZXY defines a relative rotation along the Z, X, and Y axes
	// (Since: 1.10).
	EulerOrderRZXY EulerOrder = 24
	// EulerOrderRYXY defines a relative rotation along the Y, X, and Y axes
	// (Since: 1.10).
	EulerOrderRYXY EulerOrder = 25
	// EulerOrderRYXZ defines a relative rotation along the Y, X, and Z axes
	// (Since: 1.10).
	EulerOrderRYXZ EulerOrder = 26
	// EulerOrderRZXZ defines a relative rotation along the Z, X, and Z axes
	// (Since: 1.10).
	EulerOrderRZXZ EulerOrder = 27
	// EulerOrderRXYZ defines a relative rotation along the X, Y, and Z axes
	// (Since: 1.10).
	EulerOrderRXYZ EulerOrder = 28
	// EulerOrderRZYZ defines a relative rotation along the Z, Y, and Z axes
	// (Since: 1.10).
	EulerOrderRZYZ EulerOrder = 29
)

func (EulerOrder) String

func (e EulerOrder) String() string

String returns the name in string for EulerOrder.

type Frustum

type Frustum struct {
	// contains filtered or unexported fields
}

Frustum: 3D volume delimited by 2D clip planes.

The contents of the graphene_frustum_t are private, and should not be modified directly.

An instance of this type is always passed by reference.

func NewFrustumAlloc

func NewFrustumAlloc() *Frustum

NewFrustumAlloc constructs a struct Frustum.

func (*Frustum) ContainsPoint

func (f *Frustum) ContainsPoint(point *Point3D) bool

ContainsPoint checks whether a point is inside the volume defined by the given #graphene_frustum_t.

The function takes the following parameters:

  • point: #graphene_point3d_t.

The function returns the following values:

  • ok: true if the point is inside the frustum.

func (*Frustum) Equal

func (a *Frustum) Equal(b *Frustum) bool

Equal checks whether the two given #graphene_frustum_t are equal.

The function takes the following parameters:

  • b: #graphene_frustum_t.

The function returns the following values:

  • ok: true if the given frustums are equal.

func (*Frustum) Init

func (f *Frustum) Init(p0 *Plane, p1 *Plane, p2 *Plane, p3 *Plane, p4 *Plane, p5 *Plane) *Frustum

Init initializes the given #graphene_frustum_t using the provided clipping planes.

The function takes the following parameters:

  • p0: clipping plane.
  • p1: clipping plane.
  • p2: clipping plane.
  • p3: clipping plane.
  • p4: clipping plane.
  • p5: clipping plane.

The function returns the following values:

  • frustum: initialized frustum.

func (*Frustum) InitFromFrustum

func (f *Frustum) InitFromFrustum(src *Frustum) *Frustum

InitFromFrustum initializes the given #graphene_frustum_t using the clipping planes of another #graphene_frustum_t.

The function takes the following parameters:

  • src: #graphene_frustum_t.

The function returns the following values:

  • frustum: initialized frustum.

func (*Frustum) InitFromMatrix

func (f *Frustum) InitFromMatrix(matrix *Matrix) *Frustum

InitFromMatrix initializes a #graphene_frustum_t using the given matrix.

The function takes the following parameters:

  • matrix: #graphene_matrix_t.

The function returns the following values:

  • frustum: initialized frustum.

func (*Frustum) IntersectsBox

func (f *Frustum) IntersectsBox(box *Box) bool

IntersectsBox checks whether the given box intersects a plane of a #graphene_frustum_t.

The function takes the following parameters:

  • box: #graphene_box_t.

The function returns the following values:

  • ok: true if the box intersects the frustum.

func (*Frustum) IntersectsSphere

func (f *Frustum) IntersectsSphere(sphere *Sphere) bool

IntersectsSphere checks whether the given sphere intersects a plane of a #graphene_frustum_t.

The function takes the following parameters:

  • sphere: #graphene_sphere_t.

The function returns the following values:

  • ok: true if the sphere intersects the frustum.

func (*Frustum) Planes

func (f *Frustum) Planes() [6]Plane

Planes retrieves the planes that define the given #graphene_frustum_t.

The function returns the following values:

  • planes: return location for an array of 6 #graphene_plane_t.

type Matrix

type Matrix struct {
	// contains filtered or unexported fields
}

Matrix: structure capable of holding a 4x4 matrix.

The contents of the #graphene_matrix_t structure are private and should never be accessed directly.

An instance of this type is always passed by reference.

func NewMatrixAlloc

func NewMatrixAlloc() *Matrix

NewMatrixAlloc constructs a struct Matrix.

func (*Matrix) Decompose

func (m *Matrix) Decompose() (translate *Vec3, scale *Vec3, rotate *Quaternion, shear *Vec3, perspective *Vec4, ok bool)

Decompose decomposes a transformation matrix into its component transformations.

The algorithm for decomposing a matrix is taken from the CSS3 Transforms specification (http://dev.w3.org/csswg/css-transforms/); specifically, the decomposition code is based on the equivalent code published in "Graphics Gems II", edited by Jim Arvo, and available online (http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c).

The function returns the following values:

  • translate: translation vector.
  • scale vector.
  • rotate: rotation quaternion.
  • shear vector.
  • perspective vector.
  • ok: true if the matrix could be decomposed.

func (*Matrix) Determinant

func (m *Matrix) Determinant() float32

Determinant computes the determinant of the given matrix.

The function returns the following values:

  • gfloat: value of the determinant.

func (*Matrix) Equal

func (a *Matrix) Equal(b *Matrix) bool

Equal checks whether the two given #graphene_matrix_t matrices are equal.

The function takes the following parameters:

  • b: #graphene_matrix_t.

The function returns the following values:

  • ok: true if the two matrices are equal, and false otherwise.

func (*Matrix) EqualFast

func (a *Matrix) EqualFast(b *Matrix) bool

EqualFast checks whether the two given #graphene_matrix_t matrices are byte-by-byte equal.

While this function is faster than graphene_matrix_equal(), it can also return false negatives, so it should be used in conjuction with either graphene_matrix_equal() or graphene_matrix_near(). For instance:

if (graphene_matrix_equal_fast (a, b))
  {
    // matrices are definitely the same
  }
else
  {
    if (graphene_matrix_equal (a, b))
      // matrices contain the same values within an epsilon of FLT_EPSILON
    else if (graphene_matrix_near (a, b, 0.0001))
      // matrices contain the same values within an epsilon of 0.0001
    else
      // matrices are not equal
  }.

The function takes the following parameters:

  • b: #graphene_matrix_t.

The function returns the following values:

  • ok: true if the matrices are equal. and false otherwise.

func (*Matrix) InitFrom2D

func (m *Matrix) InitFrom2D(xx float64, yx float64, xy float64, yy float64, x0 float64, y0 float64) *Matrix

InitFrom2D initializes a #graphene_matrix_t from the values of an affine transformation matrix.

The arguments map to the following matrix layout:

⎛ xx  yx ⎞   ⎛  a   b  0 ⎞
⎜ xy  yy ⎟ = ⎜  c   d  0 ⎟
⎝ x0  y0 ⎠   ⎝ tx  ty  1 ⎠

This function can be used to convert between an affine matrix type from other libraries and a #graphene_matrix_t.

The function takes the following parameters:

  • xx member.
  • yx member.
  • xy member.
  • yy member.
  • x0 member.
  • y0 member.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitFromFloat

func (m *Matrix) InitFromFloat(v [16]float32) *Matrix

InitFromFloat initializes a #graphene_matrix_t with the given array of floating point values.

The function takes the following parameters:

  • v: array of at least 16 floating point values.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitFromMatrix

func (m *Matrix) InitFromMatrix(src *Matrix) *Matrix

InitFromMatrix initializes a #graphene_matrix_t using the values of the given matrix.

The function takes the following parameters:

  • src: #graphene_matrix_t.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitFromVec4

func (m *Matrix) InitFromVec4(v0 *Vec4, v1 *Vec4, v2 *Vec4, v3 *Vec4) *Matrix

InitFromVec4 initializes a #graphene_matrix_t with the given four row vectors.

The function takes the following parameters:

  • v0: first row vector.
  • v1: second row vector.
  • v2: third row vector.
  • v3: fourth row vector.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitFrustum

func (m *Matrix) InitFrustum(left float32, right float32, bottom float32, top float32, zNear float32, zFar float32) *Matrix

InitFrustum initializes a #graphene_matrix_t compatible with #graphene_frustum_t.

See also: graphene_frustum_init_from_matrix().

The function takes the following parameters:

  • left: distance of the left clipping plane.
  • right: distance of the right clipping plane.
  • bottom: distance of the bottom clipping plane.
  • top: distance of the top clipping plane.
  • zNear: distance of the near clipping plane.
  • zFar: distance of the far clipping plane.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitIdentity

func (m *Matrix) InitIdentity() *Matrix

InitIdentity initializes a #graphene_matrix_t with the identity matrix.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitLookAt

func (m *Matrix) InitLookAt(eye *Vec3, center *Vec3, up *Vec3) *Matrix

InitLookAt initializes a #graphene_matrix_t so that it positions the "camera" at the given eye coordinates towards an object at the center coordinates. The top of the camera is aligned to the direction of the up vector.

Before the transform, the camera is assumed to be placed at the origin, looking towards the negative Z axis, with the top side of the camera facing in the direction of the Y axis and the right side in the direction of the X axis.

In theory, one could use m to transform a model of such a camera into world-space. However, it is more common to use the inverse of m to transform another object from world coordinates to the view coordinates of the camera. Typically you would then apply the camera projection transform to get from view to screen coordinates.

The function takes the following parameters:

  • eye: vector describing the position to look from.
  • center: vector describing the position to look at.
  • up: vector describing the world's upward direction; usually, this is the graphene_vec3_y_axis() vector.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitOrtho

func (m *Matrix) InitOrtho(left float32, right float32, top float32, bottom float32, zNear float32, zFar float32) *Matrix

InitOrtho initializes a #graphene_matrix_t with an orthographic projection.

The function takes the following parameters:

  • left edge of the clipping plane.
  • right edge of the clipping plane.
  • top edge of the clipping plane.
  • bottom edge of the clipping plane.
  • zNear: distance of the near clipping plane.
  • zFar: distance of the far clipping plane.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitPerspective

func (m *Matrix) InitPerspective(fovy float32, aspect float32, zNear float32, zFar float32) *Matrix

InitPerspective initializes a #graphene_matrix_t with a perspective projection.

The function takes the following parameters:

  • fovy: field of view angle, in degrees.
  • aspect value.
  • zNear: near Z plane.
  • zFar: far Z plane.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitRotate

func (m *Matrix) InitRotate(angle float32, axis *Vec3) *Matrix

InitRotate initializes m to represent a rotation of angle degrees on the axis represented by the axis vector.

The function takes the following parameters:

  • angle: rotation angle, in degrees.
  • axis vector as a #graphene_vec3_t.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitScale

func (m *Matrix) InitScale(x float32, y float32, z float32) *Matrix

InitScale initializes a #graphene_matrix_t with the given scaling factors.

The function takes the following parameters:

  • x: scale factor on the X axis.
  • y: scale factor on the Y axis.
  • z: scale factor on the Z axis.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitSkew

func (m *Matrix) InitSkew(xSkew float32, ySkew float32) *Matrix

InitSkew initializes a #graphene_matrix_t with a skew transformation with the given factors.

The function takes the following parameters:

  • xSkew: skew factor, in radians, on the X axis.
  • ySkew: skew factor, in radians, on the Y axis.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) InitTranslate

func (m *Matrix) InitTranslate(p *Point3D) *Matrix

InitTranslate initializes a #graphene_matrix_t with a translation to the given coordinates.

The function takes the following parameters:

  • p: translation coordinates.

The function returns the following values:

  • matrix: initialized matrix.

func (*Matrix) Interpolate

func (a *Matrix) Interpolate(b *Matrix, factor float64) *Matrix

Interpolate: linearly interpolates the two given #graphene_matrix_t by interpolating the decomposed transformations separately.

If either matrix cannot be reduced to their transformations then the interpolation cannot be performed, and this function will return an identity matrix.

The function takes the following parameters:

  • b: #graphene_matrix_t.
  • factor: linear interpolation factor.

The function returns the following values:

  • res: return location for the interpolated matrix.

func (*Matrix) Inverse

func (m *Matrix) Inverse() (*Matrix, bool)

Inverse inverts the given matrix.

The function returns the following values:

  • res: return location for the inverse matrix.
  • ok: true if the matrix is invertible.

func (*Matrix) Is2D

func (m *Matrix) Is2D() bool

Is2D checks whether the given #graphene_matrix_t is compatible with an a 2D affine transformation matrix.

The function returns the following values:

  • ok: true if the matrix is compatible with an affine transformation matrix.

func (*Matrix) IsBackfaceVisible

func (m *Matrix) IsBackfaceVisible() bool

IsBackfaceVisible checks whether a #graphene_matrix_t has a visible back face.

The function returns the following values:

  • ok: true if the back face of the matrix is visible.

func (*Matrix) IsIdentity

func (m *Matrix) IsIdentity() bool

IsIdentity checks whether the given #graphene_matrix_t is the identity matrix.

The function returns the following values:

  • ok: true if the matrix is the identity matrix.

func (*Matrix) IsSingular

func (m *Matrix) IsSingular() bool

IsSingular checks whether a matrix is singular.

The function returns the following values:

  • ok: true if the matrix is singular.

func (*Matrix) Multiply

func (a *Matrix) Multiply(b *Matrix) *Matrix

Multiply multiplies two #graphene_matrix_t.

Matrix multiplication is not commutative in general; the order of the factors matters. The product of this multiplication is (a × b).

The function takes the following parameters:

  • b: #graphene_matrix_t.

The function returns the following values:

  • res: return location for the matrix result.

func (*Matrix) Near

func (a *Matrix) Near(b *Matrix, epsilon float32) bool

Near compares the two given #graphene_matrix_t matrices and checks whether their values are within the given epsilon of each other.

The function takes the following parameters:

  • b: #graphene_matrix_t.
  • epsilon: threshold between the two matrices.

The function returns the following values:

  • ok: true if the two matrices are near each other, and false otherwise.

func (*Matrix) Normalize

func (m *Matrix) Normalize() *Matrix

Normalize normalizes the given #graphene_matrix_t.

The function returns the following values:

  • res: return location for the normalized matrix.

func (*Matrix) Perspective

func (m *Matrix) Perspective(depth float32) *Matrix

Perspective applies a perspective of depth to the matrix.

The function takes the following parameters:

  • depth of the perspective.

The function returns the following values:

  • res: return location for the perspective matrix.

func (*Matrix) Print

func (m *Matrix) Print()

Print prints the contents of a matrix to the standard error stream.

This function is only useful for debugging; there are no guarantees made on the format of the output.

func (*Matrix) ProjectPoint

func (m *Matrix) ProjectPoint(p *Point) *Point

ProjectPoint projects a #graphene_point_t using the matrix m.

The function takes the following parameters:

  • p: #graphene_point_t.

The function returns the following values:

  • res: return location for the projected point.

func (*Matrix) ProjectRect

func (m *Matrix) ProjectRect(r *Rect) *Quad

ProjectRect projects all corners of a #graphene_rect_t using the given matrix.

See also: graphene_matrix_project_point().

The function takes the following parameters:

  • r: #graphene_rect_t.

The function returns the following values:

  • res: return location for the projected rectangle.

func (*Matrix) ProjectRectBounds

func (m *Matrix) ProjectRectBounds(r *Rect) *Rect

ProjectRectBounds projects a #graphene_rect_t using the given matrix.

The resulting rectangle is the axis aligned bounding rectangle capable of fully containing the projected rectangle.

The function takes the following parameters:

  • r: #graphene_rect_t.

The function returns the following values:

  • res: return location for the projected rectangle.

func (*Matrix) Rotate

func (m *Matrix) Rotate(angle float32, axis *Vec3)

Rotate adds a rotation transformation to m, using the given angle and axis vector.

This is the equivalent of calling graphene_matrix_init_rotate() and then multiplying the matrix m with the rotation matrix.

The function takes the following parameters:

  • angle: rotation angle, in degrees.
  • axis: rotation axis, as a #graphene_vec3_t.

func (*Matrix) RotateEuler

func (m *Matrix) RotateEuler(e *Euler)

RotateEuler adds a rotation transformation to m, using the given #graphene_euler_t.

The function takes the following parameters:

  • e: rotation described by a #graphene_euler_t.

func (*Matrix) RotateQuaternion

func (m *Matrix) RotateQuaternion(q *Quaternion)

RotateQuaternion adds a rotation transformation to m, using the given #graphene_quaternion_t.

This is the equivalent of calling graphene_quaternion_to_matrix() and then multiplying m with the rotation matrix.

The function takes the following parameters:

  • q: rotation described by a #graphene_quaternion_t.

func (*Matrix) RotateX

func (m *Matrix) RotateX(angle float32)

RotateX adds a rotation transformation around the X axis to m, using the given angle.

See also: graphene_matrix_rotate().

The function takes the following parameters:

  • angle: rotation angle, in degrees.

func (*Matrix) RotateY

func (m *Matrix) RotateY(angle float32)

RotateY adds a rotation transformation around the Y axis to m, using the given angle.

See also: graphene_matrix_rotate().

The function takes the following parameters:

  • angle: rotation angle, in degrees.

func (*Matrix) RotateZ

func (m *Matrix) RotateZ(angle float32)

RotateZ adds a rotation transformation around the Z axis to m, using the given angle.

See also: graphene_matrix_rotate().

The function takes the following parameters:

  • angle: rotation angle, in degrees.

func (*Matrix) Row

func (m *Matrix) Row(index_ uint) *Vec4

Row retrieves the given row vector at index_ inside a matrix.

The function takes the following parameters:

  • index_: index of the row vector, between 0 and 3.

The function returns the following values:

  • res: return location for the #graphene_vec4_t that is used to store the row vector.

func (*Matrix) Scale

func (m *Matrix) Scale(factorX float32, factorY float32, factorZ float32)

Scale adds a scaling transformation to m, using the three given factors.

This is the equivalent of calling graphene_matrix_init_scale() and then multiplying the matrix m with the scale matrix.

The function takes the following parameters:

  • factorX: scaling factor on the X axis.
  • factorY: scaling factor on the Y axis.
  • factorZ: scaling factor on the Z axis.

func (*Matrix) SkewXY

func (m *Matrix) SkewXY(factor float32)

SkewXY adds a skew of factor on the X and Y axis to the given matrix.

The function takes the following parameters:

  • factor: skew factor.

func (*Matrix) SkewXZ

func (m *Matrix) SkewXZ(factor float32)

SkewXZ adds a skew of factor on the X and Z axis to the given matrix.

The function takes the following parameters:

  • factor: skew factor.

func (*Matrix) SkewYZ

func (m *Matrix) SkewYZ(factor float32)

SkewYZ adds a skew of factor on the Y and Z axis to the given matrix.

The function takes the following parameters:

  • factor: skew factor.

func (*Matrix) To2D

func (m *Matrix) To2D() (xx float64, yx float64, xy float64, yy float64, x0 float64, y0 float64, ok bool)

To2D converts a #graphene_matrix_t to an affine transformation matrix, if the given matrix is compatible.

The returned values have the following layout:

⎛ xx  yx ⎞   ⎛  a   b  0 ⎞
⎜ xy  yy ⎟ = ⎜  c   d  0 ⎟
⎝ x0  y0 ⎠   ⎝ tx  ty  1 ⎠

This function can be used to convert between a #graphene_matrix_t and an affine matrix type from other libraries.

The function returns the following values:

  • xx: return location for the xx member.
  • yx: return location for the yx member.
  • xy: return location for the xy member.
  • yy: return location for the yy member.
  • x0: return location for the x0 member.
  • y0: return location for the y0 member.
  • ok: true if the matrix is compatible with an affine transformation matrix.

func (*Matrix) ToFloat

func (m *Matrix) ToFloat() [16]float32

ToFloat converts a #graphene_matrix_t to an array of floating point values.

The function returns the following values:

  • v: return location for an array of floating point values. The array must be capable of holding at least 16 values.

func (*Matrix) TransformBounds

func (m *Matrix) TransformBounds(r *Rect) *Rect

TransformBounds transforms each corner of a #graphene_rect_t using the given matrix m.

The result is the axis aligned bounding rectangle containing the coplanar quadrilateral.

See also: graphene_matrix_transform_point().

The function takes the following parameters:

  • r: #graphene_rect_t.

The function returns the following values:

  • res: return location for the bounds of the transformed rectangle.

func (*Matrix) TransformBox

func (m *Matrix) TransformBox(b *Box) *Box

TransformBox transforms the vertices of a #graphene_box_t using the given matrix m.

The result is the axis aligned bounding box containing the transformed vertices.

The function takes the following parameters:

  • b: #graphene_box_t.

The function returns the following values:

  • res: return location for the bounds of the transformed box.

func (*Matrix) TransformPoint

func (m *Matrix) TransformPoint(p *Point) *Point

TransformPoint transforms the given #graphene_point_t using the matrix m.

Unlike graphene_matrix_transform_vec3(), this function will take into account the fourth row vector of the #graphene_matrix_t when computing the dot product of each row vector of the matrix.

See also: graphene_simd4x4f_point3_mul().

The function takes the following parameters:

  • p: #graphene_point_t.

The function returns the following values:

  • res: return location for the transformed #graphene_point_t.

func (*Matrix) TransformPoint3D

func (m *Matrix) TransformPoint3D(p *Point3D) *Point3D

TransformPoint3D transforms the given #graphene_point3d_t using the matrix m.

Unlike graphene_matrix_transform_vec3(), this function will take into account the fourth row vector of the #graphene_matrix_t when computing the dot product of each row vector of the matrix.

See also: graphene_simd4x4f_point3_mul().

The function takes the following parameters:

  • p: #graphene_point3d_t.

The function returns the following values:

  • res: return location for the result.

func (*Matrix) TransformRay

func (m *Matrix) TransformRay(r *Ray) *Ray

TransformRay: transform a #graphene_ray_t using the given matrix m.

The function takes the following parameters:

  • r: #graphene_ray_t.

The function returns the following values:

  • res: return location for the transformed ray.

func (*Matrix) TransformRect

func (m *Matrix) TransformRect(r *Rect) *Quad

TransformRect transforms each corner of a #graphene_rect_t using the given matrix m.

The result is a coplanar quadrilateral.

See also: graphene_matrix_transform_point().

The function takes the following parameters:

  • r: #graphene_rect_t.

The function returns the following values:

  • res: return location for the transformed quad.

func (*Matrix) TransformSphere

func (m *Matrix) TransformSphere(s *Sphere) *Sphere

TransformSphere transforms a #graphene_sphere_t using the given matrix m. The result is the bounding sphere containing the transformed sphere.

The function takes the following parameters:

  • s: #graphene_sphere_t.

The function returns the following values:

  • res: return location for the bounds of the transformed sphere.

func (*Matrix) TransformVec3

func (m *Matrix) TransformVec3(v *Vec3) *Vec3

TransformVec3 transforms the given #graphene_vec3_t using the matrix m.

This function will multiply the X, Y, and Z row vectors of the matrix m with the corresponding components of the vector v. The W row vector will be ignored.

See also: graphene_simd4x4f_vec3_mul().

The function takes the following parameters:

  • v: #graphene_vec3_t.

The function returns the following values:

  • res: return location for a #graphene_vec3_t.

func (*Matrix) TransformVec4

func (m *Matrix) TransformVec4(v *Vec4) *Vec4

TransformVec4 transforms the given #graphene_vec4_t using the matrix m.

See also: graphene_simd4x4f_vec4_mul().

The function takes the following parameters:

  • v: #graphene_vec4_t.

The function returns the following values:

  • res: return location for a #graphene_vec4_t.

func (*Matrix) Translate

func (m *Matrix) Translate(pos *Point3D)

Translate adds a translation transformation to m using the coordinates of the given #graphene_point3d_t.

This is the equivalent of calling graphene_matrix_init_translate() and then multiplying m with the translation matrix.

The function takes the following parameters:

  • pos: #graphene_point3d_t.

func (*Matrix) Transpose

func (m *Matrix) Transpose() *Matrix

Transpose transposes the given matrix.

The function returns the following values:

  • res: return location for the transposed matrix.

func (*Matrix) UnprojectPoint3D

func (projection *Matrix) UnprojectPoint3D(modelview *Matrix, point *Point3D) *Point3D

UnprojectPoint3D unprojects the given point using the projection matrix and a modelview matrix.

The function takes the following parameters:

  • modelview for the modelview matrix; this is the inverse of the modelview used when projecting the point.
  • point with the coordinates of the point.

The function returns the following values:

  • res: return location for the unprojected point.

func (*Matrix) UntransformBounds

func (m *Matrix) UntransformBounds(r *Rect, bounds *Rect) *Rect

UntransformBounds undoes the transformation on the corners of a #graphene_rect_t using the given matrix, within the given axis aligned rectangular bounds.

The function takes the following parameters:

  • r: #graphene_rect_t.
  • bounds of the transformation.

The function returns the following values:

  • res: return location for the untransformed rectangle.

func (*Matrix) UntransformPoint

func (m *Matrix) UntransformPoint(p *Point, bounds *Rect) (*Point, bool)

UntransformPoint undoes the transformation of a #graphene_point_t using the given matrix, within the given axis aligned rectangular bounds.

The function takes the following parameters:

  • p: #graphene_point_t.
  • bounds of the transformation.

The function returns the following values:

  • res: return location for the untransformed point.
  • ok: true if the point was successfully untransformed.

func (*Matrix) Value

func (m *Matrix) Value(row uint, col uint) float32

Value retrieves the value at the given row and col index.

The function takes the following parameters:

  • row index.
  • col: column index.

The function returns the following values:

  • gfloat: value at the given indices.

func (*Matrix) XScale

func (m *Matrix) XScale() float32

XScale retrieves the scaling factor on the X axis in m.

The function returns the following values:

  • gfloat: value of the scaling factor.

func (*Matrix) XTranslation

func (m *Matrix) XTranslation() float32

XTranslation retrieves the translation component on the X axis from m.

The function returns the following values:

  • gfloat: translation component.

func (*Matrix) YScale

func (m *Matrix) YScale() float32

YScale retrieves the scaling factor on the Y axis in m.

The function returns the following values:

  • gfloat: value of the scaling factor.

func (*Matrix) YTranslation

func (m *Matrix) YTranslation() float32

YTranslation retrieves the translation component on the Y axis from m.

The function returns the following values:

  • gfloat: translation component.

func (*Matrix) ZScale

func (m *Matrix) ZScale() float32

ZScale retrieves the scaling factor on the Z axis in m.

The function returns the following values:

  • gfloat: value of the scaling factor.

func (*Matrix) ZTranslation

func (m *Matrix) ZTranslation() float32

ZTranslation retrieves the translation component on the Z axis from m.

The function returns the following values:

  • gfloat: translation component.

type Plane

type Plane struct {
	// contains filtered or unexported fields
}

Plane: 2D plane that extends infinitely in a 3D volume.

The contents of the graphene_plane_t are private, and should not be modified directly.

An instance of this type is always passed by reference.

func NewPlaneAlloc

func NewPlaneAlloc() *Plane

NewPlaneAlloc constructs a struct Plane.

func (*Plane) Constant

func (p *Plane) Constant() float32

Constant retrieves the distance along the normal vector of the given #graphene_plane_t from the origin.

The function returns the following values:

  • gfloat: constant value of the plane.

func (*Plane) Distance

func (p *Plane) Distance(point *Point3D) float32

Distance computes the distance of point from a #graphene_plane_t.

The function takes the following parameters:

  • point: #graphene_point3d_t.

The function returns the following values:

  • gfloat: distance of the given #graphene_point3d_t from the plane.

func (*Plane) Equal

func (a *Plane) Equal(b *Plane) bool

Equal checks whether the two given #graphene_plane_t are equal.

The function takes the following parameters:

  • b: #graphene_plane_t.

The function returns the following values:

  • ok: true if the given planes are equal.

func (*Plane) Init

func (p *Plane) Init(normal *Vec3, constant float32) *Plane

Init initializes the given #graphene_plane_t using the given normal vector and constant values.

The function takes the following parameters:

  • normal (optional): unit length normal vector defining the plane pointing towards the origin; if unset, we use the X axis by default.
  • constant: distance from the origin to the plane along the normal vector; the sign determines the half-space occupied by the plane.

The function returns the following values:

  • plane: initialized plane.

func (*Plane) InitFromPlane

func (p *Plane) InitFromPlane(src *Plane) *Plane

InitFromPlane initializes the given #graphene_plane_t using the normal vector and constant of another #graphene_plane_t.

The function takes the following parameters:

  • src: #graphene_plane_t.

The function returns the following values:

  • plane: initialized plane.

func (*Plane) InitFromPoint

func (p *Plane) InitFromPoint(normal *Vec3, point *Point3D) *Plane

InitFromPoint initializes the given #graphene_plane_t using the given normal vector and an arbitrary co-planar point.

The function takes the following parameters:

  • normal vector defining the plane pointing towards the origin.
  • point: #graphene_point3d_t.

The function returns the following values:

  • plane: initialized plane.

func (*Plane) InitFromPoints

func (p *Plane) InitFromPoints(a *Point3D, b *Point3D, c *Point3D) *Plane

InitFromPoints initializes the given #graphene_plane_t using the 3 provided co-planar points.

The winding order is counter-clockwise, and determines which direction the normal vector will point.

The function takes the following parameters:

  • a: #graphene_point3d_t.
  • b: #graphene_point3d_t.
  • c: #graphene_point3d_t.

The function returns the following values:

  • plane: initialized plane.

func (*Plane) InitFromVec4

func (p *Plane) InitFromVec4(src *Vec4) *Plane

InitFromVec4 initializes the given #graphene_plane_t using the components of the given #graphene_vec4_t vector.

The function takes the following parameters:

  • src containing the normal vector in its first three components, and the distance in its fourth component.

The function returns the following values:

  • plane: initialized plane.

func (*Plane) Negate

func (p *Plane) Negate() *Plane

Negate negates the normal vector and constant of a #graphene_plane_t, effectively mirroring the plane across the origin.

The function returns the following values:

  • res: return location for the negated plane.

func (*Plane) Normal

func (p *Plane) Normal() *Vec3

Normal retrieves the normal vector pointing towards the origin of the given #graphene_plane_t.

The function returns the following values:

  • normal: return location for the normal vector.

func (*Plane) Normalize

func (p *Plane) Normalize() *Plane

Normalize normalizes the vector of the given #graphene_plane_t, and adjusts the constant accordingly.

The function returns the following values:

  • res: return location for the normalized plane.

func (*Plane) Transform

func (p *Plane) Transform(matrix *Matrix, normalMatrix *Matrix) *Plane

Transform transforms a #graphene_plane_t p using the given matrix and normal_matrix.

If normal_matrix is NULL, a transformation matrix for the plane normal will be computed from matrix. If you are transforming multiple planes using the same matrix it's recommended to compute the normal matrix beforehand to avoid incurring in the cost of recomputing it every time.

The function takes the following parameters:

  • matrix: #graphene_matrix_t.
  • normalMatrix (optional): #graphene_matrix_t.

The function returns the following values:

  • res: transformed plane.

type Point

type Point struct {
	// contains filtered or unexported fields
}

Point: point with two coordinates.

An instance of this type is always passed by reference.

func NewPointAlloc

func NewPointAlloc() *Point

NewPointAlloc constructs a struct Point.

func PointZero

func PointZero() *Point

PointZero returns a point fixed at (0, 0).

The function returns the following values:

  • point: fixed point.

func (*Point) Distance

func (a *Point) Distance(b *Point) (dX float32, dY float32, gfloat float32)

Distance computes the distance between a and b.

The function takes the following parameters:

  • b: #graphene_point_t.

The function returns the following values:

  • dX (optional): distance component on the X axis.
  • dY (optional): distance component on the Y axis.
  • gfloat: distance between the two points.

func (*Point) Equal

func (a *Point) Equal(b *Point) bool

Equal checks if the two points a and b point to the same coordinates.

This function accounts for floating point fluctuations; if you want to control the fuzziness of the match, you can use graphene_point_near() instead.

The function takes the following parameters:

  • b: #graphene_point_t.

The function returns the following values:

  • ok: true if the points have the same coordinates.

func (*Point) Init

func (p *Point) Init(x float32, y float32) *Point

Init initializes p to the given x and y coordinates.

It's safe to call this function multiple times.

The function takes the following parameters:

  • x: x coordinate.
  • y: y coordinate.

The function returns the following values:

  • point: initialized point.

func (*Point) InitFromPoint

func (p *Point) InitFromPoint(src *Point) *Point

InitFromPoint initializes p with the same coordinates of src.

The function takes the following parameters:

  • src to use.

The function returns the following values:

  • point: initialized point.

func (*Point) InitFromVec2

func (p *Point) InitFromVec2(src *Vec2) *Point

InitFromVec2 initializes p with the coordinates inside the given #graphene_vec2_t.

The function takes the following parameters:

  • src: #graphene_vec2_t.

The function returns the following values:

  • point: initialized point.

func (*Point) Interpolate

func (a *Point) Interpolate(b *Point, factor float64) *Point

Interpolate: linearly interpolates the coordinates of a and b using the given factor.

The function takes the following parameters:

  • b: #graphene_point_t.
  • factor: linear interpolation factor.

The function returns the following values:

  • res: return location for the interpolated point.

func (*Point) Near

func (a *Point) Near(b *Point, epsilon float32) bool

Near checks whether the two points a and b are within the threshold of epsilon.

The function takes the following parameters:

  • b: #graphene_point_t.
  • epsilon: threshold between the two points.

The function returns the following values:

  • ok: true if the distance is within epsilon.

func (*Point) SetX

func (p *Point) SetX(x float32)

X coordinate of the point.

func (*Point) SetY

func (p *Point) SetY(y float32)

Y coordinate of the point.

func (*Point) ToVec2

func (p *Point) ToVec2() *Vec2

ToVec2 stores the coordinates of the given #graphene_point_t into a #graphene_vec2_t.

The function returns the following values:

  • v: return location for the vertex.

func (*Point) X

func (p *Point) X() float32

X coordinate of the point.

func (*Point) Y

func (p *Point) Y() float32

Y coordinate of the point.

type Point3D

type Point3D struct {
	// contains filtered or unexported fields
}

Point3D: point with three components: X, Y, and Z.

An instance of this type is always passed by reference.

func NewPoint3DAlloc

func NewPoint3DAlloc() *Point3D

NewPoint3DAlloc constructs a struct Point3D.

func Point3DZero

func Point3DZero() *Point3D

Point3DZero retrieves a constant point with all three coordinates set to 0.

The function returns the following values:

  • point3D: zero point.

func (*Point3D) Cross

func (a *Point3D) Cross(b *Point3D) *Point3D

Cross computes the cross product of the two given #graphene_point3d_t.

The function takes the following parameters:

  • b: #graphene_point3d_t.

The function returns the following values:

  • res: return location for the cross product.

func (*Point3D) Distance

func (a *Point3D) Distance(b *Point3D) (*Vec3, float32)

Distance computes the distance between the two given #graphene_point3d_t.

The function takes the following parameters:

  • b: #graphene_point3d_t.

The function returns the following values:

  • delta (optional): return location for the distance components on the X, Y, and Z axis.
  • gfloat: distance between two points.

func (*Point3D) Dot

func (a *Point3D) Dot(b *Point3D) float32

Dot computes the dot product of the two given #graphene_point3d_t.

The function takes the following parameters:

  • b: #graphene_point3d_t.

The function returns the following values:

  • gfloat: value of the dot product.

func (*Point3D) Equal

func (a *Point3D) Equal(b *Point3D) bool

Equal checks whether two given points are equal.

The function takes the following parameters:

  • b: #graphene_point3d_t.

The function returns the following values:

  • ok: true if the points are equal.

func (*Point3D) Init

func (p *Point3D) Init(x float32, y float32, z float32) *Point3D

Init initializes a #graphene_point3d_t with the given coordinates.

The function takes the following parameters:

  • x: x coordinate of the point.
  • y: y coordinate of the point.
  • z: z coordinate of the point.

The function returns the following values:

  • point3D: initialized #graphene_point3d_t.

func (*Point3D) InitFromPoint

func (p *Point3D) InitFromPoint(src *Point3D) *Point3D

InitFromPoint initializes a #graphene_point3d_t using the coordinates of another #graphene_point3d_t.

The function takes the following parameters:

  • src: #graphene_point3d_t.

The function returns the following values:

  • point3D: initialized point.

func (*Point3D) InitFromVec3

func (p *Point3D) InitFromVec3(v *Vec3) *Point3D

InitFromVec3 initializes a #graphene_point3d_t using the components of a #graphene_vec3_t.

The function takes the following parameters:

  • v: #graphene_vec3_t.

The function returns the following values:

  • point3D: initialized #graphene_point3d_t.

func (*Point3D) Interpolate

func (a *Point3D) Interpolate(b *Point3D, factor float64) *Point3D

Interpolate: linearly interpolates each component of a and b using the provided factor, and places the result in res.

The function takes the following parameters:

  • b: #graphene_point3d_t.
  • factor: interpolation factor.

The function returns the following values:

  • res: return location for the interpolated #graphene_point3d_t.

func (*Point3D) Length

func (p *Point3D) Length() float32

Length computes the length of the vector represented by the coordinates of the given #graphene_point3d_t.

The function returns the following values:

  • gfloat: length of the vector represented by the point.

func (*Point3D) Near

func (a *Point3D) Near(b *Point3D, epsilon float32) bool

Near checks whether the two points are near each other, within an epsilon factor.

The function takes the following parameters:

  • b: #graphene_point3d_t.
  • epsilon fuzzyness factor.

The function returns the following values:

  • ok: true if the points are near each other.

func (*Point3D) Normalize

func (p *Point3D) Normalize() *Point3D

Normalize computes the normalization of the vector represented by the coordinates of the given #graphene_point3d_t.

The function returns the following values:

  • res: return location for the normalized #graphene_point3d_t.

func (*Point3D) NormalizeViewport

func (p *Point3D) NormalizeViewport(viewport *Rect, zNear float32, zFar float32) *Point3D

NormalizeViewport normalizes the coordinates of a #graphene_point3d_t using the given viewport and clipping planes.

The coordinates of the resulting #graphene_point3d_t will be in the [ -1, 1 ] range.

The function takes the following parameters:

  • viewport representing a viewport.
  • zNear: coordinate of the near clipping plane, or 0 for the default near clipping plane.
  • zFar: coordinate of the far clipping plane, or 1 for the default far clipping plane.

The function returns the following values:

  • res: return location for the normalized #graphene_point3d_t.

func (*Point3D) Scale

func (p *Point3D) Scale(factor float32) *Point3D

Scale scales the coordinates of the given #graphene_point3d_t by the given factor.

The function takes the following parameters:

  • factor: scaling factor.

The function returns the following values:

  • res: return location for the scaled point.

func (*Point3D) SetX

func (p *Point3D) SetX(x float32)

X coordinate.

func (*Point3D) SetY

func (p *Point3D) SetY(y float32)

Y coordinate.

func (*Point3D) SetZ

func (p *Point3D) SetZ(z float32)

Z coordinate.

func (*Point3D) ToVec3

func (p *Point3D) ToVec3() *Vec3

ToVec3 stores the coordinates of a #graphene_point3d_t into a #graphene_vec3_t.

The function returns the following values:

  • v: return location for a #graphene_vec3_t.

func (*Point3D) X

func (p *Point3D) X() float32

X coordinate.

func (*Point3D) Y

func (p *Point3D) Y() float32

Y coordinate.

func (*Point3D) Z

func (p *Point3D) Z() float32

Z coordinate.

type Quad

type Quad struct {
	// contains filtered or unexported fields
}

Quad: 4 vertex quadrilateral, as represented by four #graphene_point_t.

The contents of a #graphene_quad_t are private and should never be accessed directly.

An instance of this type is always passed by reference.

func NewQuadAlloc

func NewQuadAlloc() *Quad

NewQuadAlloc constructs a struct Quad.

func (*Quad) Bounds

func (q *Quad) Bounds() *Rect

Bounds computes the bounding rectangle of q and places it into r.

The function returns the following values:

  • r: return location for a #graphene_rect_t.

func (*Quad) Contains

func (q *Quad) Contains(p *Point) bool

Contains checks if the given #graphene_quad_t contains the given #graphene_point_t.

The function takes the following parameters:

  • p: #graphene_point_t.

The function returns the following values:

  • ok: true if the point is inside the #graphene_quad_t.

func (*Quad) Init

func (q *Quad) Init(p1 *Point, p2 *Point, p3 *Point, p4 *Point) *Quad

Init initializes a #graphene_quad_t with the given points.

The function takes the following parameters:

  • p1: first point of the quadrilateral.
  • p2: second point of the quadrilateral.
  • p3: third point of the quadrilateral.
  • p4: fourth point of the quadrilateral.

The function returns the following values:

  • quad: initialized #graphene_quad_t.

func (*Quad) InitFromPoints

func (q *Quad) InitFromPoints(points [4]Point) *Quad

InitFromPoints initializes a #graphene_quad_t using an array of points.

The function takes the following parameters:

  • points: array of 4 #graphene_point_t.

The function returns the following values:

  • quad: initialized #graphene_quad_t.

func (*Quad) InitFromRect

func (q *Quad) InitFromRect(r *Rect) *Quad

InitFromRect initializes a #graphene_quad_t using the four corners of the given #graphene_rect_t.

The function takes the following parameters:

  • r: #graphene_rect_t.

The function returns the following values:

  • quad: initialized #graphene_quad_t.

func (*Quad) Point

func (q *Quad) Point(index_ uint) *Point

Point retrieves the point of a #graphene_quad_t at the given index.

The function takes the following parameters:

  • index_: index of the point to retrieve.

The function returns the following values:

  • point: #graphene_point_t.

type Quaternion

type Quaternion struct {
	// contains filtered or unexported fields
}

Quaternion: quaternion.

The contents of the #graphene_quaternion_t structure are private and should never be accessed directly.

An instance of this type is always passed by reference.

func NewQuaternionAlloc

func NewQuaternionAlloc() *Quaternion

NewQuaternionAlloc constructs a struct Quaternion.

func (*Quaternion) Add

func (a *Quaternion) Add(b *Quaternion) *Quaternion

Add adds two #graphene_quaternion_t a and b.

The function takes the following parameters:

  • b: #graphene_quaternion_t.

The function returns the following values:

  • res: result of the operation.

func (*Quaternion) Dot

func (a *Quaternion) Dot(b *Quaternion) float32

Dot computes the dot product of two #graphene_quaternion_t.

The function takes the following parameters:

  • b: #graphene_quaternion_t.

The function returns the following values:

  • gfloat: value of the dot products.

func (*Quaternion) Equal

func (a *Quaternion) Equal(b *Quaternion) bool

Equal checks whether the given quaternions are equal.

The function takes the following parameters:

  • b: #graphene_quaternion_t.

The function returns the following values:

  • ok: true if the quaternions are equal.

func (*Quaternion) Init

func (q *Quaternion) Init(x float32, y float32, z float32, w float32) *Quaternion

Init initializes a #graphene_quaternion_t using the given four values.

The function takes the following parameters:

  • x: first component of the quaternion.
  • y: second component of the quaternion.
  • z: third component of the quaternion.
  • w: fourth component of the quaternion.

The function returns the following values:

  • quaternion: initialized quaternion.

func (*Quaternion) InitFromAngleVec3

func (q *Quaternion) InitFromAngleVec3(angle float32, axis *Vec3) *Quaternion

InitFromAngleVec3 initializes a #graphene_quaternion_t using an angle on a specific axis.

The function takes the following parameters:

  • angle: rotation on a given axis, in degrees.
  • axis of rotation, expressed as a vector.

The function returns the following values:

  • quaternion: initialized quaternion.

func (*Quaternion) InitFromAngles

func (q *Quaternion) InitFromAngles(degX float32, degY float32, degZ float32) *Quaternion

InitFromAngles initializes a #graphene_quaternion_t using the values of the Euler angles (http://en.wikipedia.org/wiki/Euler_angles) on each axis.

See also: graphene_quaternion_init_from_euler().

The function takes the following parameters:

  • degX: rotation angle on the X axis (yaw), in degrees.
  • degY: rotation angle on the Y axis (pitch), in degrees.
  • degZ: rotation angle on the Z axis (roll), in degrees.

The function returns the following values:

  • quaternion: initialized quaternion.

func (*Quaternion) InitFromEuler

func (q *Quaternion) InitFromEuler(e *Euler) *Quaternion

InitFromEuler initializes a #graphene_quaternion_t using the given #graphene_euler_t.

The function takes the following parameters:

  • e: #graphene_euler_t.

The function returns the following values:

  • quaternion: initialized #graphene_quaternion_t.

func (*Quaternion) InitFromMatrix

func (q *Quaternion) InitFromMatrix(m *Matrix) *Quaternion

InitFromMatrix initializes a #graphene_quaternion_t using the rotation components of a transformation matrix.

The function takes the following parameters:

  • m: #graphene_matrix_t.

The function returns the following values:

  • quaternion: initialized quaternion.

func (*Quaternion) InitFromQuaternion

func (q *Quaternion) InitFromQuaternion(src *Quaternion) *Quaternion

InitFromQuaternion initializes a #graphene_quaternion_t with the values from src.

The function takes the following parameters:

  • src: #graphene_quaternion_t.

The function returns the following values:

  • quaternion: initialized quaternion.

func (*Quaternion) InitFromRadians

func (q *Quaternion) InitFromRadians(radX float32, radY float32, radZ float32) *Quaternion

InitFromRadians initializes a #graphene_quaternion_t using the values of the Euler angles (http://en.wikipedia.org/wiki/Euler_angles) on each axis.

See also: graphene_quaternion_init_from_euler().

The function takes the following parameters:

  • radX: rotation angle on the X axis (yaw), in radians.
  • radY: rotation angle on the Y axis (pitch), in radians.
  • radZ: rotation angle on the Z axis (roll), in radians.

The function returns the following values:

  • quaternion: initialized quaternion.

func (*Quaternion) InitFromVec4

func (q *Quaternion) InitFromVec4(src *Vec4) *Quaternion

InitFromVec4 initializes a #graphene_quaternion_t with the values from src.

The function takes the following parameters:

  • src: #graphene_vec4_t.

The function returns the following values:

  • quaternion: initialized quaternion.

func (*Quaternion) InitIdentity

func (q *Quaternion) InitIdentity() *Quaternion

InitIdentity initializes a #graphene_quaternion_t using the identity transformation.

The function returns the following values:

  • quaternion: initialized quaternion.

func (*Quaternion) Invert

func (q *Quaternion) Invert() *Quaternion

Invert inverts a #graphene_quaternion_t, and returns the conjugate quaternion of q.

The function returns the following values:

  • res: return location for the inverted quaternion.

func (*Quaternion) Multiply

func (a *Quaternion) Multiply(b *Quaternion) *Quaternion

Multiply multiplies two #graphene_quaternion_t a and b.

The function takes the following parameters:

  • b: #graphene_quaternion_t.

The function returns the following values:

  • res: result of the operation.

func (*Quaternion) Normalize

func (q *Quaternion) Normalize() *Quaternion

Normalize normalizes a #graphene_quaternion_t.

The function returns the following values:

  • res: return location for the normalized quaternion.

func (*Quaternion) Scale

func (q *Quaternion) Scale(factor float32) *Quaternion

Scale scales all the elements of a #graphene_quaternion_t q using the given scalar factor.

The function takes the following parameters:

  • factor: scaling factor.

The function returns the following values:

  • res: result of the operation.

func (*Quaternion) Slerp

func (a *Quaternion) Slerp(b *Quaternion, factor float32) *Quaternion

Slerp interpolates between the two given quaternions using a spherical linear interpolation, or SLERP (http://en.wikipedia.org/wiki/Slerp), using the given interpolation factor.

The function takes the following parameters:

  • b: #graphene_quaternion_t.
  • factor: linear interpolation factor.

The function returns the following values:

  • res: return location for the interpolated quaternion.

func (*Quaternion) ToAngleVec3

func (q *Quaternion) ToAngleVec3() (float32, *Vec3)

ToAngleVec3 converts a quaternion into an angle, axis pair.

The function returns the following values:

  • angle: return location for the angle, in degrees.
  • axis: return location for the rotation axis.

func (*Quaternion) ToAngles

func (q *Quaternion) ToAngles() (degX float32, degY float32, degZ float32)

ToAngles converts a #graphene_quaternion_t to its corresponding rotations on the Euler angles (http://en.wikipedia.org/wiki/Euler_angles) on each axis.

The function returns the following values:

  • degX (optional): return location for the rotation angle on the X axis (yaw), in degrees.
  • degY (optional): return location for the rotation angle on the Y axis (pitch), in degrees.
  • degZ (optional): return location for the rotation angle on the Z axis (roll), in degrees.

func (*Quaternion) ToMatrix

func (q *Quaternion) ToMatrix() *Matrix

ToMatrix converts a quaternion into a transformation matrix expressing the rotation defined by the #graphene_quaternion_t.

The function returns the following values:

  • m: #graphene_matrix_t.

func (*Quaternion) ToRadians

func (q *Quaternion) ToRadians() (radX float32, radY float32, radZ float32)

ToRadians converts a #graphene_quaternion_t to its corresponding rotations on the Euler angles (http://en.wikipedia.org/wiki/Euler_angles) on each axis.

The function returns the following values:

  • radX (optional): return location for the rotation angle on the X axis (yaw), in radians.
  • radY (optional): return location for the rotation angle on the Y axis (pitch), in radians.
  • radZ (optional): return location for the rotation angle on the Z axis (roll), in radians.

func (*Quaternion) ToVec4

func (q *Quaternion) ToVec4() *Vec4

ToVec4 copies the components of a #graphene_quaternion_t into a #graphene_vec4_t.

The function returns the following values:

  • res: return location for a #graphene_vec4_t.

type Ray

type Ray struct {
	// contains filtered or unexported fields
}

Ray: ray emitted from an origin in a given direction.

The contents of the graphene_ray_t structure are private, and should not be modified directly.

An instance of this type is always passed by reference.

func NewRayAlloc

func NewRayAlloc() *Ray

NewRayAlloc constructs a struct Ray.

func (*Ray) ClosestPointToPoint

func (r *Ray) ClosestPointToPoint(p *Point3D) *Point3D

ClosestPointToPoint computes the point on the given #graphene_ray_t that is closest to the given point p.

The function takes the following parameters:

  • p: #graphene_point3d_t.

The function returns the following values:

  • res: return location for the closest point3d.

func (*Ray) Direction

func (r *Ray) Direction() *Vec3

Direction retrieves the direction of the given #graphene_ray_t.

The function returns the following values:

  • direction: return location for the direction.

func (*Ray) DistanceToPlane

func (r *Ray) DistanceToPlane(p *Plane) float32

DistanceToPlane computes the distance of the origin of the given #graphene_ray_t from the given plane.

If the ray does not intersect the plane, this function returns INFINITY.

The function takes the following parameters:

  • p: #graphene_plane_t.

The function returns the following values:

  • gfloat: distance of the origin of the ray from the plane.

func (*Ray) DistanceToPoint

func (r *Ray) DistanceToPoint(p *Point3D) float32

DistanceToPoint computes the distance of the closest approach between the given #graphene_ray_t r and the point p.

The closest approach to a ray from a point is the distance between the point and the projection of the point on the ray itself.

The function takes the following parameters:

  • p: #graphene_point3d_t.

The function returns the following values:

  • gfloat: distance of the point.

func (*Ray) Equal

func (a *Ray) Equal(b *Ray) bool

Equal checks whether the two given #graphene_ray_t are equal.

The function takes the following parameters:

  • b: #graphene_ray_t.

The function returns the following values:

  • ok: true if the given rays are equal.

func (*Ray) Init

func (r *Ray) Init(origin *Point3D, direction *Vec3) *Ray

Init initializes the given #graphene_ray_t using the given origin and direction values.

The function takes the following parameters:

  • origin (optional) of the ray.
  • direction (optional) vector.

The function returns the following values:

  • ray: initialized ray.

func (*Ray) InitFromRay

func (r *Ray) InitFromRay(src *Ray) *Ray

InitFromRay initializes the given #graphene_ray_t using the origin and direction values of another #graphene_ray_t.

The function takes the following parameters:

  • src: #graphene_ray_t.

The function returns the following values:

  • ray: initialized ray.

func (*Ray) InitFromVec3

func (r *Ray) InitFromVec3(origin *Vec3, direction *Vec3) *Ray

InitFromVec3 initializes the given #graphene_ray_t using the given vectors.

The function takes the following parameters:

  • origin (optional): #graphene_vec3_t.
  • direction (optional): #graphene_vec3_t.

The function returns the following values:

  • ray: initialized ray.

func (*Ray) IntersectBox

func (r *Ray) IntersectBox(b *Box) (float32, RayIntersectionKind)

IntersectBox intersects the given #graphene_ray_t r with the given #graphene_box_t b.

The function takes the following parameters:

  • b: #graphene_box_t.

The function returns the following values:

  • tOut: distance of the point on the ray that intersects the box.
  • rayIntersectionKind: type of intersection.

func (*Ray) IntersectSphere

func (r *Ray) IntersectSphere(s *Sphere) (float32, RayIntersectionKind)

IntersectSphere intersects the given #graphene_ray_t r with the given #graphene_sphere_t s.

The function takes the following parameters:

  • s: #graphene_sphere_t.

The function returns the following values:

  • tOut: distance of the point on the ray that intersects the sphere.
  • rayIntersectionKind: type of intersection.

func (*Ray) IntersectTriangle

func (r *Ray) IntersectTriangle(t *Triangle) (float32, RayIntersectionKind)

IntersectTriangle intersects the given #graphene_ray_t r with the given #graphene_triangle_t t.

The function takes the following parameters:

  • t: #graphene_triangle_t.

The function returns the following values:

  • tOut: distance of the point on the ray that intersects the triangle.
  • rayIntersectionKind: type of intersection.

func (*Ray) IntersectsBox

func (r *Ray) IntersectsBox(b *Box) bool

IntersectsBox checks whether the given #graphene_ray_t r intersects the given #graphene_box_t b.

See also: graphene_ray_intersect_box().

The function takes the following parameters:

  • b: #graphene_box_t.

The function returns the following values:

  • ok: true if the ray intersects the box.

func (*Ray) IntersectsSphere

func (r *Ray) IntersectsSphere(s *Sphere) bool

IntersectsSphere checks if the given #graphene_ray_t r intersects the given #graphene_sphere_t s.

See also: graphene_ray_intersect_sphere().

The function takes the following parameters:

  • s: #graphene_sphere_t.

The function returns the following values:

  • ok: true if the ray intersects the sphere.

func (*Ray) IntersectsTriangle

func (r *Ray) IntersectsTriangle(t *Triangle) bool

IntersectsTriangle checks whether the given #graphene_ray_t r intersects the given #graphene_triangle_t b.

See also: graphene_ray_intersect_triangle().

The function takes the following parameters:

  • t: #graphene_triangle_t.

The function returns the following values:

  • ok: true if the ray intersects the triangle.

func (*Ray) Origin

func (r *Ray) Origin() *Point3D

Origin retrieves the origin of the given #graphene_ray_t.

The function returns the following values:

  • origin: return location for the origin.

func (*Ray) PositionAt

func (r *Ray) PositionAt(t float32) *Point3D

PositionAt retrieves the coordinates of a point at the distance t along the given #graphene_ray_t.

The function takes the following parameters:

  • t: distance along the ray.

The function returns the following values:

  • position: return location for the position.

type RayIntersectionKind

type RayIntersectionKind C.gint

RayIntersectionKind: type of intersection.

const (
	// RayIntersectionKindNone: no intersection.
	RayIntersectionKindNone RayIntersectionKind = iota
	// RayIntersectionKindEnter: ray is entering the intersected object.
	RayIntersectionKindEnter
	// RayIntersectionKindLeave: ray is leaving the intersected object.
	RayIntersectionKindLeave
)

func (RayIntersectionKind) String

func (r RayIntersectionKind) String() string

String returns the name in string for RayIntersectionKind.

type Rect

type Rect struct {
	// contains filtered or unexported fields
}

Rect: location and size of a rectangle region.

The width and height of a #graphene_rect_t can be negative; for instance, a #graphene_rect_t with an origin of [ 0, 0 ] and a size of [ 10, 10 ] is equivalent to a #graphene_rect_t with an origin of [ 10, 10 ] and a size of [ -10, -10 ].

Application code can normalize rectangles using graphene_rect_normalize(); this function will ensure that the width and height of a rectangle are positive values. All functions taking a #graphene_rect_t as an argument will internally operate on a normalized copy; all functions returning a #graphene_rect_t will always return a normalized rectangle.

An instance of this type is always passed by reference.

func RectAlloc

func RectAlloc() *Rect

RectAlloc allocates a new #graphene_rect_t.

The contents of the returned rectangle are undefined.

The function returns the following values:

  • rect: newly allocated rectangle.

func RectZero

func RectZero() *Rect

RectZero returns a degenerate rectangle with origin fixed at (0, 0) and a size of 0, 0.

The function returns the following values:

  • rect: fixed rectangle.

func (*Rect) Area

func (r *Rect) Area() float32

Area: compute the area of given normalized rectangle.

The function returns the following values:

  • gfloat: area of the normalized rectangle.

func (*Rect) BottomLeft

func (r *Rect) BottomLeft() *Point

BottomLeft retrieves the coordinates of the bottom-left corner of the given rectangle.

The function returns the following values:

  • p: return location for a #graphene_point_t.

func (*Rect) BottomRight

func (r *Rect) BottomRight() *Point

BottomRight retrieves the coordinates of the bottom-right corner of the given rectangle.

The function returns the following values:

  • p: return location for a #graphene_point_t.

func (*Rect) Center

func (r *Rect) Center() *Point

Center retrieves the coordinates of the center of the given rectangle.

The function returns the following values:

  • p: return location for a #graphene_point_t.

func (*Rect) ContainsPoint

func (r *Rect) ContainsPoint(p *Point) bool

ContainsPoint checks whether a #graphene_rect_t contains the given coordinates.

The function takes the following parameters:

  • p: #graphene_point_t.

The function returns the following values:

  • ok: true if the rectangle contains the point.

func (*Rect) ContainsRect

func (a *Rect) ContainsRect(b *Rect) bool

ContainsRect checks whether a #graphene_rect_t fully contains the given rectangle.

The function takes the following parameters:

  • b: #graphene_rect_t.

The function returns the following values:

  • ok: true if the rectangle a fully contains b.

func (*Rect) Equal

func (a *Rect) Equal(b *Rect) bool

Equal checks whether the two given rectangle are equal.

The function takes the following parameters:

  • b: #graphene_rect_t.

The function returns the following values:

  • ok: true if the rectangles are equal.

func (*Rect) Expand

func (r *Rect) Expand(p *Point) *Rect

Expand expands a #graphene_rect_t to contain the given #graphene_point_t.

The function takes the following parameters:

  • p: #graphene_point_t.

The function returns the following values:

  • res: return location for the expanded rectangle.

func (*Rect) Height

func (r *Rect) Height() float32

Height retrieves the normalized height of the given rectangle.

The function returns the following values:

  • gfloat: normalized height of the rectangle.

func (*Rect) Init

func (r *Rect) Init(x float32, y float32, width float32, height float32) *Rect

Init initializes the given #graphene_rect_t with the given values.

This function will implicitly normalize the #graphene_rect_t before returning.

The function takes the following parameters:

  • x: x coordinate of the graphene_rect_t.origin.
  • y: y coordinate of the graphene_rect_t.origin.
  • width of the graphene_rect_t.size.
  • height of the graphene_rect_t.size.

The function returns the following values:

  • rect: initialized rectangle.

func (*Rect) InitFromRect

func (r *Rect) InitFromRect(src *Rect) *Rect

InitFromRect initializes r using the given src rectangle.

This function will implicitly normalize the #graphene_rect_t before returning.

The function takes the following parameters:

  • src: #graphene_rect_t.

The function returns the following values:

  • rect: initialized rectangle.

func (*Rect) Inset

func (r *Rect) Inset(dX float32, dY float32) *Rect

Inset changes the given rectangle to be smaller, or larger depending on the given inset parameters.

To create an inset rectangle, use positive d_x or d_y values; to create a larger, encompassing rectangle, use negative d_x or d_y values.

The origin of the rectangle is offset by d_x and d_y, while the size is adjusted by (2 * d_x, 2 * d_y). If d_x and d_y are positive values, the size of the rectangle is decreased; if d_x and d_y are negative values, the size of the rectangle is increased.

If the size of the resulting inset rectangle has a negative width or height then the size will be set to zero.

The function takes the following parameters:

  • dX: horizontal inset.
  • dY: vertical inset.

The function returns the following values:

  • rect: inset rectangle.

func (*Rect) InsetR

func (r *Rect) InsetR(dX float32, dY float32) *Rect

InsetR changes the given rectangle to be smaller, or larger depending on the given inset parameters.

To create an inset rectangle, use positive d_x or d_y values; to create a larger, encompassing rectangle, use negative d_x or d_y values.

The origin of the rectangle is offset by d_x and d_y, while the size is adjusted by (2 * d_x, 2 * d_y). If d_x and d_y are positive values, the size of the rectangle is decreased; if d_x and d_y are negative values, the size of the rectangle is increased.

If the size of the resulting inset rectangle has a negative width or height then the size will be set to zero.

The function takes the following parameters:

  • dX: horizontal inset.
  • dY: vertical inset.

The function returns the following values:

  • res: return location for the inset rectangle.

func (*Rect) Interpolate

func (a *Rect) Interpolate(b *Rect, factor float64) *Rect

Interpolate: linearly interpolates the origin and size of the two given rectangles.

The function takes the following parameters:

  • b: #graphene_rect_t.
  • factor: linear interpolation factor.

The function returns the following values:

  • res: return location for the interpolated rectangle.

func (*Rect) Intersection

func (a *Rect) Intersection(b *Rect) (*Rect, bool)

Intersection computes the intersection of the two given rectangles.

! (rectangle-intersection.png)

The intersection in the image above is the blue outline.

If the two rectangles do not intersect, res will contain a degenerate rectangle with origin in (0, 0) and a size of 0.

The function takes the following parameters:

  • b: #graphene_rect_t.

The function returns the following values:

  • res (optional): return location for a #graphene_rect_t.
  • ok: true if the two rectangles intersect.

func (*Rect) Normalize

func (r *Rect) Normalize() *Rect

Normalize normalizes the passed rectangle.

This function ensures that the size of the rectangle is made of positive values, and that the origin is the top-left corner of the rectangle.

The function returns the following values:

  • rect: normalized rectangle.

func (*Rect) NormalizeR

func (r *Rect) NormalizeR() *Rect

NormalizeR normalizes the passed rectangle.

This function ensures that the size of the rectangle is made of positive values, and that the origin is in the top-left corner of the rectangle.

The function returns the following values:

  • res: return location for the normalized rectangle.

func (*Rect) Offset

func (r *Rect) Offset(dX float32, dY float32) *Rect

Offset offsets the origin by d_x and d_y.

The size of the rectangle is unchanged.

The function takes the following parameters:

  • dX: horizontal offset.
  • dY: vertical offset.

The function returns the following values:

  • rect: offset rectangle.

func (*Rect) OffsetR

func (r *Rect) OffsetR(dX float32, dY float32) *Rect

OffsetR offsets the origin of the given rectangle by d_x and d_y.

The size of the rectangle is left unchanged.

The function takes the following parameters:

  • dX: horizontal offset.
  • dY: vertical offset.

The function returns the following values:

  • res: return location for the offset rectangle.

func (*Rect) Origin

func (r *Rect) Origin() *Point

Origin coordinates of the origin of the rectangle.

func (*Rect) Round deprecated

func (r *Rect) Round() *Rect

Round rounds the origin and size of the given rectangle to their nearest integer values; the rounding is guaranteed to be large enough to have an area bigger or equal to the original rectangle, but might not fully contain its extents. Use graphene_rect_round_extents() in case you need to round to a rectangle that covers fully the original one.

This function is the equivalent of calling floor on the coordinates of the origin, and ceil on the size.

Deprecated: Use graphene_rect_round_extents() instead.

The function returns the following values:

  • res: return location for the rounded rectangle.

func (*Rect) RoundExtents

func (r *Rect) RoundExtents() *Rect

RoundExtents rounds the origin of the given rectangle to its nearest integer value and and recompute the size so that the rectangle is large enough to contain all the conrners of the original rectangle.

This function is the equivalent of calling floor on the coordinates of the origin, and recomputing the size calling ceil on the bottom-right coordinates.

If you want to be sure that the rounded rectangle completely covers the area that was covered by the original rectangle — i.e. you want to cover the area including all its corners — this function will make sure that the size is recomputed taking into account the ceiling of the coordinates of the bottom-right corner. If the difference between the original coordinates and the coordinates of the rounded rectangle is greater than the difference between the original size and and the rounded size, then the move of the origin would not be compensated by a move in the anti-origin, leaving the corners of the original rectangle outside the rounded one.

The function returns the following values:

  • res: return location for the rectangle with rounded extents.

func (*Rect) RoundToPixel deprecated

func (r *Rect) RoundToPixel() *Rect

RoundToPixel rounds the origin and the size of the given rectangle to their nearest integer values; the rounding is guaranteed to be large enough to contain the original rectangle.

Deprecated: Use graphene_rect_round() instead.

The function returns the following values:

  • rect: pixel-aligned rectangle.

func (*Rect) Scale

func (r *Rect) Scale(sH float32, sV float32) *Rect

Scale scales the size and origin of a rectangle horizontaly by s_h, and vertically by s_v. The result res is normalized.

The function takes the following parameters:

  • sH: horizontal scale factor.
  • sV: vertical scale factor.

The function returns the following values:

  • res: return location for the scaled rectangle.

func (*Rect) Size

func (r *Rect) Size() *Size

Size: size of the rectangle.

func (*Rect) TopLeft

func (r *Rect) TopLeft() *Point

TopLeft retrieves the coordinates of the top-left corner of the given rectangle.

The function returns the following values:

  • p: return location for a #graphene_point_t.

func (*Rect) TopRight

func (r *Rect) TopRight() *Point

TopRight retrieves the coordinates of the top-right corner of the given rectangle.

The function returns the following values:

  • p: return location for a #graphene_point_t.

func (*Rect) Union

func (a *Rect) Union(b *Rect) *Rect

Union computes the union of the two given rectangles.

! (rectangle-union.png)

The union in the image above is the blue outline.

The function takes the following parameters:

  • b: #graphene_rect_t.

The function returns the following values:

  • res: return location for a #graphene_rect_t.

func (*Rect) Vertices

func (r *Rect) Vertices() [4]Vec2

Vertices computes the four vertices of a #graphene_rect_t.

The function returns the following values:

  • vertices: return location for an array of 4 #graphene_vec2_t.

func (*Rect) Width

func (r *Rect) Width() float32

Width retrieves the normalized width of the given rectangle.

The function returns the following values:

  • gfloat: normalized width of the rectangle.

func (*Rect) X

func (r *Rect) X() float32

X retrieves the normalized X coordinate of the origin of the given rectangle.

The function returns the following values:

  • gfloat: normalized X coordinate of the rectangle.

func (*Rect) Y

func (r *Rect) Y() float32

Y retrieves the normalized Y coordinate of the origin of the given rectangle.

The function returns the following values:

  • gfloat: normalized Y coordinate of the rectangle.

type SIMD4F

type SIMD4F struct {
	// contains filtered or unexported fields
}

SIMD4F: instance of this type is always passed by reference.

type SIMD4X4F

type SIMD4X4F struct {
	// contains filtered or unexported fields
}

SIMD4X4F: instance of this type is always passed by reference.

type Size

type Size struct {
	// contains filtered or unexported fields
}

Size: size.

An instance of this type is always passed by reference.

func NewSizeAlloc

func NewSizeAlloc() *Size

NewSizeAlloc constructs a struct Size.

func SizeZero

func SizeZero() *Size

SizeZero: constant pointer to a zero #graphene_size_t, useful for equality checks and interpolations.

The function returns the following values:

  • size: constant size.

func (*Size) Equal

func (a *Size) Equal(b *Size) bool

Equal checks whether the two give #graphene_size_t are equal.

The function takes the following parameters:

  • b: #graphene_size_t.

The function returns the following values:

  • ok: true if the sizes are equal.

func (*Size) Height

func (s *Size) Height() float32

Height: height.

func (*Size) Init

func (s *Size) Init(width float32, height float32) *Size

Init initializes a #graphene_size_t using the given width and height.

The function takes the following parameters:

  • width: width.
  • height: height.

The function returns the following values:

  • size: initialized #graphene_size_t.

func (*Size) InitFromSize

func (s *Size) InitFromSize(src *Size) *Size

InitFromSize initializes a #graphene_size_t using the width and height of the given src.

The function takes the following parameters:

  • src: #graphene_size_t.

The function returns the following values:

  • size: initialized #graphene_size_t.

func (*Size) Interpolate

func (a *Size) Interpolate(b *Size, factor float64) *Size

Interpolate: linearly interpolates the two given #graphene_size_t using the given interpolation factor.

The function takes the following parameters:

  • b: #graphene_size_t.
  • factor: linear interpolation factor.

The function returns the following values:

  • res: return location for the interpolated size.

func (*Size) Scale

func (s *Size) Scale(factor float32) *Size

Scale scales the components of a #graphene_size_t using the given factor.

The function takes the following parameters:

  • factor: scaling factor.

The function returns the following values:

  • res: return location for the scaled size.

func (*Size) SetHeight

func (s *Size) SetHeight(height float32)

Height: height.

func (*Size) SetWidth

func (s *Size) SetWidth(width float32)

Width: width.

func (*Size) Width

func (s *Size) Width() float32

Width: width.

type Sphere

type Sphere struct {
	// contains filtered or unexported fields
}

Sphere: sphere, represented by its center and radius.

An instance of this type is always passed by reference.

func NewSphereAlloc

func NewSphereAlloc() *Sphere

NewSphereAlloc constructs a struct Sphere.

func (*Sphere) BoundingBox

func (s *Sphere) BoundingBox() *Box

BoundingBox computes the bounding box capable of containing the given #graphene_sphere_t.

The function returns the following values:

  • box: return location for the bounding box.

func (*Sphere) Center

func (s *Sphere) Center() *Point3D

Center retrieves the coordinates of the center of a #graphene_sphere_t.

The function returns the following values:

  • center: return location for the coordinates of the center.

func (*Sphere) ContainsPoint

func (s *Sphere) ContainsPoint(point *Point3D) bool

ContainsPoint checks whether the given point is contained in the volume of a #graphene_sphere_t.

The function takes the following parameters:

  • point: #graphene_point3d_t.

The function returns the following values:

  • ok: true if the sphere contains the point.

func (*Sphere) Distance

func (s *Sphere) Distance(point *Point3D) float32

Distance computes the distance of the given point from the surface of a #graphene_sphere_t.

The function takes the following parameters:

  • point: #graphene_point3d_t.

The function returns the following values:

  • gfloat: distance of the point.

func (*Sphere) Equal

func (a *Sphere) Equal(b *Sphere) bool

Equal checks whether two #graphene_sphere_t are equal.

The function takes the following parameters:

  • b: #graphene_sphere_t.

The function returns the following values:

  • ok: true if the spheres are equal.

func (*Sphere) Init

func (s *Sphere) Init(center *Point3D, radius float32) *Sphere

Init initializes the given #graphene_sphere_t with the given center and radius.

The function takes the following parameters:

  • center (optional) coordinates of the center of the sphere, or NULL for a center in (0, 0, 0).
  • radius of the sphere.

The function returns the following values:

  • sphere: initialized #graphene_sphere_t.

func (*Sphere) InitFromPoints

func (s *Sphere) InitFromPoints(points []Point3D, center *Point3D) *Sphere

InitFromPoints initializes the given #graphene_sphere_t using the given array of 3D coordinates so that the sphere includes them.

The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all points.

The function takes the following parameters:

  • points: array of #graphene_point3d_t.
  • center (optional) of the sphere.

The function returns the following values:

  • sphere: initialized #graphene_sphere_t.

func (*Sphere) InitFromVectors

func (s *Sphere) InitFromVectors(vectors []Vec3, center *Point3D) *Sphere

InitFromVectors initializes the given #graphene_sphere_t using the given array of 3D coordinates so that the sphere includes them.

The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all vectors.

The function takes the following parameters:

  • vectors: array of #graphene_vec3_t.
  • center (optional) of the sphere.

The function returns the following values:

  • sphere: initialized #graphene_sphere_t.

func (*Sphere) IsEmpty

func (s *Sphere) IsEmpty() bool

IsEmpty checks whether the sphere has a zero radius.

The function returns the following values:

  • ok: true if the sphere is empty.

func (*Sphere) Radius

func (s *Sphere) Radius() float32

Radius retrieves the radius of a #graphene_sphere_t.

The function returns the following values:

func (*Sphere) Translate

func (s *Sphere) Translate(point *Point3D) *Sphere

Translate translates the center of the given #graphene_sphere_t using the point coordinates as the delta of the translation.

The function takes the following parameters:

  • point coordinates of the translation.

The function returns the following values:

  • res: return location for the translated sphere.

type Triangle

type Triangle struct {
	// contains filtered or unexported fields
}

Triangle: triangle.

An instance of this type is always passed by reference.

func NewTriangleAlloc

func NewTriangleAlloc() *Triangle

NewTriangleAlloc constructs a struct Triangle.

func (*Triangle) Area

func (t *Triangle) Area() float32

Area computes the area of the given #graphene_triangle_t.

The function returns the following values:

  • gfloat: area of the triangle.

func (*Triangle) Barycoords

func (t *Triangle) Barycoords(p *Point3D) (*Vec2, bool)

Barycoords 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.

The function takes the following parameters:

  • p (optional): #graphene_point3d_t.

The function returns the following values:

  • res: return location for the vector with the barycentric coordinates.
  • ok: true if the barycentric coordinates are valid.

func (*Triangle) BoundingBox

func (t *Triangle) BoundingBox() *Box

BoundingBox computes the bounding box of the given #graphene_triangle_t.

The function returns the following values:

  • res: return location for the box.

func (*Triangle) ContainsPoint

func (t *Triangle) ContainsPoint(p *Point3D) bool

ContainsPoint checks whether the given triangle t contains the point p.

The function takes the following parameters:

  • p: #graphene_point3d_t.

The function returns the following values:

  • ok: true if the point is inside the triangle.

func (*Triangle) Equal

func (a *Triangle) Equal(b *Triangle) bool

Equal checks whether the two given #graphene_triangle_t are equal.

The function takes the following parameters:

  • b: #graphene_triangle_t.

The function returns the following values:

  • ok: true if the triangles are equal.

func (*Triangle) InitFromFloat

func (t *Triangle) InitFromFloat(a [3]float32, b [3]float32, c [3]float32) *Triangle

InitFromFloat initializes a #graphene_triangle_t using the three given arrays of floating point values, each representing the coordinates of a point in 3D space.

The function takes the following parameters:

  • a: array of 3 floating point values.
  • b: array of 3 floating point values.
  • c: array of 3 floating point values.

The function returns the following values:

  • triangle: initialized #graphene_triangle_t.

func (*Triangle) InitFromPoint3D

func (t *Triangle) InitFromPoint3D(a *Point3D, b *Point3D, c *Point3D) *Triangle

InitFromPoint3D initializes a #graphene_triangle_t using the three given 3D points.

The function takes the following parameters:

  • a (optional): #graphene_point3d_t.
  • b (optional): #graphene_point3d_t.
  • c (optional): #graphene_point3d_t.

The function returns the following values:

  • triangle: initialized #graphene_triangle_t.

func (*Triangle) InitFromVec3

func (t *Triangle) InitFromVec3(a *Vec3, b *Vec3, c *Vec3) *Triangle

InitFromVec3 initializes a #graphene_triangle_t using the three given vectors.

The function takes the following parameters:

  • a (optional): #graphene_vec3_t.
  • b (optional): #graphene_vec3_t.
  • c (optional): #graphene_vec3_t.

The function returns the following values:

  • triangle: initialized #graphene_triangle_t.

func (*Triangle) Midpoint

func (t *Triangle) Midpoint() *Point3D

Midpoint 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.

The function returns the following values:

  • res: return location for the coordinates of the midpoint.

func (*Triangle) Normal

func (t *Triangle) Normal() *Vec3

Normal computes the normal vector of the given #graphene_triangle_t.

The function returns the following values:

  • res: return location for the normal vector.

func (*Triangle) Plane

func (t *Triangle) Plane() *Plane

Plane computes the plane based on the vertices of the given #graphene_triangle_t.

The function returns the following values:

  • res: return location for the plane.

func (*Triangle) Points

func (t *Triangle) Points() (a *Point3D, b *Point3D, c *Point3D)

Points retrieves the three vertices of the given #graphene_triangle_t and returns their coordinates as #graphene_point3d_t.

The function returns the following values:

  • a (optional): return location for the coordinates of the first vertex.
  • b (optional): return location for the coordinates of the second vertex.
  • c (optional): return location for the coordinates of the third vertex.

func (*Triangle) Uv

func (t *Triangle) Uv(p *Point3D, uvA *Vec2, uvB *Vec2, uvC *Vec2) (*Vec2, bool)

Uv 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().

The function takes the following parameters:

  • p (optional): #graphene_point3d_t.
  • uvA: UV coordinates of the first point.
  • uvB: UV coordinates of the second point.
  • uvC: UV coordinates of the third point.

The function returns the following values:

  • res: vector containing the UV coordinates of the given point p.
  • ok: true if the coordinates are valid.

func (*Triangle) Vertices

func (t *Triangle) Vertices() (a *Vec3, b *Vec3, c *Vec3)

Vertices retrieves the three vertices of the given #graphene_triangle_t.

The function returns the following values:

  • a (optional): return location for the first vertex.
  • b (optional): return location for the second vertex.
  • c (optional): return location for the third vertex.

type Vec2

type Vec2 struct {
	// contains filtered or unexported fields
}

Vec2: structure capable of holding a vector with two dimensions, x and y.

The contents of the #graphene_vec2_t structure are private and should never be accessed directly.

An instance of this type is always passed by reference.

func NewVec2Alloc

func NewVec2Alloc() *Vec2

NewVec2Alloc constructs a struct Vec2.

func Vec2One

func Vec2One() *Vec2

Vec2One retrieves a constant vector with (1, 1) components.

The function returns the following values:

  • vec2: one vector.

func Vec2XAxis

func Vec2XAxis() *Vec2

Vec2XAxis retrieves a constant vector with (1, 0) components.

The function returns the following values:

  • vec2: x axis vector.

func Vec2YAxis

func Vec2YAxis() *Vec2

Vec2YAxis retrieves a constant vector with (0, 1) components.

The function returns the following values:

  • vec2: y axis vector.

func Vec2Zero

func Vec2Zero() *Vec2

Vec2Zero retrieves a constant vector with (0, 0) components.

The function returns the following values:

  • vec2: zero vector.

func (*Vec2) Add

func (a *Vec2) Add(b *Vec2) *Vec2

Add adds each component of the two passed vectors and places each result into the components of res.

The function takes the following parameters:

  • b: #graphene_vec2_t.

The function returns the following values:

  • res: return location for the result.

func (*Vec2) Divide

func (a *Vec2) Divide(b *Vec2) *Vec2

Divide divides each component of the first operand a by the corresponding component of the second operand b, and places the results into the vector res.

The function takes the following parameters:

  • b: #graphene_vec2_t.

The function returns the following values:

  • res: return location for the result.

func (*Vec2) Dot

func (a *Vec2) Dot(b *Vec2) float32

Dot computes the dot product of the two given vectors.

The function takes the following parameters:

  • b: #graphene_vec2_t.

The function returns the following values:

  • gfloat: dot product of the vectors.

func (*Vec2) Equal

func (v1 *Vec2) Equal(v2 *Vec2) bool

Equal checks whether the two given #graphene_vec2_t are equal.

The function takes the following parameters:

  • v2: #graphene_vec2_t.

The function returns the following values:

  • ok: true if the two vectors are equal, and false otherwise.

func (*Vec2) Init

func (v *Vec2) Init(x float32, y float32) *Vec2

Init initializes a #graphene_vec2_t using the given values.

This function can be called multiple times.

The function takes the following parameters:

  • x: x field of the vector.
  • y: y field of the vector.

The function returns the following values:

  • vec2: initialized vector.

func (*Vec2) InitFromFloat

func (v *Vec2) InitFromFloat(src [2]float32) *Vec2

InitFromFloat initializes v with the contents of the given array.

The function takes the following parameters:

  • src: array of floating point values with at least two elements.

The function returns the following values:

  • vec2: initialized vector.

func (*Vec2) InitFromVec2

func (v *Vec2) InitFromVec2(src *Vec2) *Vec2

InitFromVec2 copies the contents of src into v.

The function takes the following parameters:

  • src: #graphene_vec2_t.

The function returns the following values:

  • vec2: initialized vector.

func (*Vec2) Interpolate

func (v1 *Vec2) Interpolate(v2 *Vec2, factor float64) *Vec2

Interpolate: linearly interpolates v1 and v2 using the given factor.

The function takes the following parameters:

  • v2: #graphene_vec2_t.
  • factor: interpolation factor.

The function returns the following values:

  • res: interpolated vector.

func (*Vec2) Length

func (v *Vec2) Length() float32

Length computes the length of the given vector.

The function returns the following values:

  • gfloat: length of the vector.

func (*Vec2) Max

func (a *Vec2) Max(b *Vec2) *Vec2

Max compares the two given vectors and places the maximum values of each component into res.

The function takes the following parameters:

  • b: #graphene_vec2_t.

The function returns the following values:

  • res: resulting vector.

func (*Vec2) Min

func (a *Vec2) Min(b *Vec2) *Vec2

Min compares the two given vectors and places the minimum values of each component into res.

The function takes the following parameters:

  • b: #graphene_vec2_t.

The function returns the following values:

  • res: resulting vector.

func (*Vec2) Multiply

func (a *Vec2) Multiply(b *Vec2) *Vec2

Multiply multiplies each component of the two passed vectors and places each result into the components of res.

The function takes the following parameters:

  • b: #graphene_vec2_t.

The function returns the following values:

  • res: return location for the result.

func (*Vec2) Near

func (v1 *Vec2) Near(v2 *Vec2, epsilon float32) bool

Near compares the two given #graphene_vec2_t vectors and checks whether their values are within the given epsilon.

The function takes the following parameters:

  • v2: #graphene_vec2_t.
  • epsilon: threshold between the two vectors.

The function returns the following values:

  • ok: true if the two vectors are near each other.

func (*Vec2) Negate

func (v *Vec2) Negate() *Vec2

Negate negates the given #graphene_vec2_t.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec2) Normalize

func (v *Vec2) Normalize() *Vec2

Normalize computes the normalized vector for the given vector v.

The function returns the following values:

  • res: return location for the normalized vector.

func (*Vec2) Scale

func (v *Vec2) Scale(factor float32) *Vec2

Scale multiplies all components of the given vector with the given scalar factor.

The function takes the following parameters:

  • factor: scalar factor.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec2) Subtract

func (a *Vec2) Subtract(b *Vec2) *Vec2

Subtract subtracts from each component of the first operand a the corresponding component of the second operand b and places each result into the components of res.

The function takes the following parameters:

  • b: #graphene_vec2_t.

The function returns the following values:

  • res: return location for the result.

func (*Vec2) ToFloat

func (v *Vec2) ToFloat() [2]float32

ToFloat stores the components of v into an array.

The function returns the following values:

  • dest: return location for an array of floating point values with at least 2 elements.

func (*Vec2) X

func (v *Vec2) X() float32

X retrieves the X component of the #graphene_vec2_t.

The function returns the following values:

  • gfloat: value of the X component.

func (*Vec2) Y

func (v *Vec2) Y() float32

Y retrieves the Y component of the #graphene_vec2_t.

The function returns the following values:

  • gfloat: value of the Y component.

type Vec3

type Vec3 struct {
	// contains filtered or unexported fields
}

Vec3: structure capable of holding a vector with three dimensions: x, y, and z.

The contents of the #graphene_vec3_t structure are private and should never be accessed directly.

An instance of this type is always passed by reference.

func NewVec3Alloc

func NewVec3Alloc() *Vec3

NewVec3Alloc constructs a struct Vec3.

func Vec3One

func Vec3One() *Vec3

Vec3One provides a constant pointer to a vector with three components, all sets to 1.

The function returns the following values:

  • vec3: constant vector.

func Vec3XAxis

func Vec3XAxis() *Vec3

Vec3XAxis provides a constant pointer to a vector with three components with values set to (1, 0, 0).

The function returns the following values:

  • vec3: constant vector.

func Vec3YAxis

func Vec3YAxis() *Vec3

Vec3YAxis provides a constant pointer to a vector with three components with values set to (0, 1, 0).

The function returns the following values:

  • vec3: constant vector.

func Vec3ZAxis

func Vec3ZAxis() *Vec3

Vec3ZAxis provides a constant pointer to a vector with three components with values set to (0, 0, 1).

The function returns the following values:

  • vec3: constant vector.

func Vec3Zero

func Vec3Zero() *Vec3

Vec3Zero provides a constant pointer to a vector with three components, all sets to 0.

The function returns the following values:

  • vec3: constant vector.

func (*Vec3) Add

func (a *Vec3) Add(b *Vec3) *Vec3

Add adds each component of the two given vectors.

The function takes the following parameters:

  • b: #graphene_vec3_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec3) Cross

func (a *Vec3) Cross(b *Vec3) *Vec3

Cross computes the cross product of the two given vectors.

The function takes the following parameters:

  • b: #graphene_vec3_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec3) Divide

func (a *Vec3) Divide(b *Vec3) *Vec3

Divide divides each component of the first operand a by the corresponding component of the second operand b, and places the results into the vector res.

The function takes the following parameters:

  • b: #graphene_vec3_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec3) Dot

func (a *Vec3) Dot(b *Vec3) float32

Dot computes the dot product of the two given vectors.

The function takes the following parameters:

  • b: #graphene_vec3_t.

The function returns the following values:

  • gfloat: value of the dot product.

func (*Vec3) Equal

func (v1 *Vec3) Equal(v2 *Vec3) bool

Equal checks whether the two given #graphene_vec3_t are equal.

The function takes the following parameters:

  • v2: #graphene_vec3_t.

The function returns the following values:

  • ok: true if the two vectors are equal, and false otherwise.

func (*Vec3) Init

func (v *Vec3) Init(x float32, y float32, z float32) *Vec3

Init initializes a #graphene_vec3_t using the given values.

This function can be called multiple times.

The function takes the following parameters:

  • x: x field of the vector.
  • y: y field of the vector.
  • z: z field of the vector.

The function returns the following values:

  • vec3: pointer to the initialized vector.

func (*Vec3) InitFromFloat

func (v *Vec3) InitFromFloat(src [3]float32) *Vec3

InitFromFloat initializes a #graphene_vec3_t with the values from an array.

The function takes the following parameters:

  • src: array of 3 floating point values.

The function returns the following values:

  • vec3: initialized vector.

func (*Vec3) InitFromVec3

func (v *Vec3) InitFromVec3(src *Vec3) *Vec3

InitFromVec3 initializes a #graphene_vec3_t with the values of another #graphene_vec3_t.

The function takes the following parameters:

  • src: #graphene_vec3_t.

The function returns the following values:

  • vec3: initialized vector.

func (*Vec3) Interpolate

func (v1 *Vec3) Interpolate(v2 *Vec3, factor float64) *Vec3

Interpolate: linearly interpolates v1 and v2 using the given factor.

The function takes the following parameters:

  • v2: #graphene_vec3_t.
  • factor: interpolation factor.

The function returns the following values:

  • res: interpolated vector.

func (*Vec3) Length

func (v *Vec3) Length() float32

Length retrieves the length of the given vector v.

The function returns the following values:

  • gfloat: value of the length of the vector.

func (*Vec3) Max

func (a *Vec3) Max(b *Vec3) *Vec3

Max compares each component of the two given vectors and creates a vector that contains the maximum values.

The function takes the following parameters:

  • b: #graphene_vec3_t.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec3) Min

func (a *Vec3) Min(b *Vec3) *Vec3

Min compares each component of the two given vectors and creates a vector that contains the minimum values.

The function takes the following parameters:

  • b: #graphene_vec3_t.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec3) Multiply

func (a *Vec3) Multiply(b *Vec3) *Vec3

Multiply multiplies each component of the two given vectors.

The function takes the following parameters:

  • b: #graphene_vec3_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec3) Near

func (v1 *Vec3) Near(v2 *Vec3, epsilon float32) bool

Near compares the two given #graphene_vec3_t vectors and checks whether their values are within the given epsilon.

The function takes the following parameters:

  • v2: #graphene_vec3_t.
  • epsilon: threshold between the two vectors.

The function returns the following values:

  • ok: true if the two vectors are near each other.

func (*Vec3) Negate

func (v *Vec3) Negate() *Vec3

Negate negates the given #graphene_vec3_t.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec3) Normalize

func (v *Vec3) Normalize() *Vec3

Normalize normalizes the given #graphene_vec3_t.

The function returns the following values:

  • res: return location for the normalized vector.

func (*Vec3) Scale

func (v *Vec3) Scale(factor float32) *Vec3

Scale multiplies all components of the given vector with the given scalar factor.

The function takes the following parameters:

  • factor: scalar factor.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec3) Subtract

func (a *Vec3) Subtract(b *Vec3) *Vec3

Subtract subtracts from each component of the first operand a the corresponding component of the second operand b and places each result into the components of res.

The function takes the following parameters:

  • b: #graphene_vec3_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec3) ToFloat

func (v *Vec3) ToFloat() [3]float32

ToFloat copies the components of a #graphene_vec3_t into the given array.

The function returns the following values:

  • dest: return location for an array of floating point values.

func (*Vec3) X

func (v *Vec3) X() float32

X retrieves the first component of the given vector v.

The function returns the following values:

  • gfloat: value of the first component of the vector.

func (*Vec3) XY

func (v *Vec3) XY() *Vec2

XY creates a #graphene_vec2_t that contains the first and second components of the given #graphene_vec3_t.

The function returns the following values:

  • res: return location for a #graphene_vec2_t.

func (*Vec3) XY0

func (v *Vec3) XY0() *Vec3

XY0 creates a #graphene_vec3_t that contains the first two components of the given #graphene_vec3_t, and the third component set to 0.

The function returns the following values:

  • res: return location for a #graphene_vec3_t.

func (*Vec3) XYZ0

func (v *Vec3) XYZ0() *Vec4

XYZ0 converts a #graphene_vec3_t in a #graphene_vec4_t using 0.0 as the value for the fourth component of the resulting vector.

The function returns the following values:

  • res: return location for the vector.

func (*Vec3) XYZ1

func (v *Vec3) XYZ1() *Vec4

XYZ1 converts a #graphene_vec3_t in a #graphene_vec4_t using 1.0 as the value for the fourth component of the resulting vector.

The function returns the following values:

  • res: return location for the vector.

func (*Vec3) Xyzw

func (v *Vec3) Xyzw(w float32) *Vec4

Xyzw converts a #graphene_vec3_t in a #graphene_vec4_t using w as the value of the fourth component of the resulting vector.

The function takes the following parameters:

  • w: value of the W component.

The function returns the following values:

  • res: return location for the vector.

func (*Vec3) Y

func (v *Vec3) Y() float32

Y retrieves the second component of the given vector v.

The function returns the following values:

  • gfloat: value of the second component of the vector.

func (*Vec3) Z

func (v *Vec3) Z() float32

Z retrieves the third component of the given vector v.

The function returns the following values:

  • gfloat: value of the third component of the vector.

type Vec4

type Vec4 struct {
	// contains filtered or unexported fields
}

Vec4: structure capable of holding a vector with four dimensions: x, y, z, and w.

The contents of the #graphene_vec4_t structure are private and should never be accessed directly.

An instance of this type is always passed by reference.

func NewVec4Alloc

func NewVec4Alloc() *Vec4

NewVec4Alloc constructs a struct Vec4.

func Vec4One

func Vec4One() *Vec4

Vec4One retrieves a pointer to a #graphene_vec4_t with all its components set to 1.

The function returns the following values:

  • vec4: constant vector.

func Vec4WAxis

func Vec4WAxis() *Vec4

Vec4WAxis retrieves a pointer to a #graphene_vec4_t with its components set to (0, 0, 0, 1).

The function returns the following values:

  • vec4: constant vector.

func Vec4XAxis

func Vec4XAxis() *Vec4

Vec4XAxis retrieves a pointer to a #graphene_vec4_t with its components set to (1, 0, 0, 0).

The function returns the following values:

  • vec4: constant vector.

func Vec4YAxis

func Vec4YAxis() *Vec4

Vec4YAxis retrieves a pointer to a #graphene_vec4_t with its components set to (0, 1, 0, 0).

The function returns the following values:

  • vec4: constant vector.

func Vec4ZAxis

func Vec4ZAxis() *Vec4

Vec4ZAxis retrieves a pointer to a #graphene_vec4_t with its components set to (0, 0, 1, 0).

The function returns the following values:

  • vec4: constant vector.

func Vec4Zero

func Vec4Zero() *Vec4

Vec4Zero retrieves a pointer to a #graphene_vec4_t with all its components set to 0.

The function returns the following values:

  • vec4: constant vector.

func (*Vec4) Add

func (a *Vec4) Add(b *Vec4) *Vec4

Add adds each component of the two given vectors.

The function takes the following parameters:

  • b: #graphene_vec4_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec4) Divide

func (a *Vec4) Divide(b *Vec4) *Vec4

Divide divides each component of the first operand a by the corresponding component of the second operand b, and places the results into the vector res.

The function takes the following parameters:

  • b: #graphene_vec4_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec4) Dot

func (a *Vec4) Dot(b *Vec4) float32

Dot computes the dot product of the two given vectors.

The function takes the following parameters:

  • b: #graphene_vec4_t.

The function returns the following values:

  • gfloat: value of the dot product.

func (*Vec4) Equal

func (v1 *Vec4) Equal(v2 *Vec4) bool

Equal checks whether the two given #graphene_vec4_t are equal.

The function takes the following parameters:

  • v2: #graphene_vec4_t.

The function returns the following values:

  • ok: true if the two vectors are equal, and false otherwise.

func (*Vec4) Init

func (v *Vec4) Init(x float32, y float32, z float32, w float32) *Vec4

Init initializes a #graphene_vec4_t using the given values.

This function can be called multiple times.

The function takes the following parameters:

  • x: x field of the vector.
  • y: y field of the vector.
  • z: z field of the vector.
  • w: w field of the vector.

The function returns the following values:

  • vec4: pointer to the initialized vector.

func (*Vec4) InitFromFloat

func (v *Vec4) InitFromFloat(src [4]float32) *Vec4

InitFromFloat initializes a #graphene_vec4_t with the values inside the given array.

The function takes the following parameters:

  • src: array of four floating point values.

The function returns the following values:

  • vec4: initialized vector.

func (*Vec4) InitFromVec2

func (v *Vec4) InitFromVec2(src *Vec2, z float32, w float32) *Vec4

InitFromVec2 initializes a #graphene_vec4_t using the components of a #graphene_vec2_t and the values of z and w.

The function takes the following parameters:

  • src: #graphene_vec2_t.
  • z: value for the third component of v.
  • w: value for the fourth component of v.

The function returns the following values:

  • vec4: initialized vector.

func (*Vec4) InitFromVec3

func (v *Vec4) InitFromVec3(src *Vec3, w float32) *Vec4

InitFromVec3 initializes a #graphene_vec4_t using the components of a #graphene_vec3_t and the value of w.

The function takes the following parameters:

  • src: #graphene_vec3_t.
  • w: value for the fourth component of v.

The function returns the following values:

  • vec4: initialized vector.

func (*Vec4) InitFromVec4

func (v *Vec4) InitFromVec4(src *Vec4) *Vec4

InitFromVec4 initializes a #graphene_vec4_t using the components of another #graphene_vec4_t.

The function takes the following parameters:

  • src: #graphene_vec4_t.

The function returns the following values:

  • vec4: initialized vector.

func (*Vec4) Interpolate

func (v1 *Vec4) Interpolate(v2 *Vec4, factor float64) *Vec4

Interpolate: linearly interpolates v1 and v2 using the given factor.

The function takes the following parameters:

  • v2: #graphene_vec4_t.
  • factor: interpolation factor.

The function returns the following values:

  • res: interpolated vector.

func (*Vec4) Length

func (v *Vec4) Length() float32

Length computes the length of the given #graphene_vec4_t.

The function returns the following values:

  • gfloat: length of the vector.

func (*Vec4) Max

func (a *Vec4) Max(b *Vec4) *Vec4

Max compares each component of the two given vectors and creates a vector that contains the maximum values.

The function takes the following parameters:

  • b: #graphene_vec4_t.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec4) Min

func (a *Vec4) Min(b *Vec4) *Vec4

Min compares each component of the two given vectors and creates a vector that contains the minimum values.

The function takes the following parameters:

  • b: #graphene_vec4_t.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec4) Multiply

func (a *Vec4) Multiply(b *Vec4) *Vec4

Multiply multiplies each component of the two given vectors.

The function takes the following parameters:

  • b: #graphene_vec4_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec4) Near

func (v1 *Vec4) Near(v2 *Vec4, epsilon float32) bool

Near compares the two given #graphene_vec4_t vectors and checks whether their values are within the given epsilon.

The function takes the following parameters:

  • v2: #graphene_vec4_t.
  • epsilon: threshold between the two vectors.

The function returns the following values:

  • ok: true if the two vectors are near each other.

func (*Vec4) Negate

func (v *Vec4) Negate() *Vec4

Negate negates the given #graphene_vec4_t.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec4) Normalize

func (v *Vec4) Normalize() *Vec4

Normalize normalizes the given #graphene_vec4_t.

The function returns the following values:

  • res: return location for the normalized vector.

func (*Vec4) Scale

func (v *Vec4) Scale(factor float32) *Vec4

Scale multiplies all components of the given vector with the given scalar factor.

The function takes the following parameters:

  • factor: scalar factor.

The function returns the following values:

  • res: return location for the result vector.

func (*Vec4) Subtract

func (a *Vec4) Subtract(b *Vec4) *Vec4

Subtract subtracts from each component of the first operand a the corresponding component of the second operand b and places each result into the components of res.

The function takes the following parameters:

  • b: #graphene_vec4_t.

The function returns the following values:

  • res: return location for the resulting vector.

func (*Vec4) ToFloat

func (v *Vec4) ToFloat() [4]float32

ToFloat stores the components of the given #graphene_vec4_t into an array of floating point values.

The function returns the following values:

  • dest: return location for an array of floating point values.

func (*Vec4) W

func (v *Vec4) W() float32

W retrieves the value of the fourth component of the given #graphene_vec4_t.

The function returns the following values:

  • gfloat: value of the fourth component.

func (*Vec4) X

func (v *Vec4) X() float32

X retrieves the value of the first component of the given #graphene_vec4_t.

The function returns the following values:

  • gfloat: value of the first component.

func (*Vec4) XY

func (v *Vec4) XY() *Vec2

XY creates a #graphene_vec2_t that contains the first two components of the given #graphene_vec4_t.

The function returns the following values:

  • res: return location for a #graphene_vec2_t.

func (*Vec4) XYZ

func (v *Vec4) XYZ() *Vec3

XYZ creates a #graphene_vec3_t that contains the first three components of the given #graphene_vec4_t.

The function returns the following values:

  • res: return location for a graphene_vec3_t.

func (*Vec4) Y

func (v *Vec4) Y() float32

Y retrieves the value of the second component of the given #graphene_vec4_t.

The function returns the following values:

  • gfloat: value of the second component.

func (*Vec4) Z

func (v *Vec4) Z() float32

Z retrieves the value of the third component of the given #graphene_vec4_t.

The function returns the following values:

  • gfloat: value of the third component.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL