mirror of
https://github.com/bloeys/gglm.git
synced 2025-12-29 13:38:20 +00:00
Inlining checks+update readme
This commit is contained in:
@ -22,7 +22,6 @@ gglm currently has the following:
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
|
||||||
import "github.com/bloeys/gglm/gglm"
|
import "github.com/bloeys/gglm/gglm"
|
||||||
|
|
||||||
|
|
||||||
@ -43,10 +42,15 @@ func main() {
|
|||||||
println(v1.Eq(v2))
|
println(v1.Eq(v2))
|
||||||
v2.Set(1, 2)
|
v2.Set(1, 2)
|
||||||
println(v1.Eq(v2))
|
println(v1.Eq(v2))
|
||||||
|
|
||||||
|
//This performs: v1 += v2
|
||||||
|
//v1 is returned from the function, so we can chain calls that operate on v1
|
||||||
|
newX := v1.Add(v2).X()
|
||||||
|
println("newX:", newX)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
You can check compiler inlining decisions using `go run -gcflags "-m" .`. Some functions look a bit weird compared to similar ones
|
You can check compiler inlining decisions using `go run -gcflags "-m" .`. Some functions look a bit weird compared to similar ones
|
||||||
because we are trying to reduce function complexity so the compiler inlines.
|
because we are trying to reduce function complexity so the compiler inlines.
|
||||||
|
|
||||||
|
|||||||
7
main.go
7
main.go
@ -64,6 +64,9 @@ func main() {
|
|||||||
v2.Set(1, 2)
|
v2.Set(1, 2)
|
||||||
println(v1.Eq(v2))
|
println(v1.Eq(v2))
|
||||||
|
|
||||||
|
v1.AddXY(v2.X(), v2.Y())
|
||||||
|
println(v1.String())
|
||||||
|
|
||||||
println("V1: " + v1.String())
|
println("V1: " + v1.String())
|
||||||
v1.Normalize()
|
v1.Normalize()
|
||||||
println("V1 Normal: " + v1.String())
|
println("V1 Normal: " + v1.String())
|
||||||
@ -97,6 +100,10 @@ func main() {
|
|||||||
|
|
||||||
println(gglm.DotVec4(v5, v6))
|
println(gglm.DotVec4(v5, v6))
|
||||||
|
|
||||||
|
v5.Add(v6)
|
||||||
|
v5.AddXYZW(v6.X(), v6.Y(), v6.Z(), v6.W())
|
||||||
|
println(v6.String())
|
||||||
|
|
||||||
println("V6: " + v6.String())
|
println("V6: " + v6.String())
|
||||||
v6.Normalize()
|
v6.Normalize()
|
||||||
println("V6 Normal: " + v6.String())
|
println("V6 Normal: " + v6.String())
|
||||||
|
|||||||
Reference in New Issue
Block a user