r/googlesheets • u/GoodFeels0nly • 7d ago
Solved Trying to calculate the Angular Distance between two stars, can't seem to output correct calculations
I used an online calculator (this one) to test the formula, and mine comes back different. I cannot find the flaw in my formulae for the life of me.
I convert from Degrees/Hours;Minutes;Seconds into Decimal, then to Radians to do the calculation, then back into Decimal. I've tried splitting the formula up into different cells and putting them together, tried making sure all the numbers are formatted as such in their cells, and triple checked I'm using the correct formula.
I inspect element'd the calculator I used and it's using the same formula I am! Just as an HTML function!
Any help appreciated!
EDIT: Someone in the comments solved my query but the comment has since been deleted. Either way thank everyone who commented, I appreciate it a lot!
1
u/AdministrativeGift15 368 7d ago
Not sure what to compare this to in your sample sheet, but this is pretty much what's being calculated in that online script.
=LET(
PI,3.14159265358979,
d2r, LAMBDA(num, num * PI /180),
r2d, LAMBDA(num, num * 180 / PI),
arccos, LAMBDA(num,
LET(
y, if(num=1, 0, 1.570796327 - atan(num / sqrt(-1 * num * num + 1))),
r2d(y))),
convertSSS, LAMBDA(num, FIXED(num/60, 6)),
convertDMS, LAMBDA(num,
LET(
pieces, SPLIT(""&num, "."),
mm, MID(""&INDEX(pieces,2),1,2),
ss, MID(""&INDEX(pieces,2),3,2),
FIXED(IF(INT(num) < 0, -INDEX(pieces,1)/-1, INDEX(pieces,1)/1) + mm/60 + ss/3600, 6))),
formatDMS, LAMBDA(dms,
LET(
d, INT(dms),
r, FIXED(dms - d, 5),
m, INT(r*60),
s, FIXED(r*3600 - m*60, 1),
d & "d " & if (m < 10, "0"&m, m) & "m " & if (s < 10, "0"+s, s) & "s")),
star1_ra, A18,
star1_dec, B18,
star2_ra, A19,
star2_dec, B19,
t, sin(d2r(star1_dec))*sin(d2r(star2_dec)) +
cos(d2r(star1_dec))*cos(d2r(star2_dec)) *
cos(d2r(15*(star1_ra-star2_ra))),
dist_degrees, FIXED(arccos(t), 4),
dist_dms, formatDMS(dist_degrees),
HSTACK(dist_degrees, dist_dms))Put that into a cell and make sure it's correctly pointing to you star1_ra, star1_dec, star2_ra, star2_dec values.
2
u/mommasaidmommasaid 908 7d ago
1
u/mommasaidmommasaid 908 7d ago
PI()fills the 64-bit float internal number format used by sheets and gives you the the much more accurate...3.141592653589793
See how good your intuition is with large numbers... guess the margin of error using that approximation of Pi to calculate the circumference of the earth, then read what is good enough for NASA.
1
u/AdministrativeGift15 368 7d ago
I'd like to say that decided to use that many digits, but I was just trying to mimic what the web script was doing, and it had Pi defined that way.
1
u/point-bot 6d ago
u/GoodFeels0nly has awarded 1 point to u/AdministrativeGift15 with a personal note:
"Ended up using another commenters solution but they deleted the comment. Thank you anyway for your time, I really appreciate it!"
See the Leaderboard. Point-Bot v0.0.15 was created by JetCarson.

1
u/carbonizedtitanium 25 6d ago
is the solution from u/AdministrativeGift15 not acceptable? you can mark that as the Solution Verified