Skip to main content
15 events
when toggle format what by license comment
Jun 27, 2019 at 9:25 comment added user1747281 Don't be sorry, made me learn something new :-)
Jun 27, 2019 at 9:20 comment added Peter Taylor @user1747281, sorry, my mistake. I was trying to use the smallest possible scope, and I overlooked that T was used elsewhere.
Jun 27, 2019 at 9:04 comment added user1747281 @PeterTaylor one more question: any reason why MT is declared inside the constructor? I need to calculate T and R inside my "FromGeographicRelative" method. Is there any problem if I move the method declaration outside the constructor?
S Jun 27, 2019 at 8:50 history edited Peter Taylor CC BY-SA 4.0
added explanation for the algebraic simplification of N
S Jun 27, 2019 at 8:50 history suggested user1747281 CC BY-SA 4.0
added explanation for the algebraic simplification of N
Jun 27, 2019 at 8:48 review Suggested edits
S Jun 27, 2019 at 8:50
Jun 27, 2019 at 8:41 comment added user1747281 @PeterTaylor brilliant. Haven't worked much with logs since 12th grade. Do you mind if I edit your answer with that extra bit of explanation?
Jun 27, 2019 at 8:33 comment added user1747281 I'm a bit puzzled about this line: N = System.Math.Log(M1 / M2, T1 / T2); are you sure this translate into the same as N = (Log(M1) - Log(M2))/(Log(T1)-Log(T2)) ?
Jun 27, 2019 at 8:28 comment added dfhwze @PeterTaylor They are available with unicode escape sequence: \u00B2 is ² Depending on your IDE, the variable name can be dispayed nicely.
Jun 27, 2019 at 8:23 vote accept user1747281
Jun 27, 2019 at 8:23 comment added user1747281 You're absolutely right about Deg2Rad, it's legacy from when I initially used UnityEngine.Mathf before switching to System.Math. For the getter syntax, it's the auto-generated code from VS. It generates a property with getter and setter, and I just removed the setter part. Thanks for clarifying this, point taken, lesson learned. Thanks a lot for the refactored code, looks sexy. Looking at it, I can't believe I've not thought of doing it that way from the start. Sometimes the simplest solutions just elude us for some reason.
Jun 27, 2019 at 8:18 comment added dfhwze static readonly seems the best option to me. Simple built-in solution without the need for Lazy, memoization or T4.
Jun 27, 2019 at 8:17 comment added Peter Taylor @t3chb0t, it's a shame that Unicode subscript numbers aren't also valid in identifiers.
Jun 27, 2019 at 8:14 comment added t3chb0t I didn't have time to rewrite the formula completely but it looks really nice now, with the original mathematical symbols! One improvement though about (double, double) MT(double ϕ) - I would give these two names like (double M, double T) etc... or actually it doesn't really matter since you deconstruct them anyway.
Jun 27, 2019 at 8:05 history answered Peter Taylor CC BY-SA 4.0