> say i have two points a and b in 3-d space, and their > distance is less than or equal to a constant d. i > want to find a third point that's exactly d distance > away from both a and b. i want to pick one of the > possible points at random, using a function that > returns a random real between 2 reals. also, i want > the result to be within a certain box, so if a and b > happen to be close to a side of the box then the > possible solutions have to be restricted, i'd imagine > by calculating a special max and min as the reals for > the random number function. i tried doing this > myself (sans the box part), and it didn't seem to > work.
The "equidistant" point is on a circle in the plane perpendicular to the line between the two given points and containing its midpoint. In particular, if you are given the points as (x0,y0,z0) and (x1,y1,z1) then the midpoint of the line between them, and so the center of the circle, is at (x2, y2, z2)= ((x0+x1)/2, (y0+y1)/2, (z0+z1)/2). Since the line between them is perpendicular to the plane, the equation of the plane is (x1-x0)(x- x2)+ (y1-y0)(y- y2)+ (z1-z0)(z- z2)= 0. Finally, if the distance between is D and you want the the "equidistant point" to be at distance d (with D< d) then the radius of the circle of those points will be given by R^2= d^2- D^2. The sphere with center at (x2,y2,z2) and that radius is (x-x2)^2+ (y-y2)^2+ (z-z2)^2= R^2. Solve the equation of the plane above for z-z2 and substitute into the equation of the sphere to get one equation for the circle.