Tuesday 15 February 2011

c# - Finding the intersection of a line -


So I'm beating my head on this relatively simple algorithm. I'm not sure what's wrong with my code, I still can not find the point of intersection where they are actually intersecting.

I am using Unity 3D and I am trying to find the point where two rows give each other a holes, in X, z aircraft, though not in X, Y plane. I'm assuming that the algorithm that works for X, y should work for X, Z.;

My code:

  Vector3 thisPoint1 = thisCar.position + (2 * thisCar.); Vector 3 This Point 2 = The Carbatition + (20 * Corporation); Debug. Drone (this point 1, this page 2, color. White, 2); Vector 3 Other Point 1 = Threatened Carbation + (2 * Threatened Forward); Vector 3 Other Point 2 = Threatening Kirsh. + (20 * Threatening Cor.); Debug. Drainline (other page 1, other page 2, color. White, 2); Float A1 = thisPoint2.z - thisPoint1.z; Float b1 = this point 1.x - this point 2.x; Float C1 = A1 * thisPoint1.x + B1 * thisPoint1.z; Float A2 = other point 2.z - other point 1.z; Float b2 = other point 1.x - other point 2.x; Float C2 = A2 * other point 1.z + b2 * other point 1.z; Float date = A1 * b2 - a2 * b1; Float x = (b2 * c1 - b1 * c2) / et; Float z = (A1 * C2 - A2 * C1) / et; Return new vector 3 (x, this.Tansform.bizai.a., z);   

Is anyone telling me what I am doing wrong?

Thanks in advance

================================ =========================

This car Further and Threats CAR.forward usually [0,0,1], [0,0, -1] or [1,0,0], [-1,0,0]

You can clear the parents object in the game car and put it forward in front of it (in IDE or at the beginning ). In this way you can securely draw two points to draw a line.

No comments:

Post a Comment