# calculate x en z when y = 0 (line intersection)

This topic is 4643 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a line-segment in 3d space. pntA and pntB. I have a pntC somewhere on this line-segment where i know that the y of this pnt is 0. how would i calculate the x and z for pntC!? I know its easy :(

##### Share on other sites
This is what I would do.
First I would search the direction vector assuming A(x1,y1,z1) and B(x2,y2,z2)
vec(x2-x1,y2-y1,z2-z1)
Then the line is defined as followed:
x=A.x+t*vec.x
y=A.y+t*vec.y
z=A.z+t*vec.z

Now, you know y = 0 so
0=A.y+t*vec.y
you can easily get t from this.
t=-A.y/vec.y
then when you get this value you can fill it in in the previous:
x= ...
z= ...

Not sure if it's correct but you can check it with some test values.

##### Share on other sites
I always forget to log in :p
If you have any questions just contact me.

##### Share on other sites
You can just interpolate. Since its a line its linear with respect to its change along all axis. So if:
A = (-1,-1,-1)
B = (1,1,1)

And you are looking for the x and z values when y = 0

Since it is linear
x = 0
z = 0

This is as long as you have a line and not a curve, if you have a curve you will need an equation

##### Share on other sites
Thanks laurensvd it worked, i owe you one :D

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633325
• Total Posts
3011372
• ### Who's Online (See full list)

There are no registered users currently online

×