Search code examples
geometrycomputational-geometrytriangulationgeometry-surfacetriangular

Find third point with circumcenter and two points of a triangle


How to calculate the third point of the isosceles triangle using JAVA, given its two points and the circumcenter. There will be two solutions for this, and it is sufficient for me if I get the shortest one from the points A and B.


Solution

  • If AB is the base of isosceles triangle (AC=BC), then solution is rather simple.

    Given points A, B, CC (circumcenter)

    Circumradius is

     R = Length(CC-A) = Sqrt((CC.X - A.X)^2 + (CC.Y - A.Y)^2)
    

    Edit: changed direction vector calculation to avoid ambiguity:

    Middle point of AB

     M = ((A.X + B.X)/2, (A.Y + B.Y)/2)
    

    Direction vector from CC to vertice C

    D = (CC.X - M.X, CC.Y - M.Y)
    

    Normalized (unit) direction vector

    uD = (D.X / Length(D), D.Y / Length(D))
    

    Vertice C coordinates

    C = (CC.X + R * uD.X, CC.Y + R * uD.Y)