Documentation
¶
Overview ¶
Package utility implements functions that I couldn't figure out where to put.
Index ¶
- func GeoDesicPoints(depth int, radius float64) (spherePoints [][3]float64)
- func LinearInterpolation(x, y []float64, xNew float64) (float64, error)
- func MaxLoc(array []float64) (maxloc int)
- func Smooth(x, y []float64, zeroTol float64, zeroEnds bool) ([]float64, []float64, error)
- func TriArea(v1, v2, v3 [3]float64) (area float64)
- func TriIntersect(p1, p2, p3, rayOrigin, rayEnd [3]float64) (intersect bool, t float64, err error)
- func TriIntersectComprehensive(p1, p2, p3, rayOrigin, rayEnd [3]float64) (intersect bool, front bool, distance float64, point [3]float64)
- func TriMaxSize(v1, v2, v3 [3]float64) (max float64)
- func TriMidPt(v1, v2, v3 [3]float64) (midPt [3]float64)
- func TriMinSize(v1, v2, v3 [3]float64) (min float64)
- func TriNormal(p1, p2, p3 [3]float64) (normal [3]float64)
- func TriSamplePoints(v1, v2, v3 [3]float64, min float64, maxDiv int) (samplePoints [][3]float64)
- func TriSamplePointsNew(v1, v2, v3 [3]float64, min float64) (samplePoints [][3]float64)
- func TriSubdivide(v1, v2, v3 [3]float64, min float64, maxDiv, currDiv int, ...)
- type BspNode
- type BspObj
- type DirectionType
- type Intersection
- type IntersectionList
- type Ray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeoDesicPoints ¶
GeoDesicPoints returns a list of points equally distributed over a sphere depth 0 returns 12 points, 1 returns 72 points, 2 returns 312 points, 3 returns 1272 points radius sets the radius of the points about the origin
func LinearInterpolation ¶
LinearInterpolation finds the y value associated with xNew given a list of x and y values using linear interpolation.
func Smooth ¶
Smooth processes a curve and tries to reduce the number of points by eliminating points where significant error is not incured
zeroTol is used to determine if a value should actually be zero. If it is less than 0 it will be determined from them min and max y. If zeroEnds is true points with y = 0.0 will be inserted at the begining and end of the resulting lists. It will also ensure that there are not many zeros at the end of the list.
func TriIntersect ¶
TriIntersect determines whether a line segment defined by rayOrigin and rayEnd intersects a triangle defined by the points p1, p2, p3. This algorithm was originally from an efficient ray-polygon intersection by Didier Badouel from the book Graphics Gems I */
func TriIntersectComprehensive ¶
func TriIntersectComprehensive(p1, p2, p3, rayOrigin, rayEnd [3]float64) (intersect bool, front bool, distance float64, point [3]float64)
TriIntersectComprehensive runs TriIntersect and returns more information:
whether the front (positive normal side) was hit, the distance of the intersection from the origin, and the intersection point
func TriMaxSize ¶
TriMaxSize returns the maximum edge length of the facet.
func TriMinSize ¶
TriMinSize returns the maximum edge length of the facet.
func TriSamplePoints ¶
TriSamplePoints creates a list of sample points on a triangle
func TriSamplePointsNew ¶
TriSamplePointsNew creates a list of sample points on a triangle
Types ¶
type BspNode ¶
type BspNode struct { Objs []BspObj Layer int Dir DirectionType SplitVal float64 Greater *BspNode Lesser *BspNode }
BspNode represents a node of a BSP of facets
func CreateBspTree ¶
CreateBspTree creates a BSP tree given a list of facets
func (*BspNode) FindIntersections ¶
func (node *BspNode) FindIntersections(ray *Ray, all bool, exception string) (intersections IntersectionList)
FindIntersections creates a sorted list of intersections between a ray and the facets in a bsptree if all is true if all is false FindIntersection returns when the first intersection is found.
type BspObj ¶
type BspObj interface { String() string AvgLoc(DirectionType) float64 MinLoc(DirectionType) float64 MaxLoc(DirectionType) float64 Intersect(*Ray) *Intersection }
BspObj is an interface for an object that can be stored in the bsp tree structure
type DirectionType ¶
type DirectionType int
DirectionType specifies the X, Y, or Z directions
const ( X DirectionType = 0 Y DirectionType = 1 Z DirectionType = 2 )
Enums for DirectionType
type Intersection ¶
type Intersection struct { Obj fmt.Stringer // pointer to the thing hit Front bool // did the ray hit the front (positive normal) side of the facet Dist float64 // distance of the intersection from the root point of the ray Loc [3]float64 // location in 3d of the inersection }
Intersection describes the where a ray and a facet intersect
func (*Intersection) String ¶
func (x *Intersection) String() string
type IntersectionList ¶
type IntersectionList []*Intersection
IntersectionList is a list of intersections that can be sorted from smallest Distance to largest
func (IntersectionList) Len ¶
func (a IntersectionList) Len() int
func (IntersectionList) Less ¶
func (a IntersectionList) Less(i, j int) bool
func (IntersectionList) String ¶
func (a IntersectionList) String() string
func (IntersectionList) Swap ¶
func (a IntersectionList) Swap(i, j int)
type Ray ¶
type Ray struct { RootPt [3]float64 // The Root point of this ray segment. EndPt [3]float64 // The End point of this ray segment. Distance float64 }
Ray defines a ray or a segment of a ray with rootpt and an endpt. Distance from the RootPt to the actual root point (to allow for ray splitting) if the whole ray is represented by RootPt and EndPt this number would be 0.
func (*Ray) MaxLoc ¶
func (ray *Ray) MaxLoc(dir DirectionType) (min float64)
MaxLoc returns the max location on the dir axis
func (*Ray) MinLoc ¶
func (ray *Ray) MinLoc(dir DirectionType) (min float64)
MinLoc returns the min location on the dir axis