MCPcopy Index your code
hub / github.com/EngoEngine/engo / Corners

Method Corners

common/collision.go:191–207  ·  view source on GitHub ↗

Corners returns the location of the four corners of the rectangular plane defined by the `SpaceComponent`, taking into account any possible rotation.

()

Source from the content-addressed store, hash-verified

189// Corners returns the location of the four corners of the rectangular plane defined by the `SpaceComponent`, taking
190// into account any possible rotation.
191func (sc SpaceComponent) Corners() (points [4]engo.Point) {
192 points[0].X = sc.Position.X
193 points[0].Y = sc.Position.Y
194
195 sin, cos := math.Sincos(sc.Rotation * math.Pi / 180)
196
197 points[1].X = points[0].X + sc.Width*cos
198 points[1].Y = points[0].Y + sc.Width*sin
199
200 points[2].X = points[0].X - sc.Height*sin
201 points[2].Y = points[0].Y + sc.Height*cos
202
203 points[3].X = points[0].X + sc.Width*cos - sc.Height*sin
204 points[3].Y = points[0].Y + sc.Height*cos + sc.Width*sin
205
206 return
207}
208
209// Contains indicates whether or not the given point is within the shape defined by this `SpaceComponent`.
210// If it's on the border, it is considered "not within".

Callers 5

AABBMethod · 0.95
ContainsMethod · 0.95
ShouldDrawMethod · 0.95
ShouldDrawMethod · 0.95

Calls 1

SincosFunction · 0.92

Tested by 1