MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / GetDistance

Function GetDistance

calc.cpp:1975–2038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1973// distance type aspect between the given two planets.
1974
1975int GetDistance(CONST PT3R *space1, CONST PT3R *space2,
1976 CONST real *retlen1, CONST real *retlen2, int i, int j, real *prOrb)
1977{
1978 int asp;
1979 real dist1, dist2, rPct, rDiff, rOrb, retlen1a;
1980
1981 // Compute the distances of and between the two planets.
1982 dist1 = PtLen(space1[i]); dist2 = PtLen(space2[j]);
1983 if (us.fSmartCusp && (dist1 <= 0.0 || dist2 <= 0.0))
1984 return 0;
1985 if (dist1 <= 0.0 && dist2 <= 0.0)
1986 rPct = 100.0;
1987 else
1988 rPct = (dist1 <= dist2 ? dist1 / dist2 : dist2 / dist1) * 100.0;
1989
1990 // Check each distance aspect proportion to see if it applies.
1991 for (asp = 1; asp <= us.nAsp; asp++) {
1992 if (asp == aOpp || !FAcceptAspect(i, asp, j))
1993 continue;
1994 rDiff = rPct - (rAspAngle[asp == aCon ? aOpp : asp] / rDegHalf * 100.0);
1995 rOrb = GetOrb(i, j, asp);
1996
1997 // If -ga switch in effect, then change the sign of the orb to correspond
1998 // to whether the aspect is applying or separating. To do this, check the
1999 // distance velocity vectors to see if the planets are moving toward,
2000 // away, or are overtaking each other.
2001
2002 if (us.nAppSep == 1) {
2003 if (FCmSwissAny()) {
2004 retlen1a = us.nRel > rcTransit ? retlen1[i] : 0.0;
2005 rDiff *= RSgn2(retlen2[j]-retlen1a);
2006 } else {
2007 // If no distance velocity, make aspect separating.
2008 rDiff = RAbs(rDiff);
2009 }
2010 } else if (us.nAppSep == 2) {
2011 // "Waxing" is if nearer body applying, "waning" if nearer separating.
2012 rDiff = RAbs(rDiff) *
2013 (dist1 <= dist2 ? RSgn2(retlen1[i]) : RSgn2(retlen2[j]));
2014 }
2015
2016#ifdef EXPRESS
2017 // Adjust orb with AstroExpression, if one defined.
2018 if (!us.fExpOff && FSzSet(us.szExpAsp)) {
2019 ExpSetN(iLetterV, i);
2020 ExpSetN(iLetterW, -asp);
2021 ExpSetN(iLetterX, j);
2022 ExpSetR(iLetterY, rDiff);
2023 ExpSetR(iLetterZ, rOrb);
2024 ParseExpression(us.szExpAsp);
2025 rDiff = RExpGet(iLetterY);
2026 rOrb = RExpGet(iLetterZ);
2027 }
2028#endif
2029
2030 // If distance aspect within orb, return it.
2031 if (RAbs(rDiff) < rOrb) {
2032 if (prOrb != NULL)

Callers 2

FCreateGridFunction · 0.85
FCreateGridRelationFunction · 0.85

Calls 5

FAcceptAspectFunction · 0.85
GetOrbFunction · 0.85
ExpSetNFunction · 0.85
ExpSetRFunction · 0.85
RExpGetFunction · 0.85

Tested by

no test coverage detected