docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a triangle analyzer that calculates various properties of triangles using trigonometric functions.
Implement a triangle analysis system that:
The system should validate inputs and handle edge cases such as impossible triangles.
/**
* Analyzes a triangle and computes all properties.
*
* @param {Object} input - Triangle definition
* @param {Object} input.sides - Triangle sides (optional)
* @param {number} input.sides.a - Length of side a
* @param {number} input.sides.b - Length of side b
* @param {number} input.sides.c - Length of side c
* @param {Object} input.angles - Triangle angles (optional)
* @param {number} input.angles.A - Angle A (opposite to side a)
* @param {number} input.angles.B - Angle B (opposite to side b)
* @param {number} input.angles.C - Angle C (opposite to side c)
* @param {string} input.angleUnit - Unit for angles: 'degrees' or 'radians' (default: 'degrees')
* @returns {Object} Triangle properties
* @returns {Object} return.sides - All three sides {a, b, c}
* @returns {Object} return.angles - All three angles in the input unit {A, B, C}
* @returns {number} return.area - Triangle area
* @returns {boolean} return.valid - Whether the triangle is valid
* @throws {Error} If insufficient data provided to determine the triangle
*/
function analyzeTriangle(input);
module.exports = { analyzeTriangle };Provides trigonometric and inverse trigonometric functions for triangle calculations.