forked from Tarliton/collision2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponse.go
29 lines (24 loc) · 914 Bytes
/
response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package collision2d
import (
"fmt"
"math"
)
//Response contains the information about an collision test.
type Response struct {
A, B interface{}
Overlap float64
OverlapN, OverlapV Vector
AInB, BInA bool
}
func (response Response) String() string {
output := string("Response:\n{A: %s\nB: %s\nOverlap: %f\nOverlapN: %sOverlapV: %sAInB: %t, BInA: %t}")
return fmt.Sprintf(output, response.A, response.B, response.Overlap, response.OverlapN, response.OverlapV, response.AInB, response.BInA)
}
//NewResponse is used to create a new response when necessary.
func NewResponse() Response {
return Response{Overlap: math.MaxFloat64, AInB: true, BInA: true}
}
//NotColliding is to be used when A and B are not colliding and response should be ignored.
func (response *Response) NotColliding() Response {
return Response{Overlap: -math.MaxFloat64, AInB: false, BInA: false}
}