00 - Basic HTML web page
Basic HTML web page
by artgas_pro
HTML
<!DOCTYPE html>
<html>
<head>
</head>
<body>
Text and other info goes here to create a web page.
</body>
<script>
</script>
</html>
JavaScript
class Space {
constructor(asteroid) {
this.asteroid = asteroid;
this.zonds = [];
}
distanceToAsteroid(x, y, z) {
let ax = this.asteroid.getX();
let ay = this.asteroid.getY();
let az = this.asteroid.getZ();
return Math.sqrt((x-ax)*(x-ax) + (y-ay)*(y-ay) + (z-az)*(z-az))
}
addZond(zond) {
this.zonds.push(zond);
}
getZonds() {
return this.zonds;
}
}
class Asteroid {
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
getX() {
return this.x;
}
getY() {
return this.y;
}
getZ() {
return this.z;
}
}
class Zond {
constructor(space, x, y, z) {
this.space = space;
this.x = x;
this.y = y;
this.z = z;
}
getX() {
return this.x;
}
getY() {
return this.y;
}
getZ() {
return this.z;
}
detectAsteroid() {
return this.space.distanceToAsteroid(this.x, this.y, this.z);
}
}
let generateAllPositions = function(zond, distance) {
let res = [];
for (let x = 0; x <= 100; x++) {
for (let y = 0; y <= 100; y++) {
for (let z = 0; z <= 100; z++) {
let d = Math.trunc(Math.sqrt((x-zond.getX())*(x-zond.getX()) + (y-zond.getY())*(y-zond.getY()) + (z-zond.getZ())*(z-zond.getZ())));
if (d === distance) {
res.push({x: x, y: y, z : z});
}
}
}
}
return res;
}
let findAsteriodPotencialPositions = function(positions, zond, distance) {
let res = [];
for (let index in positions) {
let pos = positions[index];
let d = Math.trunc(Math.sqrt((pos.x-zond.getX())*(pos.x-zond.getX()) + (pos.y-zond.getY())*(pos.y-zond.getY()) + (pos.z-zond.getZ())*(pos.z-zond.getZ())));
if (d === distance) {
res.push({x: pos.x, y: pos.y, z : pos.z});
}
}
return res;
}
let findAsteroid = function(space) {
let distances = [];
let positions;
let zonds = space.getZonds();
let stepCount = 0;
for (let index in zonds) {
let zond = zonds[index];
let distance =...