pedantic: s/polyhedron/polytope: n=3 case isn't 3D

This commit is contained in:
root 2025-04-26 12:36:45 +00:00
parent 769043c5cb
commit d57d49a194

View file

@ -13,7 +13,7 @@ const SURFACE_EARTH = 2;
let surface = SURFACE_CIRCLES; let surface = SURFACE_CIRCLES;
let physics = false; let physics = false;
let skeleton = false; let skeleton = false;
let polyhedron = false; let polytope = false;
let aside_size; let aside_size;
@ -53,7 +53,7 @@ function draw() {
draw_charges(sphere_radius); draw_charges(sphere_radius);
if (skeleton) draw_skeleton(sphere_radius); if (skeleton) draw_skeleton(sphere_radius);
if (polyhedron) { if (polytope) {
if (physics || faces.length === 0) find_faces(); if (physics || faces.length === 0) find_faces();
draw_faces(sphere_radius); draw_faces(sphere_radius);
} }
@ -70,7 +70,7 @@ function find_faces() {
for (let i = 2; i < charges.length; i += 1) { for (let i = 2; i < charges.length; i += 1) {
for (let j = 1; j < i; j += 1) { for (let j = 1; j < i; j += 1) {
for (let k = 0; k < j; k += 1) { for (let k = 0; k < j; k += 1) {
// Check if p1 p2 p3 form a face of the convex polyhedron // Check if p1 p2 p3 form a face of the convex polytope
// enclosing all vertices ... // enclosing all vertices ...
const p1 = charges[i].position; const p1 = charges[i].position;
const p2 = charges[j].position; const p2 = charges[j].position;
@ -97,7 +97,7 @@ function find_faces() {
// If L intersects the plane, q1 and q2 are on // If L intersects the plane, q1 and q2 are on
// opposite sides of the plane generated by p1 p2 p3, // opposite sides of the plane generated by p1 p2 p3,
// so p1 p2 p3 can't be a face. If we want the // so p1 p2 p3 can't be a face. If we want the
// polyhedron to be convex. Which we do. // polytope to be convex. Which we do.
// //
// A point k is on the plane generated by p1 p2 p3 iff // A point k is on the plane generated by p1 p2 p3 iff
// dot(k - p1, normal) = 0. Let n := normal. // dot(k - p1, normal) = 0. Let n := normal.
@ -269,7 +269,7 @@ function keyPressed() {
} else if (key == 'f') { } else if (key == 'f') {
skeleton = !skeleton; skeleton = !skeleton;
} else if (key == 'g') { } else if (key == 'g') {
polyhedron = !polyhedron; polytope = !polytope;
} else if (key >= '0' && key <= '9') { } else if (key >= '0' && key <= '9') {
make_charges(int(key)); make_charges(int(key));
faces = []; faces = [];