Java: plot points based on distances

前端 未结 2 1716
我在风中等你
我在风中等你 2020-12-20 10:29

I need to plot a group of points based on distances. I have three unknown points X, Y, and Z. I then get another unknown point (A) and its distances from the originals (AX,

2条回答
  •  悲&欢浪女
    2020-12-20 10:38

    1. I assume you use 2D space

      If it is 1D then 2 points are enough (not identical !!!).

      If 2D then 3 distances is enough but the points used must not lay on the same line !!!

    2. position/orientation of the plot

      for relative plot are above conditions enough if you want also the exact orientation and position then you need to know exact position of first 3 points otherwise your plot will look the same but can be offseted,rotated and mirrored to original geometry.

      • knowing 1 point eliminates offset
      • knowing 2 point eliminates rotation
      • knowing 3 point eliminates mirroring

    [notes]

    you need n+1 points for n-D coordinate system

    [edit1] equations

    original question text did not contain any equations need but comments requires it so here are some:

    You will need intersection point between two hyperspheres (in 2D circles, in 3D spheres,...) so look here:

    • circle-circle intersection

    Cast circle from each point as center with radius equal to the distance from that point. Find out intersection point that is the same between all combinations of circles (0,1),(0,2),(1,2)

    example

    Yellow intersection is the same in all 3 combinations so that is the next point or for 2D just solve this system:

    (x-x0)^2+(y-y0)^2=l0^2
    (x-x1)^2+(y-y1)^2=l1^2
    (x-x2)^2+(y-y2)^2=l2^2
    

    where x,y is the intersection point, xi,yi are center of circle and li is distance from that point.

    The first option should be simpler and more accurate if done right but need some knowledge on vector and trigonometry math. You will need to add rotation or compute on vectors and use perpendicular vector feature in 2D

    V(x,y) -> V0(+y,-x),V1(-y,+x)
    

    where V0,V1 are perpendicular to V

提交回复
热议问题