Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ungerik/go3d
A performance oriented 2D/3D math package for Go
https://github.com/ungerik/go3d
Last synced: 14 days ago
JSON representation
A performance oriented 2D/3D math package for Go
- Host: GitHub
- URL: https://github.com/ungerik/go3d
- Owner: ungerik
- License: mit
- Created: 2011-06-27T13:02:26.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2024-05-02T07:39:36.000Z (7 months ago)
- Last Synced: 2024-10-25T05:22:33.356Z (about 2 months ago)
- Language: Go
- Homepage:
- Size: 204 KB
- Stars: 314
- Watchers: 13
- Forks: 49
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Search and Analytic Databases)
- my-awesome - ungerik/go3d - 05 star:0.3k fork:0.0k A performance oriented 2D/3D math package for Go (Go)
- awesome-go - go3d - A performance oriented 2D/3D math package for Go - ★ 142 (Game Development)
- awesome-go-extra - go3d - 06-27T13:02:26Z|2022-04-04T20:16:13Z| (Game Development / Advanced Console UIs)
README
Package go3d is a performance oriented vector and matrix math package for 2D and 3D graphics.
Every type has its own sub-package and is named T. So vec3.T is the 3D vector type.
For every vector and matrix type there is a String() method and a Parse() function.
Besides methods of T there are also functions in the packages, like vec3.Dot(a, b).Packages under the float64 directory are using float64 values instead of float32.
Matrices are organized as arrays of columns which is also the way OpenGL expects matrices.
DirectX expects "arrays of rows" matrices, use the Transpose() to convert.Methods that don't return a specific value, return a pointer to the struct to allow method call chaining.
Example:
a := vec3.Zero
b := vec3.UnitX
a.Add(&b).Scale(5)Method names in the past tense return a copy of the struct instead of a pointer to it.
Example:
a := vec3.UnitX
b := a.Scaled(5) // a still equals vec3.UnitXNote that the package is designed for performance over usability where necessary.
This is the reason why many arguments are passed by pointer reference instead of by value.
Sticking either to passing and returning everything by value or by pointer
would lead to a nicer API, but it would be slower as demonstrated in mat4/mat4_test.gocd mat4
go test -bench=BenchmarkMulAddVec4_PassBy*Documentation: https://pkg.go.dev/github.com/ungerik/go3d