Degrees to Radians

vckicks 1 Tallied Votes 679 Views Share

The .Net Framework uses by default radians in its trigonometry calculations. Find out how to convert degrees to radians to use with C#

private double DegreeToRadian(double angle)
{
return Math.PI * angle / 180.0;
}

//Get the Cosine of a 45 degree angle
double angle = Math.Cos(DegreeToRadian(45));
ddanbe 2,724 Professional Procrastinator Featured Poster

What about 45°30'10''?
Angles don't always come in whole parts.

vckicks 1 Junior Poster in Training

If the angle isn't whole use a decimal point (45.352343). If you want to convert something like 45°30'10'' to a decimal representation then that would be a different function to write.

kalaivanan 0 Newbie Poster

it will gives error...tan(90) will comes with values but google calc gives error...help me

necrovore -2 Junior Poster in Training

It gives an error because tan(90) is undefined.
See this

ddanbe 2,724 Professional Procrastinator Featured Poster

@kalaivanan: you shouldhave started a new thread
People interested in angle conversion could consult this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.