$degreesToRadians (Degrees to Radians)

Last updated: 2026-10-09

$degreesToRadians (Degrees to Radians)

$degreesToRadians converts degrees to radians by multiplying by π/180. Since the trigonometric operators $sin, $cos, and $tan take radians as input, converting angles first avoids hand-multiplying by pi. It is used in geographic coordinates and trigonometry. A null or missing argument yields null, and NaN input returns NaN. It is the inverse of $radiansToDegrees. Note that very large inputs can lose precision.

CategoryMath
MongoDB Version1.0+
Example Languagemongosh (Shell)

📝 Syntax

{ $degreesToRadians: <numeric-expression> }

⚙️ Parameters

degreesA numeric expression in degrees.

Returns:The radians equivalent of the input; null when null or missing

▶ Example

Run the commands below in your local mongosh (requires a running mongod):

// $degreesToRadians: convert degrees to radians
db.trig.aggregate([
  { $project: {
      rad: { $degreesToRadians: '$deg' }
  } }
])

Output:

{ '_id': 1, 'rad': 3.141592653589793 }
{ '_id': 2, 'rad': 0.5235987755982988 }

📌 Notes

More hands-on cases coming soon.

📚 Related Tutorials

❓ FAQ

QWhat is the formula for $degreesToRadians?
AMultiply the input by π and divide by 180; 180 degrees is about 3.1416 radians.
QWhy convert to radians before trigonometry?
A$sin, $cos, and $tan expect radians, so passing degrees gives wrong results.
QWhat is $degreesToRadians(90)?
AIt is π/2, about 1.5708 radians.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏