Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplicationHW
- {
- class Calculator
- {
- public static DegreeValue Minus(DegreeValue v1, DegreeValue v2)
- {
- return v1 - v2;
- }
- public static DegreeValue Plus(DegreeValue v1, DegreeValue v2)
- {
- return v1 + v2;
- }
- public static DegreeValue Multiply(DegreeValue v1, int factor)
- {
- return v1 * factor;
- }
- public static DegreeValue Multiply(int factor, DegreeValue v1)
- {
- return v1 * factor;
- }
- public static DegreeValue Divide(DegreeValue v1, int devisor)
- {
- return v1 / devisor;
- }
- public static DegreeValue Flip(DegreeValue v1)
- {
- return new DegreeValue(0, 0, -(v1.Degrees * 3600 + v1.Minutes * 60 + v1.Seconds));
- }
- public static double Sin(DegreeValue v1)
- {
- double rad = Math.PI / 180 * (v1.Degrees + (double)v1.Minutes / 60 + (double)v1.Seconds / 3600);
- return Math.Sin(rad);
- }
- public static double Cos(DegreeValue v1)
- {
- double rad = Math.PI / 180 * (v1.Degrees + (double)v1.Minutes / 60 + (double)v1.Seconds / 3600);
- return Math.Cos(rad);
- }
- public static double Tg(DegreeValue v1)
- {
- if ((v1.ToSeconds() != 90 * 3600) && (v1.ToSeconds() != 270 * 3600))
- {
- double rad = Math.PI / 180 * (v1.Degrees + (double)v1.Minutes / 60 + (double)v1.Seconds / 3600);
- return Math.Tan(rad);
- }
- else if (v1.ToSeconds() == 90 * 3600)
- {
- return double.PositiveInfinity;
- }
- else
- {
- return double.NegativeInfinity;
- }
- }
- public static double Ctg(DegreeValue v1)
- {
- if ((v1.ToSeconds() != 0) && (v1.ToSeconds() != 180 * 3600))
- {
- double rad = Math.PI / 180 * (v1.Degrees + (double)v1.Minutes / 60 + (double)v1.Seconds / 3600);
- return (double)1 / Math.Tan(rad);
- }
- else if (v1.ToSeconds() == 0)
- {
- return double.PositiveInfinity;
- }
- else
- {
- return double.NegativeInfinity;
- }
- }
- public static DegreeValue ArcSin(double sin)
- {
- if (sin >= -1 && sin <= 1)
- {
- int sec = (int)Math.Round(Math.Asin(sin) * 3600 * 180 / Math.PI);
- DegreeValue res = new DegreeValue(0, 0, sec);
- return res;
- }
- else
- {
- return null;
- }
- }
- public static DegreeValue ArcCos(double cos)
- {
- if (cos >= -1 && cos <= 1)
- {
- int sec = (int)Math.Round(Math.Acos(cos) * 3600 * 180 / Math.PI);
- DegreeValue res = new DegreeValue(0, 0, sec);
- return res;
- }
- else
- {
- return null;
- }
- }
- public static DegreeValue ArcTg(double tg)
- {
- int sec = (int)Math.Round(Math.Atan(tg)*3600*180/Math.PI);
- return new DegreeValue(0, 0, sec);
- }
- public static DegreeValue ArcCtg(double ctg)
- {
- if (ctg != double.NegativeInfinity)
- {
- int sec = (int)Math.Round(Math.Atan(1 / ctg) * 3600 * 180 / Math.PI);
- return new DegreeValue(0, 0, sec);
- }
- else
- {
- return new DegreeValue(180);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement