Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching from HYG to THC. #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions server/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ using namespace std;
using namespace std::chrono;

const uint32_t kMaxLeafSize = 8;
const string kDataFileName = "data/hygdata_min3.csv";
// const string kDataFileName = "data/thc.csv";
//const string kDataFileName = "data/hygdata_min3.csv";
const string kDataFileName = "data/thc.csv";

// Signal handler sets this to false to stop the server
volatile bool running = true;
Expand Down Expand Up @@ -52,17 +52,17 @@ int main(int argc, char* argv[]) {
double minx,miny,minz,maxx,maxy,maxz;

vector<Star> stars;
//while(star_reader.read_row(idstr, x, y, z, absmag, r, g, b)) {
while(star_reader.read_row(id, x, y, z, lum, r, g, b)) {
while(star_reader.read_row(idstr, x, y, z, absmag, r, g, b)) {
//while(star_reader.read_row(id, x, y, z, lum, r, g, b)) {
minx = min(x, minx);
miny = min(y, miny);
minz = min(z, minz);
maxx = max(x, maxx);
maxy = max(y, maxy);
maxz = max(z, maxz);
//lum = exp(-0.4 * (absmag - 4.85));
//stars.push_back(Star(id++, x, y , z, lum, r, g, b));
stars.push_back(Star(id, x, y , z, lum, r, g, b));
lum = exp(-0.4 * (absmag - 4.85));
stars.push_back(Star(id++, x, y , z, lum, r, g, b));
//stars.push_back(Star(id, x, y , z, lum, r, g, b));
}
cout << "Min x: " << minx << " Min y: " << miny << " Min z: " << minz
<< endl
Expand Down
33 changes: 22 additions & 11 deletions server/static/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var draggingCanvas = false;
var dragVector = {x: null, y: null};
var pressForward = false;
var activeDrag = false;
var totalStarDownloadCount = 0;

function initKeys() {
for (var i = 0; i < 256; ++i) {
Expand Down Expand Up @@ -177,33 +178,40 @@ function doOneFrame() {
var translated = position.subtract(cameraPosition);
var brightness = star.lum /
(4 * Math.PI * translated.squaredLength());
var scaling = 255 * 64;
brightness *= scaling;
if (brightness < 0.001) {
starSkipCount++;
continue;
}
var scaling = 255 * 8;
brightness *= scaling;

var projected = translated.basisProjection(right,
cameraDirection,
upDirection);
if (projected.y < 0.00001) {
starSkipCount++;
continue;
}
var fovMultiplier = 1.0 / 0.7;
var sx = (canvas.width / 2) +
(canvas.width / 2) * projected.x / projected.y;
fovMultiplier * (canvas.width / 2) * projected.x / projected.y;
var sy = (canvas.height / 2) +
(canvas.width / 2) * projected.z / projected.y;
if (sx < 0 || sx > canvas.width) continue;
if (sy < 0 || sy > canvas.height) continue;
fovMultiplier * (canvas.width / 2) * projected.z / projected.y;
if (sx < 0 || sx > canvas.width) {
starSkipCount++;
continue;
}
if (sy < 0 || sy > canvas.height) {
starSkipCount++;
continue;
}

var color = {"r":star.r, "g":star.g, "b":star.b};
renderStar(context, sx, sy, brightness, color);
starRenderCount++;
}
}
//console.log('Stars Rendered: ' + starRenderCount);
//console.log('Stars Skipped: ' + starSkipCount);
console.log('rendered: ' + starRenderCount + ' skipped: ' + starSkipCount);
setTimeout(doOneFrame, 10);
};

Expand All @@ -221,7 +229,7 @@ function updateStars(force) {
var y = cameraPosition.y;
var z = cameraPosition.z;
//console.log('x: ' + x + ' y: ' + y + ' z: ' + z);
getVisibleOctants(0.001, x, y, z, function(newOcts) {
getVisibleOctants(0.0001, x, y, z, function(newOcts) {
// Use a temporary so we don't update with this before we
// actually have all thes tars.
var tmpVisibleOctants = newOcts;
Expand Down Expand Up @@ -250,8 +258,11 @@ function updateStars(force) {
console.log("Aleady have that!" +
octRequests[ix]);
}
octantDict[octRequests[ix]] =
newStars[octRequests[ix]];
octantDict[octRequests[ix]] = newStars[octRequests[ix]];
totalStarDownloadCount += newStars[octRequests[ix]].length;
if (totalStarDownloadCount % 100 == 0) {
console.log('total stars loaded:', totalStarDownloadCount);
}
}
//console.log("Nodes: " + Object.keys(octantDict).length);
visibleOctants = tmpVisibleOctants;
Expand Down
18 changes: 9 additions & 9 deletions thc/convert_tgas_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
import sys

# Load stars from the HYG catalog.
hyg = {}
with open('../abbreviator/data/hygdata_v3.csv') as hyg_file:
reader = csv.DictReader(hyg_file)
for row in reader:
hip = row['hip']
mag = float(row['mag'])
hyg[hip] = mag
#hyg = {}
#with open('../abbreviator/data/hygdata_v3.csv') as hyg_file:
# reader = csv.DictReader(hyg_file)
# for row in reader:
# hip = row['hip']
# mag = float(row['mag'])
# hyg[hip] = mag

def ConvertStar(row):
hip = row['hip']
tyc = row['tycho2_id']
designation = ''
if hip:
designation = 'HIP ' + hip
if hip in hyg:
del hyg[hip]
#if hip in hyg:
# del hyg[hip]
elif tyc:
designation = 'TYC ' + tyc
right_ascension = float(row['ra']) * math.pi / 180
Expand Down