common

package
v0.0.0-...-208d128 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T IT](a T) T

/ Returns the absolute value. / @param[in] a The value. / @return The absolute value of the specified value.

func Area2

func Area2[T IT](a, b, c []T) T

func AssertTrue

func AssertTrue(value bool)

func Between

func Between[T IT](a, b, c []T) bool

Returns T iff (a,b,c) are collinear and point c lies on the closed segement ab.

func CalcAreaOfPolygon2D

func CalcAreaOfPolygon2D(verts []int32, nverts int32) int32

func CircumCircle

func CircumCircle[T float64 | float32](p1, p2, p3, c []T, r *T) bool

func Clamp

func Clamp[T cmp.Ordered](value, minInclusive, maxInclusive T) T

/ Clamps the value to the specified range. / @param[in] value The value to clamp. / @param[in] minInclusive The minimum permitted return value. / @param[in] maxInclusive The maximum permitted return value. / @return The value, clamped to the specified range.

func Collinear

func Collinear[T IT](a, b, c []T) bool

func ComputeTileHash

func ComputeTileHash(x, y, mask int32) int32

func ContourInCone

func ContourInCone(i, n int32, verts, pj []int32) bool

func ContourdistancePtSeg

func ContourdistancePtSeg[T int | int32](x, z, px, pz, qx, qz T) float32

func Diagonal

func Diagonal[T1 IT, T2 int32 | uint8 | int, T3 int32 | uint16 | int](i, j, n T1, verts []T2, indices []T3) bool

Returns T iff (v_i, v_j) is a proper internal diagonal of P.

func DiagonalLoose

func DiagonalLoose[T1 IT, T2 int32 | uint8 | int, T3 int32 | uint16 | int](i, j, n T1, verts []T2, indices []T3) bool

func Diagonalie

func Diagonalie[T1 IT, T2 int32 | uint8 | int, T3 int32 | uint16 | int](i, j, n T1, verts []T2, indices []T3) bool

Returns T iff (v_i, v_j) is a proper internal *or* external diagonal of P, *ignoring edges incident to v_i and v_j*.

func DiagonalieLoose

func DiagonalieLoose[T1 IT, T2 int32 | uint8 | int, T3 int32 | uint16 | int](i, j, n T1, verts []T2, indices []T3) bool

func DistPtTri

func DistPtTri[T float64 | float32](p, a, b, c []T) (res T)

func DistToPoly

func DistToPoly[T float64 | float32](nvert int32, verts []T, p []T) (res T)

func DistToTriMesh

func DistToTriMesh[T float64 | float32](p, verts []T, nverts int32, tris []int32, ntris int32) (res T)

func DistancePtSeg

func DistancePtSeg[T float64 | float32](pt, p, q []T) T

func DistancePtSeg2d

func DistancePtSeg2d[T float64 | float32](pt, p, q []T) T

func DoWhile

func DoWhile(do func() (stop bool), while func() bool)

func DtOverlapBounds

func DtOverlapBounds[T float64 | float32](amin, amax, bmin, bmax []T) bool

/ Determines if two axis-aligned bounding boxes overlap. / @param[in] amin Minimum bounds of box A. [(x, y, z)] / @param[in] amax Maximum bounds of box A. [(x, y, z)] / @param[in] bmin Minimum bounds of box B. [(x, y, z)] / @param[in] bmax Maximum bounds of box B. [(x, y, z)] / @return True if the two AABB's overlap. / @see dtOverlapQuantBounds

func GetDirForOffset

func GetDirForOffset(offsetX, offsetZ int32) int32

/ Gets the direction for the specified offset. One of x and y should be 0. / @param[in] offsetX The x offset. [Limits: -1 <= value <= 1] / @param[in] offsetZ The z offset. [Limits: -1 <= value <= 1] / @return The direction that represents the offset.

func GetDirOffsetX

func GetDirOffsetX(direction int32) int32

/ Gets the standard width (x-axis) offset for the specified direction. / @param[in] direction The direction. [Limits: 0 <= value < 4] / @return The width offset to apply to the current cell position to move in the direction.

func GetDirOffsetY

func GetDirOffsetY(direction int32) int32

TODO (graham): Rename this to rcGetDirOffsetZ / Gets the standard height (z-axis) offset for the specified direction. / @param[in] direction The direction. [Limits: 0 <= value < 4] / @return The height offset to apply to the current cell position to move in the direction.

func GetTFloatMax

func GetTFloatMax[T float64 | float32](v T) T

func GetVert2

func GetVert2[T IT, T1 IIndex](verts []T, index T1) []T

func GetVert3

func GetVert3[T IT, T1 IIndex](verts []T, index T1) []T

func GetVert4

func GetVert4[T IT, T1 IIndex](verts []T, index T1) []T

func GluProject

func GluProject[T1 int32 | int](obj []float64, projection, modelview []float64, view []T1) []float64

func Ilog2

func Ilog2(v uint32) uint32

func InCone

func InCone[T1 IT, T2 int32 | uint8 | int, T3 int32 | uint16 | int](i, j, n T1, verts []T2, indices []T3) bool

Returns true iff the diagonal (i,j) is strictly internal to the polygon P in the neighborhood of the i endpoint.

func InConeLoose

func InConeLoose[T1 IT, T2 int32 | uint8 | int, T3 int32 | uint16 | int](i, j, n T1, verts []T2, indices []T3) bool

func Intersect

func Intersect[T IT](a, b, c, d []T) bool

Returns true iff segments ab and cd intersect, properly or improperly.

func IntersectProp

func IntersectProp[T IT](a, b, c, d []T) bool

Returns true iff ab properly intersects cd: they share a point interior to both segments. The properness of the intersection is ensured by using strict leftness.

func IntersectSegContour

func IntersectSegContour(d0, d1 []int32, i, n int32, verts []int32) bool

func IsFinite

func IsFinite(v float32) bool

func IsTFloat64

func IsTFloat64[T float64 | float32](v T) bool

func Left

func Left[T IT](a, b, c []T) bool

Returns true iff c is strictly to the left of the directed line through a to b.

func LeftOn

func LeftOn[T IT](a, b, c []T) bool

func Next

func Next[T IT](i, n T) T

func NextPow2

func NextPow2(v uint32) uint32

func PointInPoly

func PointInPoly(numVerts int32, verts []float32, point []float32) bool

TODO (graham): This is duplicated in the ConvexVolumeTool in RecastDemo / Checks if a point is contained within a polygon / / @param[in] numVerts Number of vertices in the polygon / @param[in] verts The polygon vertices / @param[in] point The point to check / @returns true if the point lies within the polygon, false otherwise.

func Prev

func Prev[T IT](i, n T) T

Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).

func PushBack

func PushBack(v int32, arr []int32, an *int32)

func PushFront

func PushFront(v int32, arr []int32, an *int32)

func RcCalcBounds

func RcCalcBounds[T float64 | float32](verts []T, numVerts int, minBounds []T, maxBounds []T)

func RcVequal

func RcVequal[T IT](a, b []T) bool

func SliceTToSlice

func SliceTToSlice[T1, T2 IT](v1 []T1) (v2 []T2)

func Sqr

func Sqr[T IT](a T) T

/ Returns the square of the value. / @param[in] a The value. / @return The square of the value.

func Sqrt

func Sqrt(x float64) float64

func TriArea2D

func TriArea2D[T float64 | float32](a, b, c []T) T

/ Derives the signed xz-plane area of the triangle ABC, or the relationship of line AB to point C. / @param[in] a Vertex A. [(x, y, z)] / @param[in] b Vertex B. [(x, y, z)] / @param[in] c Vertex C. [(x, y, z)] / @return The signed xz-plane area of the triangle.

func Triangulate

func Triangulate[T1 int32 | uint8 | int, T2 int32 | uint16 | int](n int32, verts []T1, indices []T2, tris []T2) int32

func Uleft

func Uleft[T IT](a, b, c []T) bool

func UnGluProject

func UnGluProject[T1 int32 | int](obj []float64, projection, modelview []float64, view []T1) ([]float64, error)

func Vadd

func Vadd[T float64 | float32](res []T, v1, v2 []T)

/ Performs a vector addition. (@p v1 + @p v2) / @param[out] dest The result vector. [(x, y, z)] / @param[in] v1 The base vector. [(x, y, z)] / @param[in] v2 The vector to add to @p v1. [(x, y, z)]

func Vcross

func Vcross[T float64 | float32](res []T, v1, v2 []T)

/ Derives the cross product of two vectors. (@p v1 x @p v2) / @param[out] dest The cross product. [(x, y, z)] / @param[in] v1 A Vector [(x, y, z)] / @param[in] v2 A vector [(x, y, z)]

func Vcross2

func Vcross2[T float64 | float32](p1, p2, p3 []T) T

func Vdist

func Vdist[T float64 | float32](v1, v2 []T) T

/ Returns the distance between two points. / @param[in] v1 A point. [(x, y, z)] / @param[in] v2 A point. [(x, y, z)] / @return The distance between the two points.

func Vdist2

func Vdist2[T float64 | float32](p, q []T) T

func Vdist2D

func Vdist2D(v1, v2 []float32) float32

/ Derives the distance between the specified points on the xz-plane. / @param[in] v1 A point. [(x, y, z)] / @param[in] v2 A point. [(x, y, z)] / @return The distance between the point on the xz-plane. / / The vectors are projected onto the xz-plane, so the y-values are ignored.

func Vdist2DSqr

func Vdist2DSqr(v1, v2 []float32) float32

/ Derives the square of the distance between the specified points on the xz-plane. / @param[in] v1 A point. [(x, y, z)] / @param[in] v2 A point. [(x, y, z)] / @return The square of the distance between the point on the xz-plane.

func VdistSq2

func VdistSq2[T float64 | float32](p, q []T) T

func VdistSqr

func VdistSqr[T float64 | float32](v1, v2 []T) float64

/ Returns the square of the distance between two points. / @param[in] v1 A point. [(x, y, z)] / @param[in] v2 A point. [(x, y, z)] / @return The square of the distance between the two points.

func Vdot

func Vdot[T float64 | float32](v1, v2 []T) T

/ Derives the dot product of two vectors. (@p v1 . @p v2) / @param[in] v1 A Vector [(x, y, z)] / @param[in] v2 A vector [(x, y, z)] / @return The dot product.

func Vdot2

func Vdot2[T float64 | float32](a, b []T) T

func Vdot2D

func Vdot2D(u, v []float32) float32

/ Derives the dot product of two vectors on the xz-plane. (@p u . @p v) / @param[in] u A vector [(x, y, z)] / @param[in] v A vector [(x, y, z)] / @return The dot product on the xz-plane. / / The vectors are projected onto the xz-plane, so the y-values are ignored.

func Vequal

func Vequal(p0 []float32, p1 []float32) bool

/ Performs a 'sloppy' colocation check of the specified points. / @param[in] p0 A point. [(x, y, z)] / @param[in] p1 A point. [(x, y, z)] / @return True if the points are considered to be at the same location. / / Basically, this function will return true if the specified points are / close enough to eachother to be considered colocated.

func Visfinite

func Visfinite(v []float32) bool

/ Checks that the specified vector's components are all finite. / @param[in] v A point. [(x, y, z)] / @return True if all of the point's components are finite, i.e. not NaN / or any of the infinities.

func Visfinite2D

func Visfinite2D(v []float32) bool

/ Checks that the specified vector's 2D components are finite. / @param[in] v A point. [(x, y, z)]

func Vlen

func Vlen(v []float32) float32

/ Derives the scalar length of the vector. / @param[in] v The vector. [(x, y, z)] / @return The scalar length of the vector.

func VlenSqr

func VlenSqr(v []float32) float32

/ Derives the square of the scalar length of the vector. (len * len) / @param[in] v The vector. [(x, y, z)] / @return The square of the scalar length of the vector.

func Vlerp

func Vlerp(dest []float32, v1, v2 []float32, t float32) []float32

/ Performs a linear interpolation between two vectors. (@p v1 toward @p v2) / @param[out] dest The result vector. [(x, y, x)] / @param[in] v1 The starting vector. / @param[in] v2 The destination vector. / @param[in] t The interpolation factor. [Limits: 0 <= value <= 1.0]

func Vmad

func Vmad[T float64 | float32](res []T, v1, v2 []T, s T)

/ Performs a scaled vector addition. (@p v1 + (@p v2 * @p s)) / @param[out] dest The result vector. [(x, y, z)] / @param[in] v1 The base vector. [(x, y, z)] / @param[in] v2 The vector to scale and add to @p v1. [(x, y, z)] / @param[in] s The amount to scale @p v2 by before adding to @p v1.

func Vmax

func Vmax[T float64 | float32](mx, v []T)

/ Selects the maximum value of each element from the specified vectors. / @param[in,out] mx A vector. (Will be updated with the result.) [(x, y, z)] / @param[in] v A vector. [(x, y, z)]

func Vmin

func Vmin[T float64 | float32](mn, v []T)

/ Selects the minimum value of each element from the specified vectors. / @param[in,out] mn A vector. (Will be updated with the result.) [(x, y, z)] / @param[in] v A vector. [(x, y, z)]

func Vnormalize

func Vnormalize[T float64 | float32](v []T)

/ Normalizes the vector. / @param[in,out] v The vector to normalize. [(x, y, z)]

func Vperp2D

func Vperp2D(u, v []float32) float32

/ Derives the xz-plane 2D perp product of the two vectors. (uz*vx - ux*vz) / @param[in] u The LHV vector [(x, y, z)] / @param[in] v The RHV vector [(x, y, z)] / @return The perp dot product on the xz-plane. / / The vectors are projected onto the xz-plane, so the y-values are ignored.

func Vscale

func Vscale[T float64 | float32](res []T, v []T, t T)

/ Scales the vector by the specified value. (@p v * @p t) / @param[out] dest The result vector. [(x, y, z)] / @param[in] v The vector to scale. [(x, y, z)] / @param[in] t The scaling factor.

func Vset

func Vset(dest []float32, x, y, z float32)

/ Sets the vector elements to the specified values. / @param[out] dest The result vector. [(x, y, z)] / @param[in] x The x-value of the vector. / @param[in] y The y-value of the vector. / @param[in] z The z-value of the vector.

func Vsub

func Vsub[T float64 | float32](res, v1, v2 []T)

/ Performs a vector subtraction. (@p v1 - @p v2) / @param[out] dest The result vector. [(x, y, z)] / @param[in] v1 The base vector. [(x, y, z)] / @param[in] v2 The vector to subtract from @p v1. [(x, y, z)]

func Xorb

func Xorb(x, y bool) bool

Exclusive or: true iff exactly one argument is true. The arguments are negated to ensure that they are 0/1 values. Then the bitwise Xor operator may apply. (This idea is due to Michael Baldwin.)

Types

type IIndex

type IIndex interface {
	~int | ~int8 | ~int16 | ~int32 | ~uint | ~uint8 | ~uint16 | ~uint32
}

type IT

type IT interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64
}

type Vec2

type Vec2 = mgl32.Vec2

type Vec3

type Vec3 = mgl32.Vec3

type Vec4

type Vec4 = mgl32.Vec4

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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