HyperRogue  11.3d
game/visualization engine based on non-Euclidean geometry
Classes | Namespaces | Macros | Enumerations | Functions | Variables
hyperpoint.cpp File Reference

basic computations in non-Euclidean geometry More...

#include "hyper.h"

Classes

struct  hr::hyperpoint
 A point in our continuous space Originally used for representing points in the hyperbolic plane. Currently used for all kinds of supported spaces, as well as for all vector spaces (up to 4 dimensions). We are using the normalized homogeneous coordinates, which allows us to work with most geometries in HyperRogue in a uniform way. More...
 
struct  hr::transmatrix
 A matrix acting on hr::hyperpoint Since we are using homogeneous coordinates for hr::hyperpoint, rotations and translations can be represented as matrix multiplications. Other applications of matrices in HyperRogue (in dimension up to 4) are also implemented using transmatrix. More...
 

Namespaces

 hr
 

Macros

#define C0   (MDIM == 3 ? C02 : C03)
 
#define M_PI   3.14159265358979
 
#define Cx1   (GDIM==2?Cx12:Cx13)
 

Enumerations

enum  iePrecision { iLazy, iTable }
 

Functions

constexpr transmatrix hr::diag (ld a, ld b, ld c, ld d)
 
hyperpoint hr::hpxyz (ld x, ld y, ld z)
 
hyperpoint hr::hpxyz3 (ld x, ld y, ld z, ld w)
 
constexpr hyperpoint hr::point3 (ld x, ld y, ld z)
 
constexpr hyperpoint hr::point31 (ld x, ld y, ld z)
 
constexpr hyperpoint hr::point2 (ld x, ld y)
 
EX ld hr::squar (ld x)
 
EX int hr::sig (int z)
 
EX int hr::curvature ()
 
EX ld hr::sin_auto (ld x)
 
EX ld hr::asin_auto (ld x)
 
EX ld hr::acos_auto (ld x)
 
EX ld hr::volume_auto (ld r)
 
EX ld hr::asin_clamp (ld x)
 
EX ld hr::asin_auto_clamp (ld x)
 
EX ld hr::acos_auto_clamp (ld x)
 
EX ld hr::cos_auto (ld x)
 
EX ld hr::tan_auto (ld x)
 
EX ld hr::atan_auto (ld x)
 
EX ld hr::atan2_auto (ld y, ld x)
 
EX ld hr::edge_of_triangle_with_angles (ld alpha, ld beta, ld gamma)
 
EX hyperpoint hr::hpxy (ld x, ld y)
 
EX hyperpoint hr::hpxy3 (ld x, ld y, ld z)
 
EX bool hr::zero_d (int d, hyperpoint h)
 
EX ld hr::intval (const hyperpoint &h1, const hyperpoint &h2)
 
EX ld hr::quickdist (const hyperpoint &h1, const hyperpoint &h2)
 
EX ld hr::sqhypot_d (int d, const hyperpoint &h)
 
EX ld hr::hypot_d (int d, const hyperpoint &h)
 
EX ld hr::zlevel (const hyperpoint &h)
 
EX ld hr::hypot_auto (ld x, ld y)
 
EX hyperpoint hr::normalize (hyperpoint H)
 
EX hyperpoint hr::normalize_flat (hyperpoint h)
 
EX hyperpoint hr::mid (const hyperpoint &H1, const hyperpoint &H2)
 
EX hyperpoint hr::midz (const hyperpoint &H1, const hyperpoint &H2)
 
EX transmatrix hr::cspin (int a, int b, ld alpha)
 
EX transmatrix hr::spin (ld alpha)
 
EX transmatrix hr::random_spin ()
 
EX transmatrix hr::eupush (ld x, ld y)
 
EX transmatrix hr::eupush (hyperpoint h)
 
EX transmatrix hr::eupush3 (ld x, ld y, ld z)
 
EX transmatrix hr::euscalezoom (hyperpoint h)
 
EX transmatrix hr::euaffine (hyperpoint h)
 
EX transmatrix hr::cpush (int cid, ld alpha)
 
EX transmatrix hr::xpush (ld alpha)
 
EX bool hr::eqmatrix (transmatrix A, transmatrix B, ld eps IS(.01))
 
EX hyperpoint hr::orthogonal_move (const hyperpoint &h, ld z)
 
EX transmatrix hr::ypush (ld alpha)
 
EX transmatrix hr::zpush (ld z)
 
EX transmatrix hr::matrix3 (ld a, ld b, ld c, ld d, ld e, ld f, ld g, ld h, ld i)
 
EX transmatrix hr::matrix4 (ld a, ld b, ld c, ld d, ld e, ld f, ld g, ld h, ld i, ld j, ld k, ld l, ld m, ld n, ld o, ld p)
 
EX void hr::swapmatrix (transmatrix &T)
 
EX void hr::swapmatrix (hyperpoint &h)
 
EX transmatrix hr::parabolic1 (ld u)
 
EX transmatrix hr::parabolic13 (ld u, ld v)
 
EX hyperpoint hr::parabolic10 (hyperpoint h)
 
EX hyperpoint hr::deparabolic10 (const hyperpoint h)
 
EX transmatrix hr::spintoc (const hyperpoint &H, int t, int f)
 
EX transmatrix hr::rspintoc (const hyperpoint &H, int t, int f)
 
EX transmatrix hr::spintox (const hyperpoint &H)
 
EX transmatrix hr::rspintox (const hyperpoint &H)
 
EX transmatrix hr::pushxto0 (const hyperpoint &H)
 
EX void hr::set_column (transmatrix &T, int i, const hyperpoint &H)
 
EX transmatrix hr::build_matrix (hyperpoint h1, hyperpoint h2, hyperpoint h3, hyperpoint h4)
 
EX transmatrix hr::rpushxto0 (const hyperpoint &H)
 
EX transmatrix hr::ggpushxto0 (const hyperpoint &H, ld co)
 
EX transmatrix hr::gpushxto0 (const hyperpoint &H)
 
EX transmatrix hr::rgpushxto0 (const hyperpoint &H)
 
EX void hr::fixmatrix (transmatrix &T)
 Fix the numerical inaccuracies in the isometry T The nature of hyperbolic geometry makes the computations numerically unstable. The numerical errors tend to accumulate, eventually destroying the projection. This function fixes this problem by replacing T with a 'correct' isometry.
 
EX ld hr::det (const transmatrix &T)
 
void hr::inverse_error (const transmatrix &T)
 
EX transmatrix hr::inverse (const transmatrix &T)
 
EX pair< ld, hyperpoint > hr::product_decompose (hyperpoint h)
 
EX ld hr::hdist0 (const hyperpoint &mh)
 
EX ld hr::circlelength (ld r)
 
EX ld hr::hdist (const hyperpoint &h1, const hyperpoint &h2)
 
EX hyperpoint hr::mscale (const hyperpoint &t, double fac)
 
EX transmatrix hr::mscale (const transmatrix &t, double fac)
 
EX transmatrix hr::xyscale (const transmatrix &t, double fac)
 
EX transmatrix hr::xyzscale (const transmatrix &t, double fac, double facz)
 
EX transmatrix hr::mzscale (const transmatrix &t, double fac)
 
EX hyperpoint hr::mid3 (hyperpoint h1, hyperpoint h2, hyperpoint h3)
 
EX hyperpoint hr::mid_at (hyperpoint h1, hyperpoint h2, ld v)
 
EX hyperpoint hr::mid_at_actual (hyperpoint h, ld v)
 
EX hyperpoint hr::orthogonal_of_C0 (hyperpoint h0, hyperpoint h1, hyperpoint h2)
 
EX hyperpoint hr::zshift (hyperpoint x, ld z)
 
EX hyperpoint hr::hpxd (ld d, ld x, ld y, ld z)
 
EX ld hr::signum (ld x)
 
EX bool hr::asign (ld y1, ld y2)
 
EX ld hr::xcross (ld x1, ld y1, ld x2, ld y2)
 
EX transmatrix hr::parallel_transport (const transmatrix Position, const transmatrix &ori, const hyperpoint direction, int precision IS(100))
 
EX void hr::apply_parallel_transport (transmatrix &Position, const transmatrix orientation, const hyperpoint direction)
 
EX void hr::rotate_object (transmatrix &Position, transmatrix &orientation, transmatrix R)
 
EX transmatrix hr::spin_towards (const transmatrix Position, transmatrix &ori, const hyperpoint goal, int dir, int back)
 
EX ld hr::ortho_error (transmatrix T)
 
EX transmatrix hr::transpose (transmatrix T)
 
hyperpoint hr::slr::xyz_point (ld x, ld y, ld z)
 
hyperpoint hr::slr::polar (ld r, ld theta, ld phi)
 
hyperpoint hr::cpush0 (int c, ld x)
 
hyperpoint hr::xspinpush0 (ld alpha, ld x)
 
hyperpoint hr::xpush0 (ld x)
 
hyperpoint hr::ypush0 (ld x)
 
hyperpoint hr::zpush0 (ld x)
 
hyperpoint hr::tC0 (const transmatrix &T)
 
EX hyperpoint hr::ctangent (int c, ld x)
 
EX hyperpoint hr::xtangent (ld x)
 
EX hyperpoint hr::ztangent (ld z)
 
EX hyperpoint hr::tangent_length (hyperpoint dir, ld length)
 
EX hyperpoint hr::direct_exp (hyperpoint v, int steps)
 
EX hyperpoint hr::inverse_exp (const hyperpoint h, iePrecision p, bool just_direction IS(true))
 
EX ld hr::geo_dist (const hyperpoint h1, const hyperpoint h2, iePrecision p)
 
EX hyperpoint hr::lp_iapply (const hyperpoint h)
 
EX hyperpoint hr::lp_apply (const hyperpoint h)
 
EX hyperpoint hr::smalltangent ()
 
EX void hr::cyclefix (ld &a, ld b)
 
EX ld hr::raddif (ld a, ld b)
 
EX int hr::bucketer (ld x)
 
EX int hr::bucketer (hyperpoint h)
 

Variables

constexpr hyperpoint hr::Hypc = hyperpoint(0, 0, 0, 0)
 
constexpr transmatrix hr::Id = diag(1,1,1,1)
 
constexpr transmatrix hr::Zero = diag(0,0,0,0)
 
constexpr transmatrix hr::Mirror = diag(1,-1,1,1)
 
constexpr transmatrix hr::MirrorY = diag(1,-1,1,1)
 
constexpr transmatrix hr::MirrorX = diag(-1,1,1,1)
 
constexpr transmatrix hr::MirrorZ = diag(1,1,-1,1)
 
constexpr transmatrix hr::pispin = diag(-1,-1,1,1)
 
constexpr transmatrix hr::centralsym = diag(-1,-1,-1,-1)
 
constexpr hyperpoint hr::C02 = hyperpoint(0,0,1,0)
 
constexpr hyperpoint hr::C03 = hyperpoint(0,0,0,1)
 
constexpr hyperpoint hr::Cx12 = hyperpoint(1,0,1.41421356237,0)
 
constexpr hyperpoint hr::Cx13 = hyperpoint(1,0,0,1.41421356237)
 

Detailed Description

basic computations in non-Euclidean geometry

This implements hyperpoint (a point in non-Euclidean space), transmatrix (a transformation matrix), and various basic routines related to them: rotations, translations, inverses and determinants, etc. For nonisotropic geometries, it rather refers to nonisotropic.cpp.

Macro Definition Documentation

◆ C0

#define C0   (MDIM == 3 ? C02 : C03)

C0 is the origin in our space