Skip to content

Instantly share code, notes, and snippets.

@musicm122
Created February 7, 2012 21:36
Show Gist options
  • Save musicm122/1762191 to your computer and use it in GitHub Desktop.
Save musicm122/1762191 to your computer and use it in GitHub Desktop.
C# Trig Functions
//Some old math stuff I wrote when in Trig class
using System;
using System.IO;
public class Geometry
{
//-----Area of a circle A= pi^2--------------------------------------------
public static double Area_Circle(double radius)
{
double area = 2*(Math.PI*(radius*radius));
return area;
}
public static double Radius_Circle(double area)
{
double radius = Math.Sqrt(area/Math.PI);
return radius;
}
}
public class Trigometry
{
//-----Convert Radians To Degrees--------------------------------------------
public static double Con_RadToDeg(double radians)
{
double degrees = (180/Math.PI) * radians;
return(degrees);
}
//-----Convert Degrees To Radians--------------------------------------------
public static double Con_DegToRad(double degrees)
{
double radians = (Math.PI/180)* degrees;
return(radians);
}
//-----------------Solving th sides of Right Triangles----------------------
/* o = theta
| /| |
| /o| |
Hypo| h /__| |Adj
| / |a|
| / _| |
| /__|90|<--90 degree angle hense RIGHT TRIANGLE!!
____op_____
Opposite
*/
//Remember SOH CAH TOA
// o ÷ h = sin(t)
// h*sin(t) = o
// o*sin(t) = h
// a÷h = cos(t)
// h*cos(t) = a
// a*cos(t) = h
// o ÷ a = tan(t)
// a*tan(t) = o
// o*tan(t) = a
//Finding the Length of Any Side of a Right Triangle---------------------------
//---Finding the oppsite side--------------------------------------------------
public static double FindOppSide_wSin_T_hypo(double theta,double hypo)
{
double opp = Math.Sin(theta) * hypo;
return opp;
}
public static double FindOppSide_wCos_T_hypo(double theta,double adj)
{
double opp = adj/Math.Cos(theta);
return opp;
}
public static double FindOppSide_wTan_T_hypo(double theta,double hypo)
{
double opp = Math.Tan(theta) * hypo;
return opp;
}
//---*End*-Finding the oppsite side---------------------------------------------
//---Finding the adjacent side--------------------------------------------------
public static double FindAdjSide_wTan_T_opp(double theta,double opp)
{
double adj = opp/Math.Tan(theta);
return adj;
}
public static double FindAdjSide_wSin_T_opp(double theta,double opp)
{
double adj = opp/Math.Sin(theta);
return adj;
}
public static double FindAdjSide_wCos_T_hypo(double theta,double opp)
{
double adj = Math.Cos(theta)* hypo;
return adj;
}
//---*End*-Finding the adjacent side--------------------------------------------
//----Finding the Hypotenuse ---------------------------------------------------
public static double FindHypoSide_wSin_T_opp(double theta,double opp)
{
double hypo = opp/Math.Sin(theta);
return hypo;
}
public static double FindHypoSide_wCos_T_adj(double theta,double adj)
{
double hypo = adj/Math.Cos(theta);
return hypo;
}
//---*End*-Finding the Hypotenuse ----------------------------------------------
//Finding the Angle of a Right Triangle-----------------------------------------
//----Finding the Tangent ----------------------------------------------
public static double FindTan_wOpp_T_Adj(double opp,double adj)
{
double theta = Math.Atan(opp/adj);
}
public static double FindTanAngle_wOpp_T_Adj(double opp,double adj)
{
double theta = Math.Atan(opp/adj);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment