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

  • SEARCH
  • Home
  • 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 3483746
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:42:34+00:00 2026-05-18T10:42:34+00:00

I have two arrays of points: double[] minus and double[] plus , e.g.: double[]

  • 0

I have two arrays of points: double[] minus and double[] plus, e.g.:

double[] minus = new[]
{
    24.043414306636713,
    26.521399902043807,
    23.049167719142361,
    24.473177606966754,
    18.238281854192408,
};

double[] plus = new[]
{
    8.31219054269323,
    9.5909890877229582,
    11.066525870449567,
    22.769068312057193,
    24.733540360065991,
};

I need to plot 2 diagrams basing on this number and determine their positions relatively to each other: are there an intersection and which of them is under another?

How can I do that? TIA

(please feel free to retag the question or change the topic, I’m not sure in proper math terminology used)

Edit: Here’s an Excel diagram:

https://i.stack.imgur.com/NEhcs.png

It’s easy to determine which is above and which is under.

How to determine that red (plus) has an intersection with blue (minus)? Using maybe LINQ?

  • 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-18T10:42:35+00:00Added an answer on May 18, 2026 at 10:42 am

    This code can found all collisions:

    double[] minus = new double[]
    {
        3, 24, 26, 23, 25, 18, 5,  5,  1, 10,
    };
    double[] plus = new ![alt text][1]double[]
    {
        3,  8,  9, 11, 22, 25, 5,  5,  3, 7
    };
    
    var collisionsBetweenIndices =
    Enumerable.Range(1, minus.Length - 1)
              .Where(i => ((minus[i - 1] - plus[i - 1] < 0) && (minus[i] - plus[i] > 0)) ||
                          ((minus[i - 1] - plus[i - 1] > 0) && (minus[i] - plus[i] < 0)) ||
                          ((minus[i - 1] - plus[i - 1] == 0) && (minus[i] - plus[i] == 0)))
              .ToArray();
    
    var collisionsOnIndices =
    Enumerable.Range(0, minus.Length)
              .Where(i => minus[i] == plus[i])
              .ToArray();
    
    foreach (var idx in collisionsBetweenIndices)
        Console.WriteLine("Collision between {0} and {1}", idx - 1, idx);
    
    foreach (var idx in collisionsOnIndices)
        Console.WriteLine("Collision on {0}", idx);
    
    // RESULTS:
    // Collision between 4 and 5
    // Collision between 6 and 7
    // Collision between 8 and 9
    // Collision on 0
    // Collision on 6
    // Collision on 7
    

    alt text

    EDIT:

    I did two different methods to distinguish the type of collisions (i.e. between indices or on indices), but if your purpouse is just to detect if there’s a collision or not, just do the following:

    var collisionDetected =
    Enumerable.Range(0, minus.Length).Any(i =>
    {
        if (minus[i] == plus[i])
            return true;
        if (i > 0 &&
            (((minus[i - 1] - plus[i - 1] < 0) && (minus[i] - plus[i] > 0)) ||
            ((minus[i - 1] - plus[i - 1] > 0) && (minus[i] - plus[i] < 0)) ||
            ((minus[i - 1] - plus[i - 1] == 0) && (minus[i] - plus[i] == 0))))
        {
            return true;
        }
        return false;
    });
    

    This code returns as soon as a collision is found, so it’s generally faster the the above methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays: String [] ids= new String [5]; String [] points= new
I have two 2D numpy arrays - real r , which contains points in
I have two two-by-n arrays, representing 2d-points. These two arrays are plotted in the
I have two questions: 1) How can I make an array which points to
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two arrays. One contains id=>count and the other contains id=>name . I'm
I have two arrays containing the same elements, but in different orders, and I
I have two arrays in PHP. The first array ($author_array) is comprised of user_ids
I have two arrays built while parsing a text file. The first contains the

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.