Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6250845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:30:17+00:00 2026-05-24T13:30:17+00:00

I have a problem finding out if two PolyLines intersect. Well the main objective

  • 0

I have a problem finding out if two PolyLines intersect.

Well the main objective is to compare last X and Y with the other PolyLine and find out if it’s colliding aka intersecting with it.

There are gaps in the data due moving the X and Y, so most of the time I can’t find the X and Y in the other PolyLine.

I think I should compare the visualtree or something and not the data itself, but I have no idea how to get do that.

<Canvas x:Name="LayoutRoot" Background="Black" Margin="2">
    <Polyline x:Name="player3line" Stroke="GreenYellow" StrokeThickness="4" Points="146,106 141,106 136,105 131,105 126,105 121,106 116,108 112,110 108,113 104,115 100,118 96,120 92,123 88,126 84,129 80,132 77,136 74,140 72,144 69,148 67,152 64,156 " />
    <Polyline x:Name="player4line" Stroke="Cyan" StrokeThickness="4" Points="85,113 89,116 93,119 97,121 102,123 107,124" />
</Canvas>

There must be an easy way to check if those two intersect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:30:19+00:00Added an answer on May 24, 2026 at 1:30 pm

    I figured i should search all coordinates around my point, since the stroke thickness is 4.

    So I figured I need to check from X-2 to X+2 and from Y-2 to Y+2.

    So I did this and amazingly it works for now, I admit it’s not perfect but it’s simple and for now I don’t see any CPU spikes with this method:

      private bool CheckCollision(Point centerPoint)
        {
            bool functionReturnValue = false;
    
            //wall collision
            if (centerPoint.X - 1 < 0
                || centerPoint.X + 1 > (int)LayoutRoot.ActualWidth
                || centerPoint.Y - 1 < 0
                || centerPoint.Y + 1 > (int)LayoutRoot.ActualHeight)
            {
                functionReturnValue = true;
            }
    
            //player collision
            if (!functionReturnValue)
            {
                foreach (var player in playerList) //all players are in this list
                {
                    for (int i = Convert.ToInt32(centerPoint.X - 2); i < centerPoint.X + 2; i++)
                    {
                        for (int j = Convert.ToInt32(centerPoint.Y - 2); j < centerPoint.Y + 2; j++)
                        {
                            var point = new Point() { X = i, Y = j };
                            if (player.CoordinatePoints.Contains(point))
                            {
                                functionReturnValue = true;
                                goto END;
                            }
                        }
                    }
                }
            }
            goto END;
    
         END:
            return functionReturnValue;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with finding out which children to add, update and delete
I have some trouble finding the right design solution for a problem of sharing
I have a problem with finding the current color under the cursor. My code:
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have problem when I try insert some data to Informix TEXT column via
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.