Degree ↔ Radian Conversion and the 6 Trig Functions on the Unit Circle

PublishedToolTrigonometric Ratio & Radian Converter

Contents
  1. Why You Keep Converting: People Use Degrees, Computers Use Radians
  2. Degree–Radian Conversion Formulas and the Six Trigonometric Function Definitions (Manual Calculation)
  3. Special Angles and Edge Cases That Trip People Up
  4. Summary
  5. Frequently Asked Questions

JavaScript trig functions like Math.sin() and Math.cos() take a radian value as their argument, not degrees. People, though, think in degrees (°), so every time you write code for a 2D canvas rotation or a game character's facing direction, you end up converting degrees to radians and back again.

This post covers those conversion formulas, the definitions of the six trigonometric functions including sin, cos, and tan, and the actual values of special angles like 30°, 45°, and 60°.

Summary ① Degrees (°) and radians (rad) convert to each other with a formula built on pi (π). ② sin, cos, and tan, plus their reciprocals csc, sec, and cot, are called the six trigonometric functions. ③ At angles like 90° and 270°, where the denominator becomes 0, the tan and sec values are undefined.

Why You Keep Converting: People Use Degrees, Computers Use Radians

Say you're building a character that looks toward the mouse cursor. You get the direction with Math.atan2(mouseY - charY, mouseX - charX). This function returns a radian value between -π and π regardless of the sign of the coordinates, but to show the angle on screen or match it against other calculations, you have to convert it back to degrees.

Do that conversion by hand every time and it's easy to apply the formula wrong, or to miss the spot where the math breaks at a particular angle like 90° or 270°.

Degree–Radian Conversion Formulas and the Six Trigonometric Function Definitions (Manual Calculation)

The conversion formulas between degrees and radians are defined with pi (π, about 3.14159) as follows.

  • Radians = degrees × (π ÷ 180)
  • Degrees = radians × (180 ÷ π)

For example, 90° is 90 × (π ÷ 180) ≈ 1.5708 radians.

Using the coordinates (x, y) on a unit circle with a radius of 1, the six trigonometric functions are defined as follows.

  • Sine (sin): sin θ = y (the ratio of height to the hypotenuse)
  • Cosine (cos): cos θ = x (the ratio of the base to the hypotenuse)
  • Tangent (tan): tan θ = y ÷ x = sin θ ÷ cos θ (where x ≠ 0)
  • Cosecant (csc): csc θ = 1 ÷ sin θ
  • Secant (sec): sec θ = 1 ÷ cos θ
  • Cotangent (cot): cot θ = 1 ÷ tan θ

Below is JavaScript code that computes the six trigonometric functions for an input angle in degrees.

function calculateTrigonometry(degreeVal) {
  // 1. Convert degrees -> radians
  const rad = degreeVal * (Math.PI / 180);

  // 2. Compute the six trigonometric functions
  const sin = Math.sin(rad);
  const cos = Math.cos(rad);
  const tan = Math.abs(cos) < 1e-10 ? Infinity : Math.tan(rad);

  const csc = Math.abs(sin) < 1e-10 ? Infinity : 1 / sin;
  const sec = Math.abs(cos) < 1e-10 ? Infinity : 1 / cos;
  const cot = Math.abs(tan) < 1e-10 ? Infinity : 1 / tan;

  return {
    degree: degreeVal,
    radian: rad.toFixed(6),
    sin: sin.toFixed(4),
    cos: cos.toFixed(4),
    tan: tan === Infinity ? "Undefined (∞)" : tan.toFixed(4),
    csc: csc === Infinity ? "Undefined (∞)" : csc.toFixed(4),
    sec: sec === Infinity ? "Undefined (∞)" : sec.toFixed(4),
    cot: cot === Infinity ? "Undefined (∞)" : cot.toFixed(4),
  };
}

Note You don't have to look up a trig table every time or switch your scientific calculator to radian mode by hand. Enter an angle into the Trigonometric Ratio & Radian Converter and you'll see the X and Y coordinates on the unit circle and the six trigonometric function values in a real-time SVG graphic.

You can work the formulas and code out yourself, but if you want to compare several angles quickly or see the unit circle coordinates with your own eyes, a calculator is faster. Check it with our tool.

Trigonometric Ratio & Radian Converter

Enter an angle and see its X, Y coordinates plotted on the unit circle, with live values for all six trig functions.

Special Angles and Edge Cases That Trip People Up

Special angles you use often, like 30°, 45°, and 60°, have exact fraction and surd values in addition to the decimal approximations.

Anglesincostan
30°1/2√3/2√3/3
45°√2/2√2/21
60°√3/21/2√3
90°10Undefined

At 90° or 270°, cos θ converges on 0, so tan θ = sin θ ÷ cos θ turns into division by zero. If your code doesn't filter that region ahead of time with an exception like "undefined," the Infinity value can show up on screen as-is or throw off later calculations.

Summary

  • JavaScript trig functions take radians, so an input angle in degrees has to be converted first with "radians = degrees × (π ÷ 180)".
  • sin, cos, and tan, plus their reciprocals csc, sec, and cot, are called the six trigonometric functions.
  • At angles like 90° and 270°, where cos θ or sin θ becomes 0, the tan, sec, csc, and cot values are undefined, so you need separate exception handling.
  • Special angles like 30°, 45°, and 60° have exact fraction and surd values, not just decimal approximations.

If you'd rather skip writing the math and edge-case handling yourself and just want to enter an angle to see the unit circle coordinates and the six trigonometric function values right away, use the tool below.

Trigonometric Ratio & Radian Converter

Enter an angle and see its X, Y coordinates plotted on the unit circle, with live values for all six trig functions.

Frequently Asked Questions

What is the special angle detection feature?

For whole-number angles used often in geometry or design work, such as 30, 45, and 60 degrees, it shows the exact trigonometric ratio as a rational fraction or a surd symbol (for example, √3 / 2) in addition to the decimal approximation.

Why do tangent or cosecant values show as "Undefined"?

Tangent is undefined at 90° and 270°, where cos θ = 0. Cosecant is undefined at 0°, 180°, and 360°, where sin θ = 0. In each case the denominator is 0, so the math can't be computed. The tool shows "Undefined (infinity)" in those ranges to prevent errors.

Can I enter radian values as fractions of pi?

Yes. Type a fraction that includes pi, like "pi / 4" or "pi / 6", right into the input field and it's recognized and calculated automatically.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. Dice Notation Explained: How to Read 2d6+3 and Roll d100Learn what 2d6+3 means, how d4-d20 and d100 percentile dice work, and how to add modifiers to get your final roll total.
  2. CPM vs. WPM: Why Your Typing Speed Numbers DifferSee why CPM and WPM give different numbers for the same typing run, with the exact formulas for both, plus why Korean characters count differently.
  3. What Your Browser Tells Websites: User-Agent, OS, and MoreSee what your browser sends to every site — User-Agent, OS, screen size, time zone, language — how fingerprinting works, and how to check yours.
  4. UTM Parameters Explained: source, medium, and campaign rulesWhat utm_source, utm_medium, and utm_campaign each hold, and why one capital letter or a stray space splits the same campaign into two rows.
  5. How to Verify a SHA-256 Checksum of a Downloaded FileCompare a downloaded file's SHA-256 hash with the publisher's posted value using certutil, shasum, or sha256sum, and see what a match really proves.
  6. Is the Site Down? Check Whether It's Just You or the ServerLearn how to tell whether a site is down for everyone or just you, and what DNS, cache, and HTTP status codes reveal. Free URL status check included.

Related tools