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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:32:23+00:00 2026-06-03T18:32:23+00:00

I have 2 vectors, each defined by 2 Point3D (origin and direction). I need

  • 0

I have 2 vectors, each defined by 2 Point3D (origin and direction). I need to find out the point of their intersection.
A little bit of help is always welcome.
I will post my function, which gives me wrong output.

public static CurvIntersect3D Intersect2Linii3D (Vector3D dr1, Vector3D dr2) {
    CurvIntersect3D result = new CurvIntersect3D(0, null);

    double x = Math3D.VectorNorm3D(dr1.getDirectie());
    double t = Math3D.VectorNorm3D(dr2.getDirectie());
    double cosa = (dr1.getDirectie().getX()*dr2.getDirectie().getX() + dr1.getDirectie().getY()*dr2.getDirectie().getY() + dr1.getDirectie().getZ()*dr2.getDirectie().getZ()) / (t*x);
    Punct3D p1 = dr1.getOrigine();
    Punct3D p2 = new Punct3D(), p3 = new Punct3D();
    for (int i=0; i<3; i++)
    {
        p2.set(i, dr1.getOrigine().get(i) + dr1.getDirectie().get(i));
        p3.set(i, dr1.getOrigine().get(i) + dr2.getDirectie().get(i));
    }

    Matrici.Matrice3x3 rot = Math3D.GetMatriceRotatie(p1, p2, p3);
    Punct3D orig = new Punct3D();
    for (int i=0; i<3; i++)
        orig.set(i, rot.getElement(i, 0) * (dr2.getOrigine().getX()-dr1.getOrigine().getX()) +
                    rot.getElement(i, 1) * (dr2.getOrigine().getY()-dr1.getOrigine().getY()) +
                    rot.getElement(i, 2) * (dr2.getOrigine().getZ()-dr1.getOrigine().getZ()));

    x = orig.getY() - orig.getZ()* cosa / Math.sqrt(1 - cosa*cosa);
    p1 = new Punct3D();
    for (int i=0; i<3; i++)
        p1.set(i, dr1.getOrigine().get(i) + x*dr1.getDirectie().get(i));
    result.setCount(1);
    result.add(p1);
    return result;
}

CurvIntersec3D is a structure that stores the array of points and its length.

  • 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-06-03T18:32:25+00:00Added an answer on June 3, 2026 at 6:32 pm

    As mentioned before the two lines may not meet at a single point. The best you can do in general is find the point on line1 closest to line2 and vise versa. Connect those two points to create the common normal direction.

    Given two lines passing through 3D points r1=[r1x,r1y,r1z] and r2=[r2x,r2y,r2z] and having unit directions e1=[e1x,e1y,e1z] and e2=[e2x,e2y,e2z] you can find the points on the line which are closest to the other line like this:

    1. Find the direction projection u=Dot(e1,e2)=e1x*e2x+e1y*e2y+e1z*e2z
    2. If u==1 then lines are parallel. No intersection exists.
    3. Find the separation projections t1=Dot(r2-r1,e1) and t2=Dot(r2-r1,e2)
    4. Find distance along line1 d1 = (t1-u*t2)/(1-u*u)
    5. Find distance along line2 d2 = (t2-u*t1)/(u*u-1)
    6. Find the point on line1 p1=Add(r1,Scale(d1,e1))
    7. Find the point on line2 p2=Add(r2,Scale(d2,e2))

    Note: You must have the directions as unit vectors, Dot(e1,e1)=1 and Dot(e2,e2)=1.
    The function Dot() is the vector dot product. The function Add() adds the components of vectors, and the function Scale() multiplies the components of the vector with a number.

    Good luck.

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

Sidebar

Related Questions

Context I have a matrix comprising of a sequence of column vectors. Each column
Assume I have a camera defined by its position and direction, and a box
In my little scratch built flex game framework, I have defined a class called
I have a vector of Linked list pointers. Each LinkedList has a head pointer
I would like to have an array (or a vector) and at each position
I have a C++ std::vector denoted as: std::vector<GameObject*> vectorToSort; Each object in vectorToSort contains
What I have: Vectors of different custom structs(one custom struct per vector) I used
I have three vectors in an xts R object. Call them V1, V2, V3.
I have a vectors of strings, say c(E^A,S^P,lambda,T,E^Q,E^Q,AT) , and I want to plot
I have two vectors, and I would like to fill the first one with

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.