Documentation
¶
Index ¶
- Variables
- func DegreesToRadian(degrees float64) float64
- func GetAngle2D(v1 Point, v2 Point) float64
- func NormalizeDegrees(value float64) float64
- func RadianToDegree(radian float64) float64
- type Border
- type Box
- func (b Box) BoundingBox(r2 Box) Box
- func (b Box) Bounds() Box
- func (b Box) Center() Point
- func (b Box) Contains(v Point) bool
- func (b Box) ContainsPoint(p Point) bool
- func (b Box) ContainsRectangle(r2 Box) bool
- func (b Box) Equal(r2 Box) bool
- func (b Box) Fit(o Box) bool
- func (b Box) Get() Spatial
- func (b Box) Intersect(r2 Box) (Box, bool)
- func (b Box) Margin() float64
- func (b Box) Move(diff Point) Spatial
- func (b Box) Point1() Point
- func (b Box) Point2() Point
- func (b Box) Size(i int) float64
- func (b Box) Sizes() [3]float64
- func (b Box) Split() [8]Box
- func (b Box) Support(d Point) Point
- func (b Box) ToPolygon() Polyhedron
- func (b Box) ToPolyhedron() Polyhedron
- func (b Box) VectorSizes() Point
- func (b Box) Volume() float64
- type Collide
- type Ellipsoid
- type Line
- type MultiObject
- func (m MultiObject) Bounds() Box
- func (m MultiObject) Center() Point
- func (m MultiObject) Coordinates() [3]float64
- func (m MultiObject) Count() int
- func (m MultiObject) Get() Spatial
- func (m MultiObject) Move(diff Point) Spatial
- func (m MultiObject) Object(i int) Spatial
- func (m MultiObject) Objects() []Spatial
- func (m MultiObject) Point1() Point
- func (m MultiObject) Support(d Point) Point
- type Point
- func (p Point) Abs() Point
- func (p Point) Add(diff Point) Point
- func (p Point) Bounds() Box
- func (p Point) Center() Point
- func (p Point) Coordinate(i int) float64
- func (p Point) Coordinates() [3]float64
- func (p Point) Copy() Point
- func (p Point) Cross(p2 Point) Point
- func (p Point) Decrease(v float64) Point
- func (p Point) Distance(p2 Point) float64
- func (p Point) DistanceSquare(p2 Point) float64
- func (p Point) Divide(diff Point) Point
- func (p Point) Dot(p2 Point) float64
- func (p Point) Equals(p2 Point) bool
- func (p Point) Get() Spatial
- func (p Point) GetMinAxis() int
- func (p Point) Increase(v float64) Point
- func (p Point) Invert() Point
- func (p Point) IsEmpty() bool
- func (p Point) Lerp(other Point, f float64) Point
- func (p Point) ManhattanDistance(p2 Point) float64
- func (p Point) Max(other Point) Point
- func (p Point) Min(other Point) Point
- func (p Point) MinDistance(r Box) float64
- func (p Point) MinMaxDistance(r Box) float64
- func (p Point) Move(diff Point) Spatial
- func (p Point) Multiply(diff Point) Point
- func (p Point) Normal() float64
- func (p Point) NormalSquare() float64
- func (p Point) Normalize() Point
- func (p Point) Point1() Point
- func (p Point) Reflect(normal Point) Point
- func (p Point) Refract(normal Point, eta float64) Point
- func (p Point) Round(precision float64) Point
- func (p Point) Scale(v float64) Point
- func (p Point) Subtract(diff Point) Point
- func (p Point) Support(_ Point) Point
- type Polyhedron
- func (p Polyhedron) Bounds() Box
- func (p Polyhedron) Center() Point
- func (p Polyhedron) Coordinates() [3]float64
- func (p Polyhedron) Count() int
- func (p Polyhedron) Get() Spatial
- func (p Polyhedron) Move(diff Point) Spatial
- func (p Polyhedron) Point1() Point
- func (p Polyhedron) Support(d Point) Point
- func (p Polyhedron) ToLines() (line []Line)
- func (p Polyhedron) Vector(i int) Point
- func (p Polyhedron) Vectors() []Point
- type Rotatable
- type RotatableBox
- func (b RotatableBox) Bounds() Box
- func (b RotatableBox) Center() Point
- func (b RotatableBox) Get() Spatial
- func (b RotatableBox) Move(diff Point) Spatial
- func (b RotatableBox) Rotate(c Point, byX, byY, byZ float64) RotatableBox
- func (b RotatableBox) Size(i int) float64
- func (b RotatableBox) Sizes() [3]float64
- func (b RotatableBox) Support(d Point) Point
- type Spatial
- type Sphere
- type Triangle
- func (t Triangle) Bounds() Box
- func (t Triangle) CalculateSurfaceNormal() Point
- func (t Triangle) Center() Point
- func (t Triangle) Coordinates() [3]float64
- func (t Triangle) Get() Spatial
- func (t Triangle) Move(diff Point) Spatial
- func (t Triangle) Point1() Point
- func (t Triangle) Support(d Point) Point
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnexpectedValue = errors.New("error unexpected value")
)
Shapes errors
Functions ¶
func DegreesToRadian ¶
DegreesToRadian return radian for given degrees
func GetAngle2D ¶
GetAngle2D get angle between points in radian
func NormalizeDegrees ¶
NormalizeDegrees return degrees n range 0-360
func RadianToDegree ¶
RadianToDegree return degree for given rad
Types ¶
type Border ¶
type Border struct {
Box
}
Border special type of Box. Collision will return true, if object out of border
type Box ¶
type Box struct { Point // contains filtered or unexported fields }
Box describe rectangle
func (Box) BoundingBox ¶
BoundingBox constructs the smallest rectangle containing both r1 and r2.
func (Box) ContainsPoint ¶
ContainsPoint tests whether p is located inside or on the boundary of r
func (Box) ContainsRectangle ¶
ContainsRectangle tests whether r2 is is located inside r1.
func (Box) ToPolyhedron ¶
func (b Box) ToPolyhedron() Polyhedron
ToPolyhedron return polyhedron from box
type Ellipsoid ¶
type Ellipsoid struct { Point // contains filtered or unexported fields }
Ellipsoid contains point and sizes
func NewEllipsoid ¶
NewEllipsoid return new circle
type Line ¶
type Line struct { Point // contains filtered or unexported fields }
Line describe line
func (Line) ProjectForPoint ¶
ProjectForPoint project point on line
type MultiObject ¶
type MultiObject struct {
// contains filtered or unexported fields
}
MultiObject contains different object to describe another object
func NewMultiObject ¶
func NewMultiObject(objects ...Spatial) MultiObject
NewMultiObject return new multi-object
func (MultiObject) Coordinates ¶
func (m MultiObject) Coordinates() [3]float64
Coordinates return 3d coordinates
func (MultiObject) Move ¶
func (m MultiObject) Move(diff Point) Spatial
Move return new object for given diff
func (MultiObject) Support ¶
func (m MultiObject) Support(d Point) Point
Support return support point
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point describe point
func CoordinatesToPoint ¶
CoordinatesToPoint return point by coordinates
func GetDiffPoint2D ¶
GetDiffPoint2D return diff point 2D
func RotatePoint ¶
RotatePoint rotate point by roll, yaw and pitch
func (Point) Coordinate ¶
Coordinate return coordinate for dimension (0-x, 1-y, 2-z)
func (Point) Coordinates ¶
Coordinates return all coordinates
func (Point) DistanceSquare ¶
DistanceSquare return distance square between positions (euclidean)
func (Point) GetMinAxis ¶
GetMinAxis return the axis with the minimal value
func (Point) ManhattanDistance ¶
ManhattanDistance return manhattan distance
func (Point) Max ¶
Max Returns the a vector where each component is the greater of the corresponding component in this and the specified vector
func (Point) Min ¶
Min Returns the a vector where each component is the lesser of the corresponding component in this and the specified vector
func (Point) MinDistance ¶
MinDistance computes the square of the distance from a point to a rectangle.
func (Point) MinMaxDistance ¶
MinMaxDistance computes the minimum of the maximum distances from p to points on r.
func (Point) NormalSquare ¶
NormalSquare returns the vector's norm square.
type Polyhedron ¶
type Polyhedron struct {
// contains filtered or unexported fields
}
Polyhedron describe polygon
func NewPolyhedron ¶
func NewPolyhedron(vectors ...Point) Polyhedron
NewPolyhedron return new polygon
func (Polyhedron) Coordinates ¶
func (p Polyhedron) Coordinates() [3]float64
Coordinates return 3d coordinates
func (Polyhedron) Move ¶
func (p Polyhedron) Move(diff Point) Spatial
Move return new object for given diff
func (Polyhedron) ToLines ¶
func (p Polyhedron) ToLines() (line []Line)
ToLines return lines of polyhedron
type Rotatable ¶
func NewRotatable ¶
type RotatableBox ¶
type RotatableBox struct { Polyhedron // contains filtered or unexported fields }
RotatableBox describe rotatable box
func NewRotatableBox ¶
func NewRotatableBox(c Point, b Box, byX, byY, byZ float64) RotatableBox
NewRotatableBox return new rotatable box by x,y,z
func (RotatableBox) Move ¶
func (b RotatableBox) Move(diff Point) Spatial
Move return new object for given diff
func (RotatableBox) Rotate ¶
func (b RotatableBox) Rotate(c Point, byX, byY, byZ float64) RotatableBox
Rotate rotate box
func (RotatableBox) Support ¶
func (b RotatableBox) Support(d Point) Point
Support return support point for box
type Spatial ¶
type Spatial interface { Point1() Point Coordinates() [3]float64 Center() Point Get() Spatial Move(diff Point) Spatial Bounds() Box }
Spatial describe boundable object
type Sphere ¶
type Sphere struct { Point // contains filtered or unexported fields }
Sphere contains point and radius
func (Sphere) CollisionSphere ¶
CollisionSphere return true if two spheres collided
type Triangle ¶
type Triangle struct {
// contains filtered or unexported fields
}
Triangle describe triangle by 3 points
func (Triangle) CalculateSurfaceNormal ¶
CalculateSurfaceNormal return triangle normal
func (Triangle) Coordinates ¶
Coordinates return coordinate for dimension (0-x, 1-y, 2-z)