floatgeom

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2018 License: Apache-2.0 Imports: 1 Imported by: 38

Documentation

Overview

Package floatgeom stores primitives for floating point geometry

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance2

func Distance2(x1, y1, x2, y2 float64) float64

Distance2 calculates the euclidean distance between two points, as two (x,y) pairs

func Distance3

func Distance3(x1, y1, z1, x2, y2, z2 float64) float64

Distance3 calculates the euclidean distance between two points, as two (x,y,z) triplets

Types

type Point2

type Point2 [2]float64

Point2 represents a 2D point in space.

func AnglePoint

func AnglePoint(angle float64) Point2

AnglePoint creates a unit vector from the given angle in degrees as a Point2.

func RadianPoint

func RadianPoint(radians float64) Point2

RadianPoint creates a unit vector from the given angle in radians as a Point2.

func (Point2) Add

func (p Point2) Add(ps ...Point2) Point2

Add combines the input points via addition.

func (Point2) AngleTo

func (p Point2) AngleTo(p2 Point2) float64

AngleTo returns the angle from p to p2 in degrees.

func (Point2) Dim

func (p Point2) Dim(i int) float64

Dim returns the value of p in the ith dimension. Panics if i > 1. No check is made for efficiency's sake, pending benchmarks, but adding an error here would significantly worsen the API.

func (Point2) Distance

func (p Point2) Distance(p2 Point2) float64

Distance calculates the distance between this Point2 and another.

func (Point2) Div

func (p Point2) Div(ps ...Point2) Point2

Div combines the input points via division.

func (Point2) GreaterOf

func (p Point2) GreaterOf(ps ...Point2) Point2

GreaterOf returns the highest values on each axis of the input points as a point.

func (Point2) LesserOf

func (p Point2) LesserOf(ps ...Point2) Point2

LesserOf returns the lowest values on each axis of the input points as a point.

func (Point2) Mul

func (p Point2) Mul(ps ...Point2) Point2

Mul combines in the input points via multiplication.

func (Point2) MulConst

func (p Point2) MulConst(fs ...float64) Point2

MulConst multiplies all elements of a point by the input floats

func (Point2) RadiansTo

func (p Point2) RadiansTo(p2 Point2) float64

RadiansTo returns the angle from p to p2 in radians.

func (Point2) Sub

func (p Point2) Sub(ps ...Point2) Point2

Sub combines the input points via subtraction.

func (Point2) ToAngle

func (p Point2) ToAngle() float64

ToAngle returns this point as an angle in degrees.

func (Point2) ToRadians

func (p Point2) ToRadians() float64

ToRadians returns this point as an angle in radians.

func (Point2) ToRect

func (p Point2) ToRect(span float64) Rect2

ToRect converts this point into a rectangle spanning span distance in each axis.

func (Point2) X

func (p Point2) X() float64

X returns p's value on the X axis.

func (Point2) Y

func (p Point2) Y() float64

Y returns p's value on the Y axis.

type Point3

type Point3 [3]float64

Point3 represents a 3D point in space.

func (Point3) Add

func (p Point3) Add(ps ...Point3) Point3

Add combines the input points via addition.

func (Point3) Dim

func (p Point3) Dim(i int) float64

Dim returns the value of p in the ith dimension. Panics if i > 2. No check is made for efficiency's sake, pending benchmarks, but adding an error here would significantly worsen the API.

func (Point3) Distance

func (p Point3) Distance(p2 Point3) float64

Distance calculates the distance between this Point3 and another.

func (Point3) Div

func (p Point3) Div(ps ...Point3) Point3

Div combines the input points via division.

func (Point3) GreaterOf

func (p Point3) GreaterOf(ps ...Point3) Point3

GreaterOf returns the highest values on each axis of the input points as a point.

func (Point3) LesserOf

func (p Point3) LesserOf(ps ...Point3) Point3

LesserOf returns the lowest values on each axis of the input points as a point.

func (Point3) Mul

func (p Point3) Mul(ps ...Point3) Point3

Mul combines in the input points via multiplication.

func (Point3) MulConst

func (p Point3) MulConst(fs ...float64) Point3

MulConst multiplies all elements of a point by the input floats

func (Point3) Sub

func (p Point3) Sub(ps ...Point3) Point3

Sub combines the input points via subtraction.

func (Point3) ToRect

func (p Point3) ToRect(span float64) Rect3

ToRect converts this point into a rectangle spanning span distance in each axis.

func (Point3) X

func (p Point3) X() float64

X returns p's value on the X axis.

func (Point3) Y

func (p Point3) Y() float64

Y returns p's value on the Y axis.

func (Point3) Z

func (p Point3) Z() float64

Z returns p's value on the Z axis.

type Rect2

type Rect2 struct {
	Min, Max Point2
}

A Rect2 represents a span from one point in 2D space to another. If Min is less than max on any axis, it will return undefined results for methods.

func NewBoundingRect2

func NewBoundingRect2(pts ...Point2) Rect2

NewBoundingRect2 will produce the minimal rectangle that contains all of the input points.

func NewRect2

func NewRect2(x, y, x2, y2 float64) Rect2

NewRect2 returns an (X,Y):(X2,Y2) rectangle. This enforces that x < x2 and y < y2, and will swap the inputs if that is not true. If that enforcement is not desired, construct the struct manually.

func NewRect2WH

func NewRect2WH(x, y, w, h float64) Rect2

NewRect2WH returns an (X,Y):(X+W,Y+H) rectangle. This enforces that w and h are positive, and will decrease x and y respectively if that is not true.

func (Rect2) Area

func (r Rect2) Area() float64

Area returns W * H.

func (Rect2) Contains

func (r Rect2) Contains(p Point2) bool

Contains tests whether p is located inside or on the boundary of r.

func (Rect2) ContainsRect

func (r Rect2) ContainsRect(r2 Rect2) bool

ContainsRect tests whether r2 is is located inside r1.

func (Rect2) GreaterOf

func (r Rect2) GreaterOf(r2 Rect2) Rect2

GreaterOf returns a rectangle formed of the lowest values on each dimension for Min, and the highest for Max.

func (Rect2) H

func (r Rect2) H() float64

H returns the height of this rectangle.

func (Rect2) Intersects

func (r Rect2) Intersects(r2 Rect2) bool

Intersects returns whether the two rectangles intersect.

func (Rect2) MaxDimensions

func (r Rect2) MaxDimensions() int

MaxDimensions reports that a Rect2 has only two dimensions of definition.

func (Rect2) Midpoint

func (r Rect2) Midpoint(i int) float64

Midpoint returns the midpoint of this rectangle's span over a given dimension.

func (Rect2) Perimeter

func (r Rect2) Perimeter() float64

Perimeter computes the sum of the edge lengths of a rectangle.

func (Rect2) Span

func (r Rect2) Span(i int) float64

Span returns the span on this rectangle's ith axis.

func (Rect2) W

func (r Rect2) W() float64

W returns the width of this rectangle.

type Rect3

type Rect3 struct {
	Min, Max Point3
}

A Rect3 represents a span from one point in 3D space to another. If Min is less than Max on any axis, it will return undefined results for methods.

func NewBoundingRect3

func NewBoundingRect3(pts ...Point3) Rect3

NewBoundingRect3 will produce the minimal rectangle that contains all of the input points.

func NewRect3

func NewRect3(x, y, z, x2, y2, z2 float64) Rect3

NewRect3 returns an (X,Y,Z):(X2,Y2,Z2) rectangle. This enforces that x < x2, y < y2, and z < z2, and will swap the inputs if that is not true.

func NewRect3WH

func NewRect3WH(x, y, z, w, h, d float64) Rect3

NewRect3WH returns an (X,Y,Z):(X+W,Y+H,Z+D) rectangle. This enforces that w, h, and d and positive, and will decrease x, y, and z respectively if that is not true.

func (Rect3) Contains

func (r Rect3) Contains(p Point3) bool

Contains tests whether p is located inside or on the boundary of r.

func (Rect3) ContainsRect

func (r Rect3) ContainsRect(r2 Rect3) bool

ContainsRect tests whether r2 is is located inside r1.

func (Rect3) D

func (r Rect3) D() float64

D returns the depth of this rectangle.

func (Rect3) GreaterOf

func (r Rect3) GreaterOf(r2 Rect3) Rect3

GreaterOf returns a rectangle formed of the lowest values on each dimension for Min, and the highest for Max.

func (Rect3) H

func (r Rect3) H() float64

H returns the height of this rectangle.

func (Rect3) Intersects

func (r Rect3) Intersects(r2 Rect3) bool

Intersects returns whether the two rectangles intersect.

func (Rect3) Margin

func (r Rect3) Margin() float64

Margin computes the sum of the edge lengths of a rectangle.

func (Rect3) MaxDimensions

func (r Rect3) MaxDimensions() int

MaxDimensions reports that a Rect3 has only three dimensions of definition.

func (Rect3) Midpoint

func (r Rect3) Midpoint(i int) float64

Midpoint returns the midpoint of this rectangle's span over a given dimension.

func (Rect3) Space

func (r Rect3) Space() float64

Space returns W * H * D

func (Rect3) Span

func (r Rect3) Span(i int) float64

Span returns the span on this rectangle's ith axis.

func (Rect3) W

func (r Rect3) W() float64

W returns the width of this rectangle.

Jump to

Keyboard shortcuts

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