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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:27:54+00:00 2026-05-25T17:27:54+00:00

Suppose you have have a rectangle, bottom-left point 0,0 and upper-right point is 100,100.

  • 0

Suppose you have have a rectangle, bottom-left point 0,0 and upper-right point is 100,100.
Now two line intersects the rectangle. I have to find out the coordinate of the intersection point. I have done that. Now the problem is I can’t tell whether it is inside the rectangle or not. I used double comparison. But I think it is giving me wrong answer. Suppose the intersection point is ( x , y ). I used this checking for comparison : if( x >= 0.0 && x <= 100.0 && y >= 0.0 && y <= 100.0 ). What should I do?

//this function generates line
line genline( int x1 , int y1 , int x2 , int y2 ){
    line l ;
    l.A = y2 - y1 ;
    l.B = x1 - x2 ;
    l.C = l.A * x1 + l.B * y1 ;
    return l ;
}
//this function checks intersection
bool intersect( line m ,line n ) {
    int det = m.A * n.B - m.B * n.A ;
    if( det == 0 ){
        return false ;
    }
    else {
        double x = ( n.B * m.C - m.B * n.C ) / ( det * 1.0 ) ;
        double y = ( m.A * n.C - n.A * m.C ) / ( det * 1.0 ) ;        
        if( x >= 0.0 && x <= L && y >= 0.0 && y <= W ) { return true ; }
        else{ return false ; }
    }
}

EDIT:
Both the line are stretched to infinity.

  • 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-25T17:27:55+00:00Added an answer on May 25, 2026 at 5:27 pm

    Your math looks like it’s right. By the way, If a line intersects something, it is always inside that something.

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

Sidebar

Related Questions

Generate a random point within a rectangle (uniformly) This suppose to be a simple
Suppose I have a simple WPF 3D scene set up with a single rectangle
Suppose I have PathGeometry , consisting of lines , like this (the rectangle ==
I have two methods that draw a rotated rectangle on the screen. RenderMethod1 renders
Suppose i have following code Rectangle rect = new Rectangle(); lock(rect) { ---- ---
Suppose I have: public class foobar { public int lorem; public int ipsum; }
Suppose we have the following table data: ID parent stage submitted 1 1 1
Suppose I have an IEnumerable such as a List(TValue) and I want to keep
Suppose I have string Name and Image Photo as properties of a class in
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input

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.