Пример #1
0
        private Rectangle ToDisplayRect(IScenarioMember obj, Rectangle rect)
        {
            PointF center       = obj.GetPosition();
            Point  centerRender = CoordinatesToDisplayPoint(center.X, center.Y, rect);

            int width  = (int)((float)rect.Width * obj.GetRadius() / (HorizontalUnitsVisible / 2.0f));
            int height = (int)((float)rect.Height * obj.GetRadius() / (VerticalUnitsVisible / 2.0f));

            return(new Rectangle(centerRender.X - (width / 2), centerRender.Y - (height / 2), width, height));
        }
Пример #2
0
        private bool HitTest(IScenarioMember member, PointF simpt)
        {
            var simposition = member.GetPosition();

            float dx = simpt.X - simposition.X;
            float dy = simpt.Y - simposition.Y;

            float distanceSq = dx * dx + dy * dy;

            return(distanceSq <= member.GetRadius() * member.GetRadius());
        }