Issue
I've been trying to get all possible coordinate for a circle in a 3 dimensional space. If only 2 points values given as [x1,y1,z1] and [x2,y2,z2] and the distance from each point is r1 and r2, How can i get the path?
src="https://i.stack.imgur.com/rWKrJ.png" alt="enter image description here">
I used
int radius =100;
for(int x= -radius; x<=radius; x++ ){
int sliceDistance = (int) Math.round(Math.sqrt(Math.pow(radius, 2) - Math.pow(x, 2)));
for(int y= -sliceDistance; y<=sliceDistance; y++){
int z = (int)Math.round(Math.sqrt(Math.pow(radius,2)-Math.pow(y,2)-Math.pow(x,2)));
System.out.println(""+x+":"+y+":"+z);
if(z!=0){
System.out.println(""+x+":"+y+":"+(-z));
}
}
}
to get all the possible values for a sphere in a 3D space given the radius.But have no idea how to get the circle in a 3D space.
Solution
This circle is the set S of all 3D points (x,y,z) which satisfy the
equations of both spheres. The equations of the 2 spheres are known:
(x-x1)^2 + (y-y1)^2 + (z-z1)^2 = r1 ^ 2
(x-x2)^2 + (y-y2)^2 + (z-z2)^2 = r2 ^ 2
So you have to somehow "solve" this system of 2 equations i.e.
find somehow all (x,y,z) satisfying both equations.
Google for "intersection of two spheres" to start with.
This looks quite good: Link
Answered By - peter.petrov
Answer Checked By - Willingham (JavaFixing Volunteer)