Search code examples
algorithmmathcartesian-coordinates

How do I find all points of an isosceles triangle given the vertex point, base midpoint, and base width?


I'm trying to make a properly-rotated isosceles triangle. I have the following data:

  • The (x, y) coordinates of the vertex point, A
  • The (x, y) coordinates of the midpoint of the base, am
  • The width of the base, a

And I need to find the coordinates of the other two points, B and C. What is an algorithm for finding these last two points with only the above information? Searching Google just got me a lot of equations that assume it's pointed directly up, but I need these to be placed before a transformation is performed.

An isosceles triangle rotated so that the vertex (labeled with a blue capital A) is in the lower-left and the base (labeled with a red lower-case a) is on the upper-right. The base is bisected by its midpoint (labeled by a green a with a subscript m). The other two points are labeled with a purple capital B and an orange capital C, respectively.


Solution

  • To find B and C:

    1. find the normalized direction vector a_mA = (A - a_m)/|A - a_m|
    2. find a vector orthogonal to the vector a_mA – let's call it a_mA'
      • a_mA' = (-a_mA.y, a_mA.x)
    3. to find B, step width/2 units in the direction of a_mA' and add a_m:
      • B = (width/2)*a_mA' + a_m
    4. to find C, step -width/2 units in the direction of a_mA' and add a_m:
      • C = (-width/2)*a_mA' + a_m

    JsFiddle example: https://jsfiddle.net/asq7h2jd/