| 71 | } |
| 72 | |
| 73 | func (poly *B2PolygonShape) SetAsBoxFromCenterAndAngle(hx float64, hy float64, center B2Vec2, angle float64) { |
| 74 | poly.M_count = 4 |
| 75 | poly.M_vertices[0].Set(-hx, -hy) |
| 76 | poly.M_vertices[1].Set(hx, -hy) |
| 77 | poly.M_vertices[2].Set(hx, hy) |
| 78 | poly.M_vertices[3].Set(-hx, hy) |
| 79 | poly.M_normals[0].Set(0.0, -1.0) |
| 80 | poly.M_normals[1].Set(1.0, 0.0) |
| 81 | poly.M_normals[2].Set(0.0, 1.0) |
| 82 | poly.M_normals[3].Set(-1.0, 0.0) |
| 83 | poly.M_centroid = center |
| 84 | |
| 85 | xf := MakeB2Transform() |
| 86 | xf.P = center |
| 87 | xf.Q.Set(angle) |
| 88 | |
| 89 | // Transform vertices and normals. |
| 90 | for i := 0; i < poly.M_count; i++ { |
| 91 | poly.M_vertices[i] = B2TransformVec2Mul(xf, poly.M_vertices[i]) |
| 92 | poly.M_normals[i] = B2RotVec2Mul(xf.Q, poly.M_normals[i]) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | func (poly B2PolygonShape) GetChildCount() int { |
| 97 | return 1 |