Ejemplo n.º 1
0
func floatArrayEq(xs, ys []float64) bool {
	if len(xs) != len(ys) {
		return false
	}
	for i := 0; i < len(xs); i++ {
		if !num.AlmostEqual(xs[i], ys[i]) {
			return false
		}
	}
	return true
}
Ejemplo n.º 2
0
func NewFinitePlane(anchor, coplanarX, coplanarY vec.Vector, width, height float64) *FinitePlane {
	if len(anchor) != len(coplanarX) || len(anchor) != len(coplanarY) {
		panic("")
	}

	plane := new(FinitePlane)
	plane.Width = width
	plane.Height = height
	plane.CoplanarX = coplanarX.Normalize()
	plane.CoplanarY = coplanarY.Normalize()
	plane.Normal = vec.Cross(plane.CoplanarX, plane.CoplanarY)

	// If coplanarX and coplanarY are colinear, we'll have issues.
	if num.AlmostEqual(0.0, plane.Normal.Norm()) {
		panic("")
	}

	return plane
}