{
  "id": "right-triangle",
  "version": "3f71d5951955",
  "status": "published",
  "name": "Right Triangle Calculator",
  "question": "How do I solve my right triangle?",
  "summary": "Solves a right triangle from any two sides, or a side and an angle: all three sides, both acute angles, the area, the perimeter, and the height.",
  "category": "math",
  "subcategory": "geometry",
  "url": "https://www.acalculator.org/math/right-triangle-calculator",
  "markdown": "https://www.acalculator.org/math/right-triangle-calculator.md",
  "kind": "function",
  "method": "a² + b² = c², sin α = a ÷ c, cos α = b ÷ c, tan α = a ÷ b, and β = 90° − α.",
  "assumptions": [
    "The angle between legs a and b is 90°; α is opposite a and β is opposite b.",
    "Enter two of a, b, c and α. To start from β, enter it as α and swap the names of the legs.",
    "Sides are more than 0, in one unit; α is more than 0° and less than 90°. A third value must fit the first two."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "a": {
        "title": "Leg a",
        "description": "The side opposite angle α; it meets leg b at the right angle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "b": {
        "title": "Leg b",
        "description": "The side opposite angle β; it meets leg a at the right angle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "c": {
        "title": "Hypotenuse c",
        "description": "The longest side, opposite the right angle.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "alpha": {
        "title": "Angle α",
        "description": "The acute angle opposite leg a, between leg b and the hypotenuse.",
        "type": [
          "number",
          "string"
        ],
        "x-quantity": "angle",
        "exclusiveMinimum": 0,
        "exclusiveMaximum": 1.5707963267948966
      }
    }
  },
  "outputs": {
    "hypotenuse": {
      "label": "Hypotenuse c",
      "description": "The longest side, opposite the right angle.",
      "format": "number"
    },
    "legA": {
      "label": "Leg a",
      "description": "The side opposite angle α.",
      "format": "number"
    },
    "legB": {
      "label": "Leg b",
      "description": "The side opposite angle β.",
      "format": "number"
    },
    "angleA": {
      "label": "Angle α",
      "description": "The acute angle opposite leg a.",
      "format": "quantity",
      "unit": "deg"
    },
    "angleB": {
      "label": "Angle β",
      "description": "The acute angle opposite leg b: 90° − α.",
      "format": "quantity",
      "unit": "deg"
    },
    "area": {
      "label": "Area",
      "description": "Half the product of the legs: a × b ÷ 2.",
      "format": "number"
    },
    "perimeter": {
      "label": "Perimeter",
      "description": "The three sides added: a + b + c.",
      "format": "number"
    },
    "height": {
      "label": "Height to the hypotenuse",
      "description": "The distance from the right angle to the hypotenuse: a × b ÷ c.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "a": 3,
      "b": 4
    },
    "outputs": {
      "hypotenuse": 5,
      "legA": 3,
      "legB": 4,
      "angleA": 0.6435011087932844,
      "angleB": 0.9272952180016122,
      "area": 6,
      "perimeter": 12,
      "height": 2.4
    },
    "text": "A right triangle with legs 3 and 4 has a hypotenuse of 5 and angles of 36.869898° and 53.130102°."
  },
  "examples": [
    {
      "given": {
        "a": 3,
        "b": 4
      },
      "expect": {
        "hypotenuse": 5,
        "angleA": 0.6435011087932844,
        "angleB": 0.9272952180016122,
        "area": 6,
        "perimeter": 12,
        "height": 2.4
      },
      "source": "hand calculation in content.mdx: c = √(9 + 16) = 5; α = atan(3/4); Python 3: math.atan2(3, 4) = 0.6435011087932844, math.pi/2 - math.atan2(3, 4) = 0.9272952180016122"
    },
    {
      "given": {
        "c": 10,
        "alpha": 0.5235987755982988
      },
      "expect": {
        "legA": 4.999999999999999,
        "legB": 8.660254037844387,
        "angleB": 1.0471975511965979,
        "area": 21.650635094610966
      },
      "source": "hand calculation in content.mdx: a = 10 × sin 30° = 5, b = 10 × cos 30° = 5√3; Python 3: 10*math.sin(math.pi/6) = 4.999999999999999, 10*math.cos(math.pi/6) = 8.660254037844387, math.pi/2 - math.pi/6 = 1.0471975511965979, a*b/2 = 21.650635094610966"
    },
    {
      "given": {
        "b": 12,
        "c": 13
      },
      "expect": {
        "legA": 5,
        "angleA": 0.3947911196997615,
        "perimeter": 30,
        "height": 4.615384615384615
      },
      "source": "hand calculation in content.mdx: a = √(169 − 144) = 5; Python 3: math.atan2(5, 12) = 0.3947911196997615, 5*12/13 = 4.615384615384615"
    },
    {
      "given": {
        "a": 7,
        "alpha": 0.7853981633974483
      },
      "expect": {
        "legB": 7.000000000000001,
        "hypotenuse": 9.899494936611665,
        "angleB": 0.7853981633974483,
        "area": 24.500000000000004
      },
      "source": "hand calculation in content.mdx: β = 90° − 45° = 45°, so b = a = 7 and c = 7√2; Python 3: 7/math.sin(math.pi/4) = 9.899494936611665, 7/math.tan(math.pi/4) = 7.000000000000001"
    },
    {
      "given": {
        "a": 3,
        "b": 4,
        "c": 5
      },
      "expect": {
        "hypotenuse": 5,
        "area": 6
      },
      "source": "hand calculation in content.mdx: 9 + 16 = 25, so all three sides fit"
    }
  ],
  "sources": [
    "OpenStax, Algebra and Trigonometry 2e, section 7.2 Right Triangle Trigonometry: https://openstax.org/books/algebra-and-trigonometry-2e/pages/7-2-right-triangle-trigonometry",
    "OpenStax, Elementary Algebra 2e, section 3.4 Solve Geometry Applications: Triangles, Rectangles, and the Pythagorean Theorem: https://openstax.org/books/elementary-algebra-2e/pages/3-4-solve-geometry-applications-triangles-rectangles-and-the-pythagorean-theorem"
  ],
  "related": [
    "pythagorean-theorem",
    "law-of-cosines",
    "area"
  ],
  "changelog": []
}
