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 301111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:58:32+00:00 2026-05-12T06:58:32+00:00

I have 4 points that form some quadrilateral. The lines can’t cross or anything

  • 0

I have 4 points that form some quadrilateral. The lines can’t cross or anything like that, it should be a square, rectangle, rhombus, parallelogram, etc.

The lines that connect them break the field into 9 regions. With a square, it would look like a tic-tac-toe board (#), but with other shapes the lines will be at angles.

A point falls randomly into this 9-region field. I know the coordinates of the random point, as well as the coordinates of the quadrilateral’s 4 corners.

Is there any way I can find which field contains the point without using the equations of the lines?

I’m basically looking for something like

if(p.x > q1.x && p.x < q4.x && p.y < q3.y) {
    //It's in the top left region
}
etc

I’m thinking that this isn’t possible when using sloped lines (rather than a square/rectangle) without solving the line equations. But I thought I’d run it by the math guys first. THANKS!

  • 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-12T06:58:33+00:00Added an answer on May 12, 2026 at 6:58 am

    Anything you do is effectively “using the equations of the lines”, so I’m not sure what to make of that condition. I assume you just want easy inequalities to check which region the random point (x,y) is in, so that’s what I’ll show you how to do.

    From your question, it sounds like you always have a parallelogram, so let’s assume that the points are (0,0), (a,b), (c,d), and (a+c,b+d), which makes the explanation a little easier to follow. To fix your mental picture, imagine that (a,b) is roughly “to the right” of (0,0) and (c,d) is roughly “above” (0,0). Then the equations for the “horizontal” lines are -bx+ay=0 and -bx+ay=-bc+ad, so you get three possibilities, depending on how -bx+cy compares to 0 and -bc+ad:

    // Assuming -bc+ad is positive
    -bx+ay < 0           // it's in the "bottom row"
    0 < -bx+ay < -bc+ad // it's in the "middle row"
    -bc+ad < -bx+ay     // it's in the "top row"
    

    Similarly, the equations for the “vertical” lines are dx-cy=0 and dx-cy=da-bc, so the three possibilities, depending on how dx-cy compares to 0 and to da-cb:

    // Still assuming ad-bc is positive
    dx-cy < 0           // it's in the "left column"
    0 < dx-cy < da-cb  // it's in the "middle column"
    da-cb < dx-cy      // it's in the "right column"
    

    Of course, if da-cb is negative, then the three possibilities in each case are “less than da-cb“, “between da-cb and 0“, and “greater than 0” instead. Finally, if equality ever holds, then the point (x,y) is actually on one of the lines rather than in one of the regions.

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

Sidebar

Related Questions

I have 3 points ( lat , lon ) that form a triangle.How can
Supose I have a matrix. This matrix is blank except some points that create
I have a boost::posix_time::ptime that points to March 31st 2010 like this: ptime p(date(2010,
I have data in the form of a 2D array of intensities that should
I have some 9000 points that are plotted on a graph: [ Full resolution
I have a script (worker.py) that prints unbuffered output in the form... 1 2
I have a set of points that i want to turn into a closed
I have different urls that points to the same code www.url1.com www.url2.com I need
Suppose that I have n points (x,y1),(x2,y2),.....(xn,yn) my aim is to connect these points
I have a custom validator that points to a Client side script to validate

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.