Original Post
Having a straight segment S which goes form the point p0 to p1, a point p and the distance d, how can get the point on S which dists d from p?!?
Quote:I think that's what Zipster was saying: the point(s) on a segment that are a given distance from a point are the same as the points of intersection between the segment and a circle/sphere with the point as its center. Is that not what you're looking for?
Original post by xissburg
no it isn't that :P
I want to know the point on S which dists d from p, not the distance between S and p......
Quote:No, no, no! Don't use that method! It's practically useless in a game context due to the degeneracies and lack of generality. You do have the right idea about plugging the line equation into the circle/sphere equation; just use the parametric form for the line instead.
Original post by KidWithTheSquid
Just to expand a bit on what the other two folks have said - let's see it in 2-D.
Your equation for a line is trusty ol:
y = mx + b (where m is ( ( p1y - p0y ) / ( p1x - p0x ))
Quote:That's another reason to use the parametric form: it's exactly the same in 2d and 3d, so you can use (almost) exactly the same code for line-circle and line-sphere intersections.
In three dimensions, the equation for a line gets a little bit more complicated.
Quote:
Original post by jyk
You do have the right idea about plugging the line equation into the circle/sphere equation; just use the parametric form for the line instead.
Quote:Yup :)
Original post by xissburg
Are you talking about catch the parametric equation for the line ( p(s) = p0 + s*(p1-p0) ) and plug with the sphere equation ( (x - px)^2 + (y - py)^2 + (z - pz)^2 = d^2) ?!?
Quote:Break the parameteric equation into its "components" (x,y,z)
Original post by xissburg
Are you talking about catch the parametric equation for the line ( p(s) = p0 + s*(p1-p0) ) and plug with the sphere equation ( (x - px)^2 + (y - py)^2 + (z - pz)^2 = d^2) ?!?
Quote:Substitute x,y & z in the sphere equation for these.
c(s).x = A.x + s*(B.x-A.x)
c(s).y = A.y + s*(B.y-A.y)
c(s).z = A.z + s*(B.z-A.z)
Quote:
Original post by jyk Quote:No, no, no! Don't use that method! It's practically useless in a game context due to the degeneracies and lack of generality. You do have the right idea about plugging the line equation into the circle/sphere equation; just use the parametric form for the line instead.
Original post by KidWithTheSquid
Just to expand a bit on what the other two folks have said - let's see it in 2-D.
Your equation for a line is trusty ol:
y = mx + b (where m is ( ( p1y - p0y ) / ( p1x - p0x ))
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more