Monday, 15 February 2010

math - In 3D space, how do I calculate a point at a certain height, that is linear with 2 other known points? -


background

I'm working on a 3D game, where I need to move my mouse-input to a certain height in the 3D world, so I can move one unit to a single surface

This sloping camera (45 degrees tilted) ) From the perspective of the PlayKenvas API provides me with a function on my camera, which is 2D My mouse input on the screen can be translated by using the set depth in the 3D world.

When I set my depth to 0, I get the exact coordinates of my camera (which is in this case (08080), and if I set the depth to 100 then I ( ~ 0.09, 11.52, 7.06) ...

I would like to have a way to remove the coordinates where the boundary between two points hits the height (y-axis 2), or a path to me Can get

to which I have a clue:

I have 2 coordinates 3d space: let's go I have to figure out how to calculate a third point, where y is equal to 2. This point is

Any suggestion for how I can get it? I'm probably looking for solutions with some calculations.

One way to do this is to write a family of equations that describe all the points of space which is called P1 And are collinear with P2.

  x = x1 * t + x2 * (1-t) y = y1 * t + y2 * (1-t) z = z1 * T + z2 * (1-t)  

... where x1, y1, z1, coordinates of p1, ditto for p2 and t no actual the number is.

We can find our special coordinates by solving the solution for t and we want to know that y = 2, so we will rearrange that equation.

  y = y1 * t + y2 - y2 * ty - y2 = y1 * t - y2 * ty - y2 = (y1 - y2) * t (y - y2) / (y1 - Y2) = tt = (y - y2) / (y1 - y2)  

Now when you know t, you get it in your two remaining equations to get your X and Z values plug up.


No comments:

Post a Comment