Arxiv:1908.01742V1 [Cs.GR] 5 Aug 2019 Contents
Total Page:16
File Type:pdf, Size:1020Kb
Rendering Non-Euclidean Geometry in Real-Time Using Spherical and Hyperbolic Trigonometry Daniil Osudin Dr Chris Child Prof Yang-Hui He City, University of London 08/06/2019 arXiv:1908.01742v1 [cs.GR] 5 Aug 2019 Contents 1 Abstract 2 2 Introduction 2 3 Method 3 3.1 Polar coordinates . 3 3.2 Projection . 3 3.3 Mathematical analysis . 4 3.3.1 Rendering the shape . 4 3.3.2 Updating object position . 7 4 Results 8 4.1 Engine . 8 4.2 Complexity Analysis . 10 5 Discussion 10 6 Conclusion 11 1 (a) Spherical space timelapse (b) Spherical space timelapse (c) Hyperbolic space timelapse Figure 1: Time-lapse images of multiple objects moving through spherical (a), planar (b) and hyperbolic (c) 2D space calculated and rendered by the physics/graphics engine described below 1 Abstract encompasses any geometry that arises from either changing the parallel postulate (Euclid's fifth pos- This paper introduces a method of calculating and tulate) or the metric requirement. In this study we rendering shapes in a non-Euclidean 2D space. In will be focussing solely on traditional non-Euclidean order to achieve this, we developed a physics and 2D geometries: Spherical geometry and Hyperbolic graphics engine that uses hyperbolic trigonometry geometry, illustrated on Figure 2 (a) and (c) respec- to calculate and subsequently render the shapes in tively. a 2D space of constant negative or positive curva- ture in real-time. We have chosen to use polar co- ordinates to record the parameters of the objects as well as an azimuthal equidistant projection to render the space onto the screen because of the multiple useful properties they have. For example, (a) Spherical (c) Euclidean (b) Hyperbolic polar coordinate system works well with trigono- Figure 2: Comparison of parallel lines in the 2D metric calculations, due to the distance from the spaces of different curvature reference point (analogous to origin in Cartesian In spherical geometry all geodesics (straight coordinates) being one of the coordinates by def- lines in a non-planar space) intersect, so there are inition. Azimuthal equidistant projection is not a no parallel lines. Even if the lines start parallel, typical projection, used for neither spherical nor hy- they don't preserve the same distance along their perbolic space, however one of the main features of length and instead appear to `bend' towards each our engine relies on it: changing the curvature of other. In fact any two great circles will intersect the world in real-time without stopping the execu- twice (unless they are one and the same). Spheri- tion of the application in order to re-calculate the cal geometry is used in multiple fields: navigation, world. This is due to the projection properties that GPS, architecture and aerospace engineering among work identically for both spherical and hyperbolic others. However in most circumstances the calcula- space, as can be seen in the Figure 1 above. We tions are done on a surface of a 3D sphere instead will also be looking at the complexity analysis of of the 2D spherical plane, and rendering if any uses this method as well as renderings that the engine the orthographic projection of the sphere. Figure 3 produces. Finally we will be discussing the limita- below, for example, illustrates Earth's eastern hemi- tions and possible applications of the created engine sphere: as well as potential improvements of the described method. 2 Introduction Non-Euclidean geometry is a broad subject that takes its origin from Euclid's work Elements [1], where he defined his five postulates. This field Figure 3: Orthographic projection of the sphere [2] 2 In cartography, multiple other projections are 3 Method used and one of them has been chosen by us to be a focus of this study: Azimuthal equidistant pro- The method chosen is using hyperbolic and spher- jection. A detailed explanation of this projection ical trigonometry, as well as equidistant azimuthal and its advantages for this model is described in projection and polar coordinates system in order to the Method section. calculate object positions and render the objects in In Hyperbolic geometry, any line can have an an arbitrary 2D space of constant positive or nega- infinite number of parallel lines, as the lines appear tive curvature. to `bend' away from each other. Elliptic geome- try is more tangible and intuitive than hyperbolic geometry, due to people interacting with it more 3.1 Polar coordinates and the possibility of a 2D elliptic plane to be em- bedded into a 3D space. Hyperbolic geometry is more abstract; however it is used heavily in mathe- y matics, astrophysics and theoretical physics, partic- A ularly for calculations involving general relativity. r Θ x The usual projection used to represent hyperbolic geometry is the Poincare disc. O Figure 5: Position of a point A in polar coordinates. It has distance r and bearing θ from the reference point O A polar coordinate system of the form (r; θ) is used in this model for all of the object positions and Figure 4: Poincare disc with hyperbolic tiling [3] calculations instead of Cartesian coordinates. The centre of the of the screen is taken as a reference point (analogous to the origin point in Cartesian Our aim was to create a physics and graphics coordinates) for the distance coordinate, r, while engine capable of calculating and rendering objects eastbound direction is set to be the reference direc- in a 2D space of arbitrary constant curvature. Our tion for the bearing coordinate, θ. additional objective was to make it possible for the Cartesian coordinates need to be adapted in curvature to be modified in real-time during the ex- order to be used for constant negative and posi- ecution of the engine. We approached this by devel- tive curvature spaces, as the parallel lines, which oping a method of calculating the object's position are essential to pinpoint the location in Carte- as well as the vertices of its shape in polar coordi- sian space, are fundamentally different in a non- nates using spherical [4] or hyperbolic trigonome- Euclidean space. try [5] [6] and then rendering the objects onto the On the other hand, polar coordinates work just screen using an azimuthal equidistant projection. as well in any space of constant curvature, as the The real-time change of curvature was achieved by distance from a reference point and bearing from a having the shapes of the object's dynamically recal- reference direction still exist. This principle will culated in order to always use the current curvature help unify the coordinate system for any curva- variable. ture of the space and ultimately allow the real-time Figure 1 above shows the time-lapse results of change of curvature without any complications. the engine rendering multiple objects in spherical (a), planar (b) and hyperbolic (c) geometries. The resulting engine can be used and built upon for 3.2 Projection multiple different purposes, such as creating video games or animations in non-Euclidean environment, In order to render a non-Euclidean 2D space onto a help visualise the mathematics of non-Euclidean flat screen, a projection has to be used which trans- space and create tools for use in different areas of late the points in a curved space onto a flat 2D space research. that is a screen. 3 1 Shape has a List of position vectors for each vertex. r = 1 These vectors are defined in local coordinates with the reference point being the centre of the object (point defined by object's position vector in global coordinates) and reference direction is taken as the opposite of the object's position vector (illustrated l = 6.28 on the Figure 8 below). This method simplifies the trigonometric calculations explained in the follow- Figure 6: Side view of unfolding a sphere or radius ing subsections. All of the vertices are defined to r onto a plane of size l using Azimuthal Equidistant be connected by the edges that lie on the geodesics projection. The diagram is to scale. which standardizes the definition of the object in a We chose to use azimuthal equidistant projec- way that is independent of the world's curvature. tion, as this projection has useful properties that fit As such, in order to have a shape with a curved the purpose well. Firstly, by definition, distances edge (e.g. semicircle), multiple vertices will need to and bearing from the centre of the projection are be set to represent the curved edge. preserved. This fits perfectly with the Polar co- V ordinates: for any point, its position vector on the 3 projection is the position vector in the curved space. Secondly, this projection is intuitive, so makes the V4 C non-Euclidean geometry easier to understand. Fi- nally, this projection can be used with no change to ϴ1 V2 O r1 O’ represent both spherical and hyperbolic 2D spaces. C’ 3.3 Mathematical analysis V1 The calculations in this model are split into two Figure 7: Local coordinate system of the object. parts: movement of the objects and rendering of Key: O, the reference point with coordinates (0; 0); the shapes, so the analysis will also be split into the C, position of the object and reference point of the corresponding subsections. Initially, it is important local coordinate system with coordinates (rc; θc); to overview how the model is structured and how V , vertex of the illustrated object with local co- the objects, shapes and the space are defined in the 1 ordinates (r1; θ1); V1,V2,V3, other vertices; OO', model. reference direction; CC', local reference direction First, as previously mentioned, the model uses a polar coordinate system for all calculations and Note: Diagrams below are shown in planar ge- these are only converted into Cartesian coordinates ometry in order to keep them clear, the triangle is for the final step of rendering, in order to utilise still a good representation for the analogous spher- the rendering functions available through OpenGL.