Trigonometry is a branch of mathematics that studies relationships between side lengths and angles of triangles. The three primary trigonometric functions – sine (sin), cosine (cos), and tangent (tan) – are fundamental to this study and have widespread applications in physics, engineering, computer graphics, and many other fields. They are defined based on a right-angled triangle and can be extended to all angles using the unit circle.
The Right-Angled Triangle Definitions:
In a right-angled triangle, for an acute angle (θ):
Sine (sin θ): The ratio of the length of the side opposite the angle to the length of the hypotenuse. sin θ = Opposite / Hypotenuse
Cosine (cos θ): The ratio of the length of the side adjacent to the angle to the length of the hypotenuse. cos θ = Adjacent / Hypotenuse
Tangent (tan θ): The ratio of the length of the side opposite the angle to the length of the side adjacent to the angle. It can also be expressed as tan θ = sin θ / cos θ. tan θ = Opposite / Adjacent
The Unit Circle and General Angles:
Trigonometric functions can be extended to all real numbers (angles) using the unit circle. Imagine a circle with a radius of 1 centered at the origin of a Cartesian coordinate system. For any angle θ measured counterclockwise from the positive x-axis, the point where the terminal side of the angle intersects the unit circle has coordinates (x, y).
x = cos θ
y = sin θ
The tangent is still sin θ / cos θ (or y / x). This definition allows us to work with angles greater than 90 degrees, negative angles, and angles beyond a full rotation.
Units of Measurement: Degrees vs. Radians
Angles can be measured in two primary units:
Degrees (°): A full circle is 360°. A right angle is 90°.
Radians (rad): A full circle is 2π radians. A right angle is π/2 radians. Radians are often preferred in higher mathematics and calculus because they simplify many formulas. The conversion is: 180° = π radians.
This calculator allows you to specify whether your input angle is in degrees or radians, ensuring accurate calculations.
Applications:
Physics: Analyzing wave motion (sound, light, water), projectile motion, oscillations, and AC circuits.
Engineering: Designing structures, calculating forces, surveying, and signal processing.
Navigation: Determining positions and directions using angles.
Computer Graphics: Rotating objects, simulating movement, and creating realistic visuals.
Mathematics: Solving complex equations, calculus, and geometry.
function calculateTrig() {
var angleInput = document.getElementById("angleValue");
var unitSelect = document.getElementById("angleUnit");
var functionSelect = document.getElementById("trigFunction");
var resultValueDiv = document.getElementById("result-value");
var angleStr = angleInput.value;
var unit = unitSelect.value;
var trigFunction = functionSelect.value;
// Clear previous error messages
resultValueDiv.style.color = "#28a745";
resultValueDiv.innerHTML = "–";
// Input validation
if (angleStr === "") {
resultValueDiv.innerHTML = "Please enter an angle.";
resultValueDiv.style.color = "red";
return;
}
var angle = parseFloat(angleStr);
if (isNaN(angle)) {
resultValueDiv.innerHTML = "Invalid angle value.";
resultValueDiv.style.color = "red";
return;
}
var angleInRadians;
// Convert angle to radians if necessary
if (unit === "degrees") {
angleInRadians = angle * (Math.PI / 180);
} else { // radians
angleInRadians = angle;
}
var result;
// Perform calculation based on selected function
if (trigFunction === "sin") {
result = Math.sin(angleInRadians);
} else if (trigFunction === "cos") {
result = Math.cos(angleInRadians);
} else if (trigFunction === "tan") {
// Handle potential division by zero for tan(90°), tan(270°), etc.
// Cosine is 0 at these points. Check if the angle (in radians) is very close to (n * PI + PI/2)
var cosValue = Math.cos(angleInRadians);
if (Math.abs(cosValue) < 1e-10) { // Using a small tolerance for floating point comparison
result = "Undefined";
} else {
result = Math.tan(angleInRadians);
}
} else {
result = "Unknown function"; // Should not happen with current setup
}
// Display result
if (result === "Undefined") {
resultValueDiv.innerHTML = "Undefined";
resultValueDiv.style.color = "orange";
} else if (typeof result === 'number') {
// Format result to a reasonable number of decimal places
resultValueDiv.innerHTML = result.toFixed(6);
resultValueDiv.style.color = "#28a745"; // Success green
} else {
resultValueDiv.innerHTML = result;
resultValueDiv.style.color = "red";
}
}
function clearFields() {
document.getElementById("angleValue").value = "";
document.getElementById("angleUnit").value = "degrees";
document.getElementById("trigFunction").value = "sin";
document.getElementById("result-value").innerHTML = "–";
document.getElementById("result-value").style.color = "#28a745";
}