aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/paulmach/orb/planar/example_test.go
blob: 0cf83d91bab6cfc097eca36f8e45e46c17bb2b8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package planar_test

import (
	"fmt"

	"github.com/paulmach/orb"
	"github.com/paulmach/orb/planar"
)

func ExampleArea() {
	// +
	// |\
	// | \
	// |  \
	// +---+

	r := orb.Ring{{0, 0}, {3, 0}, {0, 4}, {0, 0}}
	a := planar.Area(r)

	fmt.Println(a)
	// Output:
	// 6
}

func ExampleDistance() {
	d := planar.Distance(orb.Point{0, 0}, orb.Point{3, 4})

	fmt.Println(d)
	// Output:
	// 5
}

func ExampleLength() {
	// +
	// |\
	// | \
	// |  \
	// +---+

	r := orb.Ring{{0, 0}, {3, 0}, {0, 4}, {0, 0}}
	l := planar.Length(r)

	fmt.Println(l)
	// Output:
	// 12
}