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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:11:44+00:00 2026-05-30T00:11:44+00:00

We have 2 lines (A and B – see picture below). Line A starts

  • 0

We have 2 lines (A and B – see picture below). Line A starts at p1 and ends at p2 Line B starts at p3 and ends at p4.

Point p5 is the point that line A intersects line B if extended.

How do I find out the distance between p2 and p5?

EDIT:
To be more clear, how do I find point p5?

Best Regards!

  • 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-30T00:11:46+00:00Added an answer on May 30, 2026 at 12:11 am

    Get the intersection by

    // each pair of points decides a line
    // return their intersection point
    Point intersection(const Point& l11, const Point& l12, const Point& l21, const Point& l22)
    {
      double a1 = l12.y-l11.y, b1 = l11.x-l12.x;
      double c1 = a1*l11.x + b1*l11.y;
      double a2 = l22.y-l21.y, b2 = l21.x-l22.x;
      double c2 = a2*l21.x + b2*l21.y;
      double det = a1*b2-a2*b1;
      assert(fabs(det) > EPS);
      double x = (b2*c1-b1*c2)/det;
      double y = (a1*c2-a2*c1)/det;
    
      return Point(x,y);
    }
    
    // here is the point class
    class Point
    {
    public:
      double x;
      double y;
    public:
      Point(double xx, double yy)
        : x(xx), y(yy)
      {}
    
      double dist(const Point& p2) const 
      {
        return sqrt((x-p2.x)*(x-p2.x) + (y-p2.y)*(y-p2.y));
      }
    };
    

    Then you can just call p2.dist(p5) to get the distance.

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

Sidebar

Related Questions

i have 2 lines jquery. first line is adding event on myLink and second
Lets say I have 10 lines in a file. I have 2 parameters that
I have lines of data that looks like this: sp_A0A342_ATPB_COFAR_6_+_contigs_full.fasta sp_A0A342_ATPB_COFAR_9_-_contigs_full.fasta sp_A0A373_RK16_COFAR_10_-_contigs_full.fasta sp_A0A373_RK16_COFAR_8_+_contigs_full.fasta sp_A0A4W3_SPEA_GEOSL_15_-_contigs_full.fasta
I have lines of data that contain single column and two columns. What I
I am writing a code generation tool that frequently will have lines like StringBuilder
For example, if ı have lines like this: $this->db->where(blabla,$blala); And following this line, I
I have a SQL*Loader control file that has a line something like this: FIELDS
I have multiple lines of texts in a text file that look similar to
In clojure I have lines like this that define default values: (def *http-port* 8080)
I am developing a circular chart that will have lines that move around it

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.