public bool CollidesWith(OrientedRectangle orientedRectangle) { Rectangle localRectangle = orientedRectangle.TransformToLocalRectangle(); IVector2D lp = Position.Substract(orientedRectangle.Center); lp = lp.Rotate(-orientedRectangle.Rotation); lp = lp.Add(orientedRectangle.HalfExtend); var localPoint = new Point(lp); return localPoint.CollidesWith(localRectangle); }
public bool CollidesWith(OrientedRectangle orientedRectangle) { Rectangle lr = orientedRectangle.TransformToLocalRectangle(); IVector2D basee = Base.Substract(orientedRectangle.Center); basee = basee.Rotate(-orientedRectangle.Rotation); basee = basee.Add(orientedRectangle.HalfExtend); IVector2D direction = Direction.Rotate(-orientedRectangle.Rotation); var line = new Line(basee, direction); return line.CollidesWith(lr); }
public bool CollidesWith(OrientedRectangle orientedRectangle) { Rectangle lr = orientedRectangle.TransformToLocalRectangle(); IVector2D point1 = Point1.Substract(orientedRectangle.Center); point1 = point1.Rotate(-orientedRectangle.Rotation); point1 = point1.Add(orientedRectangle.HalfExtend); IVector2D point2 = Point2.Substract(orientedRectangle.Center); point2 = point2.Rotate(-orientedRectangle.Rotation); point2 = point2.Add(orientedRectangle.HalfExtend); var ls = new LineSegment(point1, point2); return lr.CollidesWith(ls); }
public bool CollidesWith(OrientedRectangle orientedRectangle) { Rectangle localRectangle = orientedRectangle.TransformToLocalRectangle(); IVector2D distance = Center.Substract(orientedRectangle.Center); distance = distance.Rotate(-orientedRectangle.Rotation); var localCenter = distance.Add(orientedRectangle.HalfExtend); var localCircle = new Circle(localCenter, Radius); return localCircle.CollidesWith(localRectangle); }