From 2e7b5f0c16f841753980e7111ba489c7736048a4 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 23 Jul 2018 05:18:55 +0200 Subject: [PATCH] improved the gnomonic projection of the sphere; there are still glitches with stereographic --- polygons.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/polygons.cpp b/polygons.cpp index 9e9e987f..3768ea6f 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -146,12 +146,24 @@ void add1(const hyperpoint& H) { int spherespecial, spherephase; +bool is_behind(const hyperpoint& H) { + return pmodel == mdDisk && vid.alpha + H[2] <= BEHIND_LIMIT; + } + +hyperpoint be_just_on_view(const hyperpoint& H1, const hyperpoint &H2) { + using namespace hyperpoint_vec; + // H1[2] * t + H2[2] * (1-t) == BEHIND_LIMIT - vid.alpha + // H2[2]- BEHIND_LIMIT + vid.alpha = t * (H2[2] - H1[2]) + ld t = (H2[2] - BEHIND_LIMIT + vid.alpha) / (H2[2] - H1[2]); + return H1 * t + H2 * (1-t); + } + void addpoint(const hyperpoint& H) { if(true) { hyperpoint Hscr; applymodel(H, Hscr); for(int i=0; i<3; i++) Hscr[i] *= vid.radius; - if(vid.alpha + H[2] <= BEHIND_LIMIT && pmodel == mdDisk) poly_flags |= POLY_BEHIND; + // if(vid.alpha + H[2] <= BEHIND_LIMIT && pmodel == mdDisk) poly_flags |= POLY_BEHIND; if(spherespecial) { double curnorm = H[0]*H[0]+H[1]*H[1]+H[2]*H[2]; @@ -185,8 +197,20 @@ void coords_to_poly() { } void addpoly(const transmatrix& V, const vector &tab, int ofs, int cnt) { - for(int i=ofs; i poly_limit || abs(p[1]) > poly_limit)