phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP - Number: Converting Between Degrees and Radians

Tag: number. degree, radian   Category: PHP Basic
post: 16 Mar 2008 read: 157


PHP Number Tips - Part 16: If you want to convert an angle measurement from degrees to radians or vice versa, so you only have to use PHP's rad2deg( ) and deg2rad( ) functions such as:

<?php
//result: "90 degrees = 1.57079632679 radians "
$degrees = 90;
$radians = deg2rad($degrees);
echo "$degrees degrees = $radians radians ";

//result: "1.57079632679491 radians = 90 degrees"
$radians = 1.57079632679491;
$degrees = rad2deg($radians);
echo "$radians radians = $degrees degrees";
?>

The formula to convert an angle measurement in degrees (D) to radians (R) is D = R*180/pi. Fortunately, PHP comes with a function to do it for you automatically: the deg2rad( ) function or if you have a value that is already in radians, you can convert it to degrees with the rad2reg( ) function.




| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting