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

Function DrawMapSquare

xcharts0.cpp:1781–1824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1779// squares should be nested a specified number of levels deep.
1780
1781void DrawMapSquare(real lon1, real lat1, real lon2, real lat2,
1782 real lon3, real lat3, real lon4, real lat4,
1783 flag fGlobe, int nScl, CIRC *pcr, real deg, int nLevel, int grf)
1784{
1785 real x0, y0, x1, y1, x2, y2, x3, y3, x4, y4;
1786
1787 // Recursive case: Draw four smaller squares composing this square.
1788 if (nLevel > 0) {
1789 // Square's center is the midpoint of the midpoints of opposite corners.
1790 SphRatio(lon1, lat1, lon3, lat3, 0.5, &x1, &y1);
1791 SphRatio(lon2, lat2, lon4, lat4, 0.5, &x2, &y2);
1792 SphRatio(x1, y1, x2, y2, 0.5, &x0, &y0);
1793
1794 SphRatio(lon1, lat1, lon2, lat2, 0.5, &x1, &y1);
1795 SphRatio(lon2, lat2, lon3, lat3, 0.5, &x2, &y2);
1796 SphRatio(lon3, lat3, lon4, lat4, 0.5, &x3, &y3);
1797 SphRatio(lon4, lat4, lon1, lat1, 0.5, &x4, &y4);
1798 DrawMapSquare(lon1, lat1, x1, y1, x0, y0, x4, y4, fGlobe, nScl, pcr, deg,
1799 nLevel-1, (grf | 2) & 11);
1800 DrawMapSquare(x1, y1, lon2, lat2, x2, y2, x0, y0, fGlobe, nScl, pcr, deg,
1801 nLevel-1, (grf | 4) & 7);
1802 DrawMapSquare(x0, y0, x2, y2, lon3, lat3, x3, y3, fGlobe, nScl, pcr, deg,
1803 nLevel-1, (grf | 8) & 14);
1804 DrawMapSquare(x4, y4, x0, y0, x3, y3, lon4, lat4, fGlobe, nScl, pcr, deg,
1805 nLevel-1, (grf | 1) & 13);
1806 return;
1807 }
1808
1809 // Base case: Draw the four sides of the square.
1810 if (!fGlobe) {
1811 lon1 = Mod(lon1 + deg);
1812 lon2 = Mod(lon2 + deg);
1813 lon3 = Mod(lon3 + deg);
1814 lon4 = Mod(lon4 + deg);
1815 }
1816 if (grf & 1)
1817 DrawMapLine(lon1, lat1, lon2, lat2, fGlobe, nScl, pcr, deg);
1818 if (grf & 2)
1819 DrawMapLine(lon2, lat2, lon3, lat3, fGlobe, nScl, pcr, deg);
1820 if (grf & 4)
1821 DrawMapLine(lon3, lat3, lon4, lat4, fGlobe, nScl, pcr, deg);
1822 if (grf & 8)
1823 DrawMapLine(lon4, lat4, lon1, lat1, fGlobe, nScl, pcr, deg);
1824}
1825
1826
1827// Draw a grid of triangles or squares over the surface of the planet.

Callers 1

DrawMapTrianglesFunction · 0.85

Calls 3

SphRatioFunction · 0.85
ModFunction · 0.85
DrawMapLineFunction · 0.85

Tested by

no test coverage detected