|
| 1 | +/* |
| 2 | + * This file is part of the Buildings and Habitats object Model (BHoM) |
| 3 | + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. |
| 4 | + * |
| 5 | + * Each contributor holds copyright over their respective contributions. |
| 6 | + * The project versioning (Git) records all such contribution source information. |
| 7 | + * |
| 8 | + * |
| 9 | + * The BHoM is free software: you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU Lesser General Public License as published by |
| 11 | + * the Free Software Foundation, either version 3.0 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * The BHoM is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU Lesser General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU Lesser General Public License |
| 20 | + * along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. |
| 21 | + */ |
| 22 | + |
| 23 | +using System; |
| 24 | +using System.Collections.Generic; |
| 25 | +using System.Linq; |
| 26 | +using System.Text; |
| 27 | +using System.Threading.Tasks; |
| 28 | + |
| 29 | +using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes |
| 30 | +using UnitsNet.Units; |
| 31 | + |
| 32 | +using System.ComponentModel; |
| 33 | +using BH.oM.Reflection.Attributes; |
| 34 | +using BH.oM.Quantities.Attributes; |
| 35 | + |
| 36 | +namespace BH.Engine.Units |
| 37 | +{ |
| 38 | + public static partial class Convert |
| 39 | + { |
| 40 | + [Description("Convert SI units (radians) into degrees")] |
| 41 | + [Input("radians", "The number of radians to convert", typeof(Angle))] |
| 42 | + [Output("degrees", "The number of degrees")] |
| 43 | + public static double ToDegree(this double radians) |
| 44 | + { |
| 45 | + UN.QuantityValue qv = radians; |
| 46 | + return UN.UnitConverter.Convert(qv, AngleUnit.Radian, AngleUnit.Degree); |
| 47 | + } |
| 48 | + |
| 49 | + [Description("Convert degrees into SI units (radians)")] |
| 50 | + [Input("degrees", "The number of degrees to convert")] |
| 51 | + [Output("radians", "The number of radians", typeof(Angle))] |
| 52 | + public static double FromDegree(this double degrees) |
| 53 | + { |
| 54 | + UN.QuantityValue qv = degrees; |
| 55 | + return UN.UnitConverter.Convert(qv, AngleUnit.Degree, AngleUnit.Radian); |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments