MCPcopy Create free account
hub / github.com/ByteArena/box2d / SetAsBoxFromCenterAndAngle

Method SetAsBoxFromCenterAndAngle

CollisionB2ShapePolygon.go:73–94  ·  view source on GitHub ↗
(hx float64, hy float64, center B2Vec2, angle float64)

Source from the content-addressed store, hash-verified

71}
72
73func (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
96func (poly B2PolygonShape) GetChildCount() int {
97 return 1

Callers 1

TestCPPComplianceFunction · 0.80

Calls 4

MakeB2TransformFunction · 0.85
B2TransformVec2MulFunction · 0.85
B2RotVec2MulFunction · 0.85
SetMethod · 0.45

Tested by 1

TestCPPComplianceFunction · 0.64