func (r Ray) IntersectRect(b Rectangle) bool {
	t1 := (b.Min.X - r.o.X) * r.invv.X
	t2 := (b.Max.X - r.o.X) * r.invv.X

	tmin := math.Min(t1, t2)
	tmax := math.Max(t1, t2)

	// x
	t1 = (b.Min.X - r.o.X) * r.invv.X
	t2 = (b.Max.X - r.o.X) * r.invv.X
	tmin = math.Max(tmin, math.Min(t1, t2))
	tmax = math.Min(tmax, math.Max(t1, t2))

	// y
	t1 = (b.Min.Y - r.o.Y) * r.invv.Y
	t2 = (b.Max.Y - r.o.Y) * r.invv.Y
	tmin = math.Max(tmin, math.Min(t1, t2))
	tmax = math.Min(tmax, math.Max(t1, t2))

	return tmax >= math.Max(tmin, 0.0)
}
func (r Ray) IntersectRect(b Rectangle) bool {
	t1 := (b.Min.X - r.o.X) * r.invv.X
	t2 := (b.Max.X - r.o.X) * r.invv.X

	tmin := math.Min(t1, t2)
	tmax := math.Max(t1, t2)

	
	t1 = (b.Min.X - r.o.X) * r.invv.X
	t2 = (b.Max.X - r.o.X) * r.invv.X
	tmin = math.Max(tmin, math.Min(t1, t2))
	tmax = math.Min(tmax, math.Max(t1, t2))

	
	t1 = (b.Min.Y - r.o.Y) * r.invv.Y
	t2 = (b.Max.Y - r.o.Y) * r.invv.Y
	tmin = math.Max(tmin, math.Min(t1, t2))
	tmax = math.Min(tmax, math.Max(t1, t2))

	return tmax >= math.Max(tmin, 0.0)
}
func ( r Ray ) IntersectRect ( b Rectangle ) bool { t1 := ( b . Min . X - r . o . X ) * r . invv . X t2 := ( b . Max . X - r . o . X ) * r . invv . X tmin := math . Min ( t1 , t2 ) tmax := math . Max ( t1 , t2 ) // x t1 = ( b . Min . X - r . o . X ) * r . invv . X t2 = ( b . Max . X - r . o . X ) * r . invv . X tmin = math . Max ( tmin , math . Min ( t1 , t2 ) ) tmax = math . Min ( tmax , math . Max ( t1 , t2 ) ) // y t1 = ( b . Min . Y - r . o . Y ) * r . invv . Y t2 = ( b . Max . Y - r . o . Y ) * r . invv . Y tmin = math . Max ( tmin , math . Min ( t1 , t2 ) ) tmax = math . Min ( tmax , math . Max ( t1 , t2 ) ) return tmax >= math . Max ( tmin , 0.0 ) }
// IntersectRect indicates wether the ray intersects with the rectangle b.
IntersectRect indicates wether the ray intersects with the rectangle b .