https://github.com/ungerik/go3d
A performance oriented 2D/3D math package for Go
https://github.com/ungerik/go3d
Last synced: 8 months 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 14 years ago)
- Default Branch: master
- Last Pushed: 2024-05-02T07:39:36.000Z (over 1 year ago)
- Last Synced: 2025-03-24T23:02:18.188Z (8 months ago)
- Language: Go
- Homepage:
- Size: 204 KB
- Stars: 318
- Watchers: 11
- 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)
- awesome-go-plus - go3d - Performance oriented 2D/3D math package for Go.  (Game Development / Search and Analytic Databases)
- my-awesome - ungerik/go3d - 10 star:0.3k fork:0.0k A performance oriented 2D/3D math package for Go (Go)
- awesome-go - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Search and Analytic Databases)
- fucking-awesome-go - :octocat: go3d - A performance oriented 2D/3D math package for Go :star: 106 :fork_and_knife: 12 (Game Development / Advanced Console UIs)
- awesome-go - ungerik/go3d
- awesome-go-cn - go3d
- awesome-go - go3d - | - | - | (Game Development / Advanced Console UIs)
- awesome-go-cn - go3d
- awesome-go - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Search and Analytic Databases)
- awesome-go-extra - go3d - 06-27T13:02:26Z|2022-04-04T20:16:13Z| (Game Development / Advanced Console UIs)
- awesome-go - go3d - 面向Go的面向性能的2D / 3D数学包。 (<span id="游戏开发-game-development">游戏开发 Game Development</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go - go3d - A performance oriented 2D/3D math package for Go - ★ 142 (Game Development)
- awesome-go - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Search and Analytic Databases)
- awesome-go-with-stars - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Search and Analytic Databases)
- awesome-go - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Search and Analytic Databases)
- fucking-awesome-go - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Search and Analytic Databases)
- awesome-Char - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Advanced Console UIs)
- awesome-go-cn - go3d
- awesome-go - go3d - Performance oriented 2D/3D math package for Go. - :arrow_down:0 - :star:112 (Game Development / Advanced Console UIs)
- awesome-go - go3d - Performance oriented 2D/3D math package for Go. (Game Development / Advanced Console UIs)
- awesome-go-cn - go3d
- awesome-go - go3d - Performance oriented 2D/3D math package for Go. (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.UnitX
Note 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.go
cd mat4
go test -bench=BenchmarkMulAddVec4_PassBy*
Documentation: https://pkg.go.dev/github.com/ungerik/go3d