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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:48:30+00:00 2026-05-21T04:48:30+00:00

i want to compute intersection line, given by 2 planes. my main program gives

  • 0

i want to compute intersection line, given by 2 planes. my main program gives me, plane parameters a,b,-1,d (my equation is ax+by-z+d=0). so, my function for computing equation of intersection line is as;

vector<double> LineofIntersection(vector<double> plane1,vector<double> plane2) {
     double a1=plane1.at(0);    double a2=plane2.at(0);
     double b1=plane1.at(1);    double b2=plane2.at(1);
     double d1=plane1.at(2);    double d2=plane2.at(2);
     int c1=-1,c2=-1;
     double cros_x=fabs((b1*c2)-(b2*c1));
     double cros_y=fabs((a2*c1)-(a1*c2));
     double cros_z=fabs((a1*b2)-(a2*b1));
     vector <double> point; vector <double> pointout;

     int maxc;   // max coordinate
     if (cros_x > cros_y){
        if (cros_x > cros_z)
             maxc = 1;
        else maxc = 3;
        }
     else {
        if (cros_y > cros_z)
             maxc = 2;
        else maxc = 3;
        }
     //
     vector <double> point; vector <double> pointout;
     switch (maxc) {  // select max coordinate          
     case 1: // intersect with x=0                   
        point.at(0)=0;
        point.at(1)=(d2-d1)/(b2-b1);
        point.at(2)=(b1*d2-2*b1*d1+d1*b2)/(b2-b1);
        break;
     case 2: // intersect with y=0                   
        point.at(0)=(d2-d1)/(a1-a2);
        point.at(1)=0;
        point.at(2)=(a1*d2-a2*d1)/(a1-a2);
        break;
     case 3: // intersect with z=0                   
        point.at(0)=(b1*d2-b2*d1)/(a1*b2-a2*b1);
        point.at(1)=(a2*d1-a1*d2)/(a1*b2-a2*b1);
        point.at(2)=0;
        break;
     }   
     pointout.push_back(point.at(0));
     pointout.push_back(point.at(1));
     pointout.push_back(point.at(2));
     return pointout;
}

in the main program, i call this function as:

vector<double> linep=LineofIntersection(plane1,plane2);
cout<<linep.at(1)<<" "<<linep.at(1)<<" "<<linep.at(2);

but, i got error message and cannot run the program. any help please.

  • 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-21T04:48:31+00:00Added an answer on May 21, 2026 at 4:48 am

    Fundementally, your problem is that you are assigning to locations in the point vector without first allocating them. Additionally, pointout serves no purpose, and you have a syntax error. Here are my recommendations:

     vector <double> point; vector <double> pointout;
    

    This line appears twice. Delete the line the first time it appears, and replace the second instance with:

    vector <double> point(3);
    

    Notice the (3). Without it, point is an empty vector, i.e. it has no doubles in it at all. With it, it has 3 doubles.

    The pointout object serves no purpose. Replace these two lines:

    pointout.push_back(point.at(0));pointout.push_back(point.at(1));pointout.push_back(point.at(2));
    return pointout;
    

    with this line:

    return point; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to geometrically compute the intersection points of a line and
I want (barely computer literate) people to easily submit a large number of files
I want to index a computed column in my database table which uses a
I want to verify if a computer is running .net 3.5 or 3.5 sp1,
I want to create a persisted computed column in a table so that I
I want to be able to detect when a computer connects to a network.
Basically I want to make sure I will always get the computer's name rather
You and I want to be the expert on computer programming or website design,
I've computed the mean & variance of a set of values, and I want
Using C#, I want to get the total amount of RAM that my computer

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.