trig

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package trig implements various trigonometrical calculations.

Index

Constants

View Source
const (
	// MinAngle is the smallest valid angle in degrees.
	MinAngle = 0
	// MaxAngle is the largest valid angle in degrees.
	MaxAngle = 360
)

Variables

This section is empty.

Functions

func CircleAngleAtPoint

func CircleAngleAtPoint(point, mid image.Point) int

CircleAngleAtPoint given a point on a circle and its midpoint, calculates the angle in degrees. Angles are zero at the X axis and grow counter-clockwise.

func CirclePointAtAngle

func CirclePointAtAngle(degrees int, mid image.Point, radius int) image.Point

CirclePointAtAngle given an angle in degrees and a circle midpoint and radius, calculates coordinates of a point on the circle at that angle. Angles are zero at the X axis and grow counter-clockwise.

func FilterByAngle

func FilterByAngle(points []image.Point, mid image.Point, start, end int) ([]image.Point, error)

FilterByAngle filters the provided points, returning only those that fall within the starting and the ending angle on a circle with the provided mid point.

func PointIsIn

func PointIsIn(p image.Point, points []image.Point) bool

PointIsIn asserts whether the provided point is inside of a shape outlined with the provided points. Does not verify that the shape is closed or complete, it merely counts the number of intersections with the shape on one row.

func RangeMid

func RangeMid(start, end int) (int, error)

RangeMid returns an angle that lies in the middle between start and end. E.g:

0,10   => 5
350,10 => 0

func RangeSize

func RangeSize(start, end int) (int, error)

RangeSize returns the size of the degree range. E.g:

0,25  => 25
359,1 => 2

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL