Abstract
We introduce a method of calculating and rendering shapes in a non-Euclidean 2D space in real-time using hyperbolic and spherical trigonometry. We record the objects’ parameters in a polar coordinate system and use azimuthal equidistant projection to render the space onto the screen. We discuss the complexity of this method, renderings produced, limitations and possible applications of the created software as well as potential future developments.
You have full access to this open access chapter, Download conference paper PDF
Similar content being viewed by others
Keywords
- non-Euclidean geometry
- Spherical trigonometry
- Hyperbolic trigonometry
- Azimuthal equidistant projection
- Polar coordinate system
- Real-time
1 Introduction
Non-Euclidean geometry is a field that studies any space that arises from changing Euclid’s fifth postulate [1] or changing the metric requirement. In spherical geometry, Fig. 2(a), all geodesics (shortest paths in a non-planar space) intersect: don’t preserve the distance and appear to ‘bend’ towards each other. In Hyperbolic geometry, Fig. 2(c), each line has an infinite number of parallel lines, as they appear to ‘bend’ away from each other.
We present a method for calculating the object’s position and its vertices in polar coordinates using spherical [2] or hyperbolic trigonometry [3, 4]. A polar coordinate system of the form \((r,\theta )\) is used in this model for all calculations instead of Cartesian coordinates. The centre of the of the screen is taken as a reference point O(0, 0) for the distance coordinate, r, while eastbound is the reference direction for the bearing coordinate, \(\theta \). This allows the same coordinates to be used irrespective of the correct curvature. In order to render the curved space onto a flat 2D screen, we are using azimuthal equidistant projection. By definition, distances and bearing from the centre of the projection are preserved. This works well with Polar coordinates, projection is intuitive and can be used with no changes for both spherical and hyperbolic 2D spaces (Fig. 3).
2 Method
The calculations are split into two parts: movement of the objects and rendering of the shapes. The screen (rendering space) is limited to a circle of an arbitrary size. When the object’s centre moves past the circumference of the circle, it is repositioned to the antipodal point on the circle with the velocity preserved. This is implemented in order to keep the objects in the visible area on the screen.
Shape has a list of position vectors for each vertex in local coordinates with object’s position being the reference point and reference direction is taken as the reverse of its position vector (Fig. 4).
2.1 Rendering the Shape
Let \(K \in [-1,1] \subset \mathfrak {R}\) s.t. \(K = 0 \Rightarrow \) Euclidean Geometry;
\(K > 0 \Rightarrow \) Spherical Geometry, \(r = \frac{1}{\sqrt{K}}\)
Theorem 1
For a sphere of radius r and hence Gaussian curvature \(K = \frac{1}{r^2}\) and a spherical triangle on its surface described by points u, v and w, connected by great circles that form the edges a, b, c (interpreted as subtended angles) and an angle C (Fig. 5), the spherical law of cosines [5] states:
\(K < 0 \Rightarrow \) Hyperbolic Geometry, \(k = - \frac{1}{\sqrt{K}}\)
Theorem 2
For a hyperbolic plane with Gaussian Curvature \(K = -\frac{1}{k^2}\) and a hyperbolic triangle on its surface described by points u, v and w, connected by geodesics that form the edges a, b and c, as well as an angle C (Fig. 6), the hyperbolic law of cosines [6] states:
Note: To simplify the equations below, all lengths are assumed to have been divided by r or k depending on the value of K.
Corollary 1
Given:
Find: \(r_v\), \(\theta _v\) = ?
If \(K > 0\), then: If \(K < 0\), then:
In order to find \(r_v\), first find \(\beta = \alpha + \theta _{local}\); if \(\varPi< \beta < 2\varPi \), use the explementary angle instead to determine to which side of OC the triangle lies. Depending on that \(\varDelta \theta \) is then added to or subtracted from \(\theta _c\) to find \(\theta _v\) (Fig. 7).
Corollary 2
Given: (Fig. 8)
Find: d, \(\varDelta \theta \) = ?
If angles converge, \(\varDelta \theta = ||\varDelta \theta _1 - \varDelta \theta _2 ||\); if angles diverge, \(\varDelta \theta = ||\varDelta \theta _1 ||+ ||\varDelta \theta _2 ||\)
If \(K > 0\), then: If \(K < 0\), then:
Note: distance d is divided into a number of equal parts in order to find the distance \(d_i\) for each of the points on the edge V\(_1\)V\(_2\). The number of segments depends on the object tesselation variable.
Corollary 3
Given:
Find: \(r_i\), \(\theta _i\) = ?
If \(K > 0\), then: If \(K < 0\), then:
\(\alpha \) is calculated to find the angle opposite r\(_i\). Then \(r_i\) and subsequently \(\varDelta \theta _i\) can be found using the cosine rule (illustrated on Fig. 9). Then to find actual coordinates of the point \(V_i\), \(r_i\) should be multiplied by r or k depending on the value of K; \(\varDelta \theta _i\) should be added to or subtracted from angle \(\theta \)1, depending on the direction of the edge d, determined previously.
2.2 Updating Object Position
Corollary 4
Given:
Find: \(r_{t1}\), \(\theta _{t1}\), \(\gamma _{t1}\), \(\beta _{t1}\) = ?
\(\gamma _{t0}\) should be 0 to \(\pi \), if calculated value is \(\gamma _{t0} > \pi \), take the explemntary angle. This indicates the movement direction with respect to the reference point (Fig. 10).
Let \(\angle OC_{t1}C_{t0} = \gamma '_{t1}\)
If \(K > 0\), then: If \(K < 0\), then:
\(\alpha = \beta _{t0} - \gamma _{t0}\). \(\alpha \) is the difference between rotation direction and the geodesic of movement (\(C"\!_0{C"\!_1}\)), it does not change if the object is not rotating. Hence, \(\beta _{t1} = \gamma _{t1} + \alpha \). Because \(\gamma '_{t1}\) and \(\gamma _{t1}\) are supplementary angles, \(\gamma _{t1} = \varPi - \gamma '_{t1}\).
To find the \(\theta \) coordinate, either subtract or add \(\varDelta \theta \) to the \(\theta _c\) depending on whether the angle \(\alpha \) or its explementary angle is used for this calculation.
3 Results
3.1 Implementation
Using the method described above and OpenGL, we created a software capable of calculating the objects and rendering the vector graphics in a non-Euclidean space with constant curvature in the range of \(-1\le K \le 1\). Figure 1 shows the time-lapses of multiple objects in spherical (a), planar (b) and hyperbolic (c) geometries. They show movement through different geodesics at \(K=1\), \(K=0\) and \(K=-1\) respectively. Starting positions as well as shape definitions of each object are the same across all time-lapses (grid-lines have been created and rendered as separate objects). The software can calculate the object moving in arbitrary direction with arbitrary speed as well as starting from arbitrary position in the space.
Curvature of the world can be modified in real-time using keyboard inputs in a similar manner to controlling the object’s acceleration and orientation. Another feature is the cut-off of the world at a distance of N pixels. This can be seen in the hyperbolic and planar time-lapse images. While these spaces should be infinite, we chose to limit them in order to keep objects within the boundaries of the screen (non-shaded area). We created a video [7] displaying the implementation.
3.2 Complexity Analysis
Positions of each vertex need to be calculated, requiring O(v) time, where v is the number of vertices. Subsequently, intermediate points have to be computed, requiring O(i) time to find all of the points on a single edge, where i is the level of tessellation. Complexity to render the world with s number of shapes is therefore \(O(s*v*i)\). The best case would be equal to O(n) complexity, if two of the terms are negligibly small. The worst case can be approximated to \(O(n^3)\) if all terms were comparably large. Spatial complexity for shape rendering is only \(O(v*i)\) as previous shape’s data is rewritten to store the next shape’s data. So either O(n) in the best case or \(O(n^2)\) in the worst case.
Only one movement calculation per object is required and the previous position record is overwritten, both spatial and time complexity is O(n), where n is the number of objects in the world.
Trigonometric and hyperbolic functions in the calculations are slower to compute than simpler operations, hence additional cost (implementation dependent). For example the AGM iteration [8] method is faster than the previously common Taylor series method.
4 Discussion
Implementation does not affect performance up to a certain number of objects or tessellation amount. The focus was on implementing the method correctly and having it work continuously under any curvature in the range \(-1 \le K \le 1\).
The next step in the project’s development is improving the execution time using parallelised calculations. Subsequent calculation of the points creates a bottleneck, which can be solved by performing some calculations directly on the GPU. Other approaches are considered as well, including lookup tables to speed up trigonometric calculations, for example, Frank Rochet’s implementation [9]; or finding intermediate points from a geodesic equation.
Potential applications for the software include education about non-Euclidean geometry (more intuitive than standard projections: Poincare disk and Upper Half-Plane models); cartography [10] (the engine could be modified to efficiently convert data into different projections); ecology [11] and climatology [12] (modelling dynamic systems); Astrophysics (modelling systems of cosmological objects and gravitational fields) and video games (game engine for a real-time continuous non Euclidean space, unlike HyperRogue [13], which uses step by step implementation).
References
Heath, T.L.: Euclid’s Elements. Dover, New York (1956). (translated)
Todhunter, I.: Spherical Trigonometry For the use of colleges and schools. Project Gutenberg License (1886). (republished 12 November 2006)
Carslaw, H.S.: The Elements of Non-Euclidean Plane Geometry and Trigonometry. Longmans, Green and Co., London (1916)
Traver, T.: Trigonometry in the hyperbolic plane (2014). Accessed December 2017, Manuscript
Gellert, W., Gottwald, S., Hellwich, M., Kästner, H., Küstner, H.: The VNR Concise Encyclopedia of Mathematics, 2nd edn. Van Nostrand Reinhold, New York (1989). ch. 12
Gray, J.: Non-Euclidean geometry–a re-interpretation. Historia Mathematica 6, 236–258 (1979)
Osudin, D., Child, C., He, Y.-H.: Rendering non-Euclidean space in realtime using spherical and hyperbolic trigonometry (2019). https://youtu.be/A1ZCFh5qfNg
Brent, R.P.: Multiple-precision zero-finding methods and the complexity of elementary function evaluation (2010). http://arxiv.org/abs/1004.3412v2. Accessed 26 Aug 2018
Rochet, F.: Fast trigonometry functions using lookup tables (2004). http://www.flipcode.com/archives/Fast_Trigonometry_Functions_Using_Lookup_Tables.shtml. Accessed 30 Aug 2018
Gartner, G., Huang, H.: Recent research developments in modern cartography in Europe, Issue 1: EuroCarto 2015 (2015)
Sutherland, C., Fuller, A.K., Royle, J.A.: Modelling non-Euclidean movement and landscape connectivity in highly structured ecological networks. Methods Ecol. Evol. 6, 169–177 (2015)
Frei, C.: Interpolation of temperature in a mountainous region using nonlinear profiles and non-Euclidean distances. Int. J. Climatol. 34, 1585–1605 (2013). https://doi.org/10.1002/joc.3786
Zeno Rogue Games: Hyperrogue (2019). http://roguetemple.com/z/hyper/
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Osudin, D., Child, C., He, YH. (2019). Rendering Non-Euclidean Space in Real-Time Using Spherical and Hyperbolic Trigonometry. In: Rodrigues, J., et al. Computational Science – ICCS 2019. ICCS 2019. Lecture Notes in Computer Science(), vol 11540. Springer, Cham. https://doi.org/10.1007/978-3-030-22750-0_49
Download citation
DOI: https://doi.org/10.1007/978-3-030-22750-0_49
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-22749-4
Online ISBN: 978-3-030-22750-0
eBook Packages: Computer ScienceComputer Science (R0)