golang / geo

S2 geometry library in Go
Apache License 2.0
1.69k stars 182 forks source link

Radian == 57.2957795 ? #64

Closed ctessum closed 4 years ago

ctessum commented 4 years ago

Hello,

I am encountering a confusing issue. s1.Radian is clearly defined as 1, but when I print it from within a program it equals 57.2957795 and s1.Degree equals 1.

Any ideas what the issue could be, or what I'm misunderstanding here?

$ cat example.go 
package main

import(
"fmt"
"github.com/golang/geo/s1"
)

func main() {
fmt.Println(s1.Radian)
}

$ go mod init example
go: creating new go.mod: module example

$ go run example.go 
go: finding module for package github.com/golang/geo/s1
go: found github.com/golang/geo/s1 in github.com/golang/geo v0.0.0-20200319012246-673a6f80352d
57.2957795

$ go version
go version go1.14.2 linux/amd64

Thanks!

rsned commented 4 years ago

s1.Angle has a String() method https://github.com/golang/geo/blob/master/s1/angle.go#L110 that prints it out using x.Degrees().

To get it as a radian you would need to either use %f, or cast it to a float https://play.golang.org/p/JN0YLlUXyBW