Created
February 18, 2013 14:12
-
-
Save dck-jp/4977714 to your computer and use it in GitHub Desktop.
OppaiAnalysis Rev.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace OppaiAnalysis | |
| { | |
| static class OppaiAnalysis | |
| { | |
| static public double cupDiameterFromUnderbustAndCup(double under, string cup) | |
| { | |
| var cupInt = ToCharacterCode(cup)[0] - 64; | |
| var initSize = 8.3; //8.3 or 9.7 | |
| var diffCup = 0.98; //0.98 or 0.847 | |
| return initSize + diffCup * ((under - 65.0) / 5.0 - 1.0) + diffCup * (cupInt - 1.0); | |
| } | |
| static public double cupVolumeFromCupDiameter(double diameter) | |
| { | |
| return 2.0 / 3.0 * Math.PI * Math.Pow((diameter / 2.0), 3); | |
| } | |
| static public double cup2cm(string cup) | |
| { | |
| if (cup == "AAA") { return 5; } | |
| else if (cup == "AA") { return 7.5; } | |
| else if (cup == "ZZ") { return 75; } | |
| else if (cup == "ZZZ") { return 77.5; } | |
| return ToCharacterCode(cup)[0] - ToCharacterCode('A') * 2.5 + 10; | |
| } | |
| static public string cm2cup(double cm) | |
| { | |
| if( cm <= 6.25) {return "AAA";} | |
| else if( cm <= 8.75){ return "AA";} | |
| else if ( cm >= 77.5) {return "ZZZ";} | |
| else if ( cm >= 75) { return "ZZ";} | |
| return FromCharacterCode(Math.Floor((cm - 10)/2.5) + 65).ToString(); | |
| } | |
| /// <summary> | |
| /// 文字列の各文字に対応する文字コードを返す | |
| /// </summary> | |
| /// <param name="str"></param> | |
| /// <returns></returns> | |
| static private List<int> ToCharacterCode(string str) | |
| { | |
| var output = new List<int>(); | |
| foreach (var c in str.ToCharArray()) | |
| { | |
| output.Add(Convert.ToInt32(c)); | |
| } | |
| return output; | |
| } | |
| static private int ToCharacterCode(char c) | |
| { | |
| return Convert.ToInt32(c); | |
| } | |
| /// <summary> | |
| /// 整数値 n の文字コードの1文字からなる文字列を与える. | |
| /// </summary> | |
| /// <param name="n"></param> | |
| /// <returns></returns> | |
| static private char FromCharacterCode <T>(T n) | |
| where T : struct | |
| { | |
| return Convert.ToChar(Convert.ToInt32(n)); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace OppaiAnalysis | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var under = 75; | |
| var cups = new List<string>( | |
| new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" } | |
| ); | |
| cups.ForEach(cup => | |
| { | |
| var vol = OppaiAnalysis.cupVolumeFromCupDiameter( | |
| OppaiAnalysis.cupDiameterFromUnderbustAndCup(under, cup) | |
| ); | |
| Console.WriteLine(vol); | |
| }); | |
| cups.ForEach(cup => | |
| { | |
| var dia = OppaiAnalysis.cupDiameterFromUnderbustAndCup(under, cup); | |
| Console.WriteLine(dia); | |
| }); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment