Documentation ¶
Overview ¶
Package floatgeom stores primitives for floating point geometry
Index ¶
- Variables
- func Distance2(x1, y1, x2, y2 float64) float64
- func Distance3(x1, y1, z1, x2, y2, z2 float64) float64
- type Dir2
- type Point2
- func (p Point2) Add(ps ...Point2) Point2
- func (p Point2) AngleTo(p2 Point2) float64
- func (p Point2) Dim(i int) float64
- func (p Point2) Distance(p2 Point2) float64
- func (p Point2) Div(ps ...Point2) Point2
- func (p Point2) DivConst(fs ...float64) Point2
- func (p Point2) Dot(p2 Point2) float64
- func (p Point2) GreaterOf(ps ...Point2) Point2
- func (p Point2) LesserOf(ps ...Point2) Point2
- func (p Point2) Magnitude() float64
- func (p Point2) Mul(ps ...Point2) Point2
- func (p Point2) MulConst(fs ...float64) Point2
- func (p Point2) Normalize() Point2
- func (p Point2) RadiansTo(p2 Point2) float64
- func (p Point2) Rotate(fs ...float64) Point2
- func (p Point2) RotateRadians(fs ...float64) Point2
- func (p Point2) Sub(ps ...Point2) Point2
- func (p Point2) ToAngle() float64
- func (p Point2) ToRadians() float64
- func (p Point2) ToRect(span float64) Rect2
- func (p Point2) X() float64
- func (p Point2) Y() float64
- type Point3
- func (p Point3) Add(ps ...Point3) Point3
- func (p Point3) Cross(p2 Point3) Point3
- func (p Point3) Dim(i int) float64
- func (p Point3) Distance(p2 Point3) float64
- func (p Point3) Div(ps ...Point3) Point3
- func (p Point3) DivConst(fs ...float64) Point3
- func (p Point3) Dot(p2 Point3) float64
- func (p Point3) GreaterOf(ps ...Point3) Point3
- func (p Point3) LesserOf(ps ...Point3) Point3
- func (p Point3) Magnitude() float64
- func (p Point3) Mul(ps ...Point3) Point3
- func (p Point3) MulConst(fs ...float64) Point3
- func (p Point3) Normalize() Point3
- func (p Point3) ProjectX() Point2
- func (p Point3) ProjectY() Point2
- func (p Point3) ProjectZ() Point2
- func (p Point3) Sub(ps ...Point3) Point3
- func (p Point3) ToRect(span float64) Rect3
- func (p Point3) X() float64
- func (p Point3) Y() float64
- func (p Point3) Z() float64
- type Point4
- func (p Point4) Conjugate() Point4
- func (p Point4) Dim(i int) float64
- func (p Point4) DivConst(fs ...float64) Point4
- func (p Point4) Dot(p2 Point4) float64
- func (p Point4) Inverse() Point4
- func (p Point4) Magnitude() float64
- func (p Point4) MulConst(fs ...float64) Point4
- func (p Point4) MulQuat(p2 Point4) Point4
- func (p Point4) Normalize() Point4
- func (p Point4) W() float64
- func (p Point4) X() float64
- func (p Point4) Y() float64
- func (p Point4) Z() float64
- type Rect2
- func (r Rect2) Area() float64
- func (r Rect2) Center() Point2
- func (r Rect2) Contains(p Point2) bool
- func (r Rect2) ContainsRect(r2 Rect2) bool
- func (r Rect2) GreaterOf(r2 Rect2) Rect2
- func (r Rect2) H() float64
- func (r Rect2) Intersects(r2 Rect2) bool
- func (r Rect2) MaxDimensions() int
- func (r Rect2) Midpoint(i int) float64
- func (r Rect2) Perimeter() float64
- func (r Rect2) Shift(p Point2) Rect2
- func (r Rect2) Span(i int) float64
- func (r Rect2) W() float64
- type Rect3
- func (r Rect3) Center() Point3
- func (r Rect3) Contains(p Point3) bool
- func (r Rect3) ContainsRect(r2 Rect3) bool
- func (r Rect3) D() float64
- func (r Rect3) GreaterOf(r2 Rect3) Rect3
- func (r Rect3) H() float64
- func (r Rect3) Intersects(r2 Rect3) bool
- func (r Rect3) Margin() float64
- func (r Rect3) MaxDimensions() int
- func (r Rect3) Midpoint(i int) float64
- func (r Rect3) Shift(p Point3) Rect3
- func (r Rect3) Space() float64
- func (r Rect3) Span(i int) float64
- func (r Rect3) W() float64
- type Tri3
Constants ¶
This section is empty.
Variables ¶
var ( Up = Dir2(Point2{0, -1}) Down = Dir2(Point2{0, 1}) Left = Dir2(Point2{-1, 0}) Right = Dir2(Point2{1, 0}) UpRight = Up.And(Right) DownRight = Down.And(Right) DownLeft = Down.And(Left) UpLeft = Up.And(Left) )
Dir2 values
Functions ¶
Types ¶
type Point2 ¶
type Point2 [2]float64
Point2 represents a 2D point on a plane.
func AnglePoint ¶
AnglePoint creates a unit vector from the given angle in degrees as a Point2.
func RadianPoint ¶
RadianPoint creates a unit vector from the given angle in radians as a Point2.
func (Point2) Div ¶
Div combines the input points via division. Div does not check that the inputs are non zero before operating, and can panic if that is not true.
func (Point2) DivConst ¶
DivConst divides all elements of a point by the input floats DivConst does not check that the inputs are non zero before operating, and can panic if that is not true.
func (Point2) GreaterOf ¶
GreaterOf returns the highest values on each axis of the input points as a point.
func (Point2) LesserOf ¶
LesserOf returns the lowest values on each axis of the input points as a point.
func (Point2) Rotate ¶
Rotate takes in a set of angles and rotates v by their sum the input angles are expected to be in degrees.
func (Point2) RotateRadians ¶
RotateRadians takes in a set of angles and rotates v by their sum the input angles are expected to be in radians.
type Point3 ¶
type Point3 [3]float64
Point3 represents a 3D point in space.
func (Point3) Div ¶
Div combines the input points via division. Div does not check that the inputs are non zero before operating, and can panic if that is not true.
func (Point3) DivConst ¶
DivConst divides all elements of a point by the input floats DivConst does not check that the inputs are non zero before operating, and can panic if that is not true.
func (Point3) GreaterOf ¶
GreaterOf returns the highest values on each axis of the input points as a point.
func (Point3) LesserOf ¶
LesserOf returns the lowest values on each axis of the input points as a point.
func (Point3) ProjectX ¶
ProjectX projects the Point3 onto the x axis, removing it's x component and returning a Point2 todo: I'm not sure about this (these) function name
func (Point3) ProjectY ¶
ProjectY projects the Point3 onto the y axis, removing it's y component and returning a Point2
func (Point3) ProjectZ ¶
ProjectZ projects the Point3 onto the z axis, removing it's z component and returning a Point2
type Point4 ¶
type Point4 [4]float64
Point4 represents a 4D point, in space + some additional dimension.
func (Point4) Conjugate ¶
Conjugate returns a value of a Point4 often obtained to calculate the inverse
func (Point4) DivConst ¶
DivConst divides all elements of a point by the input floats DivConst does not check that the inputs are non zero before operating, and can panic if that is not true.
func (Point4) MulQuat ¶
MulQuat multiplies two quaternions to generate a combined quarternion that represents both rotations ref: https://www.mathworks.com/help/aeroblks/quaternionmultiplication.html
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 ¶
NewBoundingRect2 will produce the minimal rectangle that contains all of the input points.
func NewRect2 ¶
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 ¶
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) ContainsRect ¶
ContainsRect tests whether r2 is is located inside r1.
func (Rect2) GreaterOf ¶
GreaterOf returns a rectangle formed of the lowest values on each dimension for Min, and the highest for Max.
func (Rect2) Intersects ¶
Intersects returns whether the two rectangles intersect.
func (Rect2) MaxDimensions ¶
MaxDimensions reports that a Rect2 has only two dimensions of definition.
func (Rect2) Midpoint ¶
Midpoint returns the midpoint of this rectangle's span over a given dimension.
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 ¶
NewBoundingRect3 will produce the minimal rectangle that contains all of the input points.
func NewRect3 ¶
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 ¶
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) ContainsRect ¶
ContainsRect tests whether r2 is is located inside r1.
func (Rect3) GreaterOf ¶
GreaterOf returns a rectangle formed of the lowest values on each dimension for Min, and the highest for Max.
func (Rect3) Intersects ¶
Intersects returns whether the two rectangles intersect.
func (Rect3) MaxDimensions ¶
MaxDimensions reports that a Rect3 has only three dimensions of definition.
func (Rect3) Midpoint ¶
Midpoint returns the midpoint of this rectangle's span over a given dimension.
type Tri3 ¶
type Tri3 [3]Point3
Tri3 is a triangle of Point3s
func (Tri3) Barycentric ¶
Barycentric finds the barycentric coordinates of the given x,y cartesian coordinates within this triangle. If the point (x,y) is outside of the triangle, one of the output values will be negative. Credit goes to github.com/yellingintothefan for their work in gel