I am using this bit of code with a method provided by the wiki - but it gives the wrong intersection point.
public Vector3 A = new Vector3(15,0,5);
public Vector3 B = new Vector3(15,0,10);
public Vector3 C = new Vector3(10,0,8);
public Vector3 D = new Vector3(20,0,8);
public Vector3 intersectPoint;
private void Update()
{
Debug.Log(Maths.LineLineIntersection(out intersectPoint, A, B, C, D));
}
The result gives True, but the intersection point is: (33.75, 0 , 17.5) which is obviously wrong.
That looks like the correct intersection point to me. Adding the direction vectors to the position vectors gives a very close value to both each other and the supposed intersection point.
Oh it takes a direction ? Ah i was supplying 4 points, 2 for each line to represent the line, is there a way to change it so it takes 4 points and not a direction.
I’m confused, so i need to supply the point of the line and the sum of the first and second point of the line ? For both lines… right?
Even if the lines don’t intersect i still get true. I’m fairly convinced its related to do the direction but not sure how to just input 4 points rather than a direction to make life easier.
Sorry for late reply but do you happen to know how to do it for line segments, i can only ever fine infinite line calculations which is driving me crazy.