xxxxxxxxxx
807
var g_width;
var g_height;
var g_main_title;
var g_ctr, g_mouse, g_ctr0;
let g_scale = 7;
let g_dragged = false;
let g_click_ell = false;
let g_loop_ccw = true;
let g_url_params = {};
let g_loop = true;
let g_tDeg = 0;
let g_a = 1.618034;
let g_locus_X1 = [];
let g_locus_X2 = [];
let g_locus_X3 = [];
let g_locus_X4 = [];
let g_locus_X5 = [];
let g_locus_X6 = [];
let g_locus_X6_mult = [];
let g_locus_X7 = [];
let g_locus_X8 = [];
let g_locus_X10 = [];
let g_locus_X11 = [];
let g_locus_X12 = [];
let g_locus_X15 = [];
let g_locus_X24 = [];
let g_locus_X40 = [];
//let g_locus_X88 = [];
let g_locus_X49 = [];
//let g_locus_X50 = [];
let g_locus_X53 = [];
let g_locus_X59 = [];
let g_locus_X67 = [];
let g_locus_X70 = [];
let g_locus_X77 = [];
let g_locus_X74 = [];
let g_locus_X91 = [];
let g_locus_X92 = [];
let g_locus_X96 = [];
let g_locus_X97 = [];
let g_locus_X99 = [];
//let g_locus_X100 = [];
let g_locus_X142 = [];
let g_locus_X144 = [];
//let g_locus_X162 = [];
let g_locus_X173 = [];
//let g_locus_X190 = [];
let g_locus_orthic_inc = [];
let g_locus_symmedial_vtx = [];
let g_locus_exc_symmedial_vtx = [];
let g_locus_medial_vtx = [];
let g_locus_feuerbach_vtx = [];
let g_locus_anticompl_vtx = [];
let g_locus_excentral_vtx = [];
let g_locus_intouch_vtx = [];
let g_locus_extouch_vtx = [];
let g_locus_orthic_vtx = [];
let g_locus_euler_vtx = [];
let g_env_x1x5 = [];
let g_env_x5x53 = [];
let g_env_x1x100 = [];
let g_env_x88x162 = [];
function clear_loci() {
g_locus_X1 = [];
g_locus_X2 = [];
g_locus_X3 = [];
g_locus_X4 = [];
g_locus_X5 = [];
g_locus_X6 = [];
g_locus_X6_mult = [];
g_locus_X7 = [];
g_locus_X8 = [];
g_locus_X10 = [];
g_locus_X11 = [];
g_locus_X12 = [];
g_locus_X15 = [];
g_locus_X24 = [];
g_locus_X40 = [];
//g_locus_X88 = [];
g_locus_X49 = [];
//g_locus_X50 = [];
g_locus_X53 = [];
g_locus_X59 = [];
g_locus_X67 = [];
g_locus_X70 = [];
g_locus_X77 = [];
g_locus_X74 = [];
g_locus_X90 = [];
g_locus_X91 = [];
g_locus_X92 = [];
g_locus_X96 = [];
g_locus_X97 = [];
g_locus_X99 = [];
g_locus_X142 = [];
g_locus_X144 = [];
g_locus_X173 = [];
g_locus_orthic_inc = [];
g_locus_symmedial_vtx = [];
g_locus_exc_symmedial_vtx = [];
g_locus_medial_vtx = [];
g_locus_feuerbach_vtx = [];
g_locus_anticompl_vtx = [];
g_locus_excentral_vtx = [];
g_locus_intouch_vtx = [];
g_locus_extouch_vtx = [];
g_locus_orthic_vtx = [];
g_locus_euler_vtx = [];
// envelopes
g_env_x2x3 = [];
g_env_x1x5 = [];
g_env_x5x53 = [];
g_env_x88x90 = [];
g_env_x1x100 = [];
g_env_x88x162 = [];
g_env_x190x799 = [];
}
function create_loci() {
let tDegStep = 0.1;
let tDegMax = 180; //142;
let tDeg_dt = 0.001;
clear_loci();
for (let tDeg = 0; tDeg < tDegMax; tDeg += tDegStep) {
let ons = orbit_normals(g_a, tDeg);
let x1 = trilin_X1(ons.o, ons.s);
let x2 = trilin_X2(ons.o, ons.s);
let x5 = trilin_X5(ons.o, ons.s);
let x53 = trilin_X53(ons.o, ons.s);
let x88 = trilin_X88(ons.o, ons.s);
let x90 = trilin_X90(ons.o, ons.s);
let x190 = trilin_X190(ons.o, ons.s);
g_locus_X1.push(x1);
g_locus_X2.push(x2);
g_locus_X3.push(trilin_X3(ons.o, ons.s));
g_locus_X4.push(trilin_X4(ons.o, ons.s));
g_locus_X5.push(x5);
g_locus_X6.push(trilin_X6(ons.o, ons.s));
g_locus_X7.push(trilin_X7(ons.o, ons.s));
g_locus_X8.push(trilin_X8(ons.o, ons.s));
g_locus_X10.push(trilin_X10(ons.o, ons.s));
g_locus_X11.push(trilin_X11(ons.o, ons.s));
g_locus_X12.push(trilin_X12(ons.o, ons.s));
g_locus_X15.push(trilin_X15(ons.o, ons.s));
g_locus_X24.push(trilin_X24(ons.o, ons.s));
g_locus_X40.push(trilin_X40(ons.o, ons.s));
g_locus_X49.push(trilin_X49(ons.o, ons.s));
//g_locus_X50.push(trilin_X50(ons.o, ons.s));
g_locus_X53.push(x53);
g_locus_X59.push(trilin_X59(ons.o, ons.s));
g_locus_X67.push(trilin_X67(ons.o, ons.s));
g_locus_X70.push(trilin_X70(ons.o, ons.s));
g_locus_X74.push(trilin_X74(ons.o, ons.s));
g_locus_X77.push(trilin_X77(ons.o, ons.s));
g_locus_X90.push(x90);
g_locus_X91.push(trilin_X91(ons.o, ons.s));
g_locus_X92.push(trilin_X92(ons.o, ons.s));
g_locus_X96.push(trilin_X96(ons.o, ons.s));
g_locus_X97.push(trilin_X97(ons.o, ons.s));
g_locus_X99.push(trilin_X99(ons.o, ons.s));
g_locus_X142.push(trilin_X142(ons.o, ons.s));
g_locus_X144.push(trilin_X144(ons.o, ons.s));
g_locus_X173.push(trilin_X173(ons.o, ons.s));
// orthic incenter
g_locus_orthic_inc.push(trilin_orthic_inc(ons.o, ons.s));
// envelope
let ons_dt = orbit_normals(g_a, tDeg + tDeg_dt);
let x1_dt = trilin_X1(ons_dt.o, ons_dt.s);
let x2_dt = trilin_X2(ons_dt.o, ons_dt.s);
let x5_dt = trilin_X5(ons_dt.o, ons_dt.s);
let x53_dt = trilin_X53(ons_dt.o, ons_dt.s);
let x88_dt = trilin_X88(ons_dt.o, ons_dt.s);
let x90_dt = trilin_X90(ons_dt.o, ons_dt.s);
let x100_dt = trilin_X100(ons_dt.o, ons_dt.s);
let x162_dt = trilin_X162(ons_dt.o, ons_dt.s);
let x190_dt = trilin_X190(ons_dt.o, ons_dt.s);
let x799_dt = trilin_X799(ons_dt.o, ons_dt.s);
// it's ok to push x5 since x2,x3,x5 are on euler's line
g_env_x2x3.push(inter_lines(x2, x5, x2_dt, x5_dt));
g_env_x1x5.push(inter_lines(x1, x5, x1_dt, x5_dt));
g_env_x5x53.push(inter_lines(x5, x53, x5_dt, x53_dt));
g_env_x1x100.push(inter_lines(x1, trilin_X100(ons.o,ons.s), x1_dt, x100_dt));
// these don't exist since their loci is the EB
g_env_x88x90.push(inter_lines(x88,x90,x88_dt,x90_dt));
g_env_x88x162.push(inter_lines(x88,trilin_X162(ons.o,ons.s),x88_dt,x162_dt))
g_env_x190x799.push(inter_lines(x190,trilin_X799(ons.o,ons.s),x190_dt,x799_dt))
}
g_locus_X6_mult = sym_locus_mult(g_a, g_locus_X6, 2e3 / (g_a * g_a * g_a));
// those which require all the way to 360
for (let tDeg = 0; tDeg <= 360; tDeg += tDegStep) {
let ons = orbit_normals(g_a, tDeg);
g_locus_symmedial_vtx.push(symmedial_vtx(ons.o, ons.s));
g_locus_exc_symmedial_vtx.push(exc_symmedial_vtx(ons.o, ons.s));
g_locus_medial_vtx.push(medial_vtx(ons.o, ons.s));
g_locus_feuerbach_vtx.push(feuerbach_vtx(ons.o, ons.s));
g_locus_anticompl_vtx.push(anticompl_vtx(ons.o, ons.s));
g_locus_excentral_vtx.push(excentral_vtx(ons.o, ons.s));
g_locus_intouch_vtx.push(intouch_vtx(ons.o, ons.s));
g_locus_extouch_vtx.push(extouch_vtx(ons.o, ons.s));
g_locus_orthic_vtx.push(orthic_vtx(ons.o, ons.s));
g_locus_euler_vtx.push(euler_vtx(ons.o, ons.s));
}
}
function create_chk(n, x, y, bf=false, val=false) {
let chk = createCheckbox(n, val);
chk.parent('ui');
chk.position(x, y);
chk.changed(chk_redraw);
chk.class(bf ? 'chkBold' : 'chk');
return chk;
}
function create_chk_bold(n, x, y, val=false) {
let chk = create_chk(n, x, y, false, val);
chk.style('font-weight', 'bold');
chk.style('color', 'blue');
//chk.class('chk_bold');
return chk;
}
function chk_redraw() {
if (!g_loop) redraw();
}
function create_title(lab, x, y, prep = true) {
let p = createP((prep ? '>>> ' : "") + lab);
p.parent('ui');
p.position(x, y);
p.class('lab');
return lab;
}
function create_slider(x, y) {
s = createSlider(0, 255, 100);
s.parent('ui');
s.position(x, y);
s.style('width', '100px');
return s;
}
function create_radio_a(x, y) {
let radio = createRadio();
radio.class('chk');
radio.parent('ui');
radio.option('1.1', 1.1);
radio.option('1.25', 1.25);
radio.option('1.352', 1.3522);
radio.option('1.3924', 1.3924);
radio.option('1.5', 1.5);
radio.option('φ=1.618', 1.618034);
radio.option('1.8364', 1.836377);
radio.option('2.0', 2);
radio.option('3.0', 3);
radio.option('5.0', 5);
radio._getInputChildrenArray()[5].checked = true;
radio.position(x, y);
radio.style('display', 'inline');
radio.changed(radio_a_changed);
return radio;
}
function radio_a_changed() {
g_a = g_radio_a.value();
create_loci();
redraw();
}
function create_title_ctr(lab, x, y, par, clr = 'red') {
let p = createP(lab);
p.parent(par);
p.style('color', clr)
return p;
}
function create_main_title(y) {
let div = createDiv();
let x = g_width / 2 - 160;
div.parent('ui');
div.position(x, y);
div.style('text-align', 'center');
div.class('lab');
create_title_ctr("Elliptic Billiard: Loci of Triangular Centers", 0, 0, div, 'blue');
create_title_ctr("Left Click: stop/go, Right Click: reverse<br>Drag: move billiard, Wheel: zoom", 0, 0, div, 'red');
return div;
}
function create_checkboxes() {
let xstep = 75;
let ystep = 20;
let chks = [];
let y = -ystep/2;
create_title("Billiard Aspect Ratio", 0, y);
g_main_title = create_main_title(y);
y += ystep/2;
y += ystep;
g_radio_a = create_radio_a(0, y);
y += ystep;
create_title("Elliptic Loci", 0, y);
y += ystep/2;
y += ystep;
chk_x1 = create_chk('X1', xstep * 0, y);
chk_x2 = create_chk('X2', xstep * 1, y);
chk_x3 = create_chk('X3', xstep * 2, y);
chk_x4 = create_chk('X4', xstep * 3, y);
y += ystep;
chk_x5 = create_chk('X5', xstep * 0, y);
chk_x7 = create_chk('X7', xstep * 1, y);
chk_x8 = create_chk('X8', xstep * 2, y);
chk_x9 = create_chk('X9', xstep * 3, y);
y += ystep;
chk_x10 = create_chk('X10', xstep * 0, y);
chk_x11 = create_chk('X11', xstep * 1, y);
chk_x12 = create_chk('X12', xstep * 2, y);
chk_x40 = create_chk('X40', xstep * 3, y);
y += ystep;
chk_x90 = create_chk( 'X90', xstep * 0, y);
chk_x142 = create_chk('X142', xstep * 1, y);
chk_x144 = create_chk('X144', xstep * 2, y);
chk_x173 = create_chk('X173', xstep * 3, y);
y += ystep;
create_title("Non-Elliptic Loci", 0, y);
y += ystep / 2;
y += ystep;
chk_x6 = create_chk('X6', xstep * 0, y);
chk_x6_mult = create_chk('X6+', xstep * 1, y);
chk_x15 = create_chk('X15', xstep * 2, y);
chk_x24 = create_chk('X24', xstep * 3, y);
y+=ystep;
chk_x49 = create_chk('X49', xstep * 0, y);
//chk_x50 = create_chk('X50', xstep * 1, y);
chk_x53 = create_chk('X53', xstep * 1, y);
chk_x59 = create_chk('X59', xstep * 2, y);
chk_x67 = create_chk('X67', xstep * 3, y);
y+=ystep;
chk_x70 = create_chk('X70', xstep * 0, y);
chk_x77 = create_chk('X77', xstep * 1, y);
chk_x74 = create_chk('X74', xstep * 2, y);
chk_x91 = create_chk('X91', xstep * 3, y);
y+=ystep;
chk_x92 = create_chk('X92', xstep * 0, y);
chk_x96 = create_chk('X96', xstep * 1, y);
chk_x97 = create_chk('X97', xstep * 2, y);
chk_x99 = create_chk('X99', xstep * 3, y);
y += ystep;
create_title("Boundary Swans (* = non-monotonic)", 0, y);
y += ystep / 2;
y += ystep;
chk_x88 = create_chk( 'X88*', xstep * 0, y, false);
chk_x100 = create_chk('X100', xstep * 1, y, false);
chk_x162 = create_chk('X162*', xstep * 2, y, false);
chk_x190 = create_chk('X190', xstep * 3, y, false);
y += ystep;
chk_x651 = create_chk('X651*', xstep * 0, y, false);
chk_x653 = create_chk('X653*', xstep * 1, y, false);
chk_x658 = create_chk('X658*', xstep * 2, y, false);
chk_x655 = create_chk('X655', xstep * 3, y, false);
y += ystep;
chk_x660 = create_chk('X660', xstep * 0, y, false);
chk_x662 = create_chk('X662', xstep * 1, y, false);
chk_x673 = create_chk('X673', xstep * 2, y, false);
chk_x771 = create_chk('X771*', xstep * 3, y, false);
y += ystep;
chk_x799 = create_chk('X799*', xstep * 0, y, false);
chk_x823 = create_chk('X823*', xstep * 1, y, false);
chk_x897 = create_chk('X897*', xstep * 2, y, false);
chk_x1156 = create_chk('X1156', xstep * 3, y, false);
y += ystep;
chk_x1492 = create_chk('X1492*', xstep * 0, y, false);
chk_x1821 = create_chk('X1821*', xstep * 1, y, false);
y += ystep;
create_title("Notable Circles", 0, y);
y += ystep / 2;
y += ystep;
chk_incircle = create_chk('Incircle', xstep * 0, y);
chk_circum = create_chk('Circum', xstep * 1, y);
chk_excircum = create_chk('Excircum', xstep * 2, y);
chk_npc = create_chk('9-Point', xstep * 3, y);
y += ystep
chk_excirc = create_chk('Excircs', xstep * 0, y);
chk_ant_incirc = create_chk('AntIncirc', xstep * 1, y);
chk_cosine_circle = create_chk('ExCoscirc', xstep * 2, y);
y += ystep;
create_title("Derived Triangles", 0, y);
y += ystep / 2;
chk_tri_locus = create_chk_bold('Show Locus', xstep * 2.5, y, g_url_params.tri_locus=='T');
y += ystep;
chk_exc = create_chk('ΔExctrl', xstep * 0, y);
chk_x1p = create_chk('ΔIntouch', xstep * 1, y);
chk_ext = create_chk('ΔExtouch', xstep * 2, y);
chk_medial = create_chk('ΔMedial', xstep * 3, y);
y += ystep;
chk_anticompl = create_chk('ΔAnticpl', xstep * 0, y);
chk_feu = create_chk('ΔFeuerb', xstep * 1, y);
chk_orthic = create_chk('ΔOrthic', xstep * 2, y, false,g_url_params.orthic=='T');
chk_orthic_inc = create_chk('OrthicInc', xstep * 3, y);
y += ystep;
chk_euler_tri = create_chk('ΔEuler', xstep * 0, y);
chk_x15p = create_chk('ΔX15p', xstep * 1, y);
chk_symmedial = create_chk('ΔSymm', xstep * 2, y);
chk_exc_symmedial = create_chk('ΔExcSymm', xstep * 3, y);
y += ystep / 2;
create_title("Constructions & Envelopes", 0, y);
y += ystep / 2;
y += ystep;
chk_euler = create_chk('EulerLin', xstep * 0, y);
chk_alt_feet = create_chk('Alt Feet', xstep * 1, y);
chk_x9_lines = create_chk('X9lns', xstep * 2, y);
chk_exc_perps = create_chk('ExcPerps', xstep * 3, y);
chk_sidelengths = create_chk('Sides', xstep * 4, y);
y += ystep;
chk_env_x2x3 = create_chk('env2,3', xstep * 0, y);
chk_env_x1x5 = create_chk('env1,5', xstep * 1, y);
chk_env_x5x53 = create_chk('env5,53', xstep * 2, y);
chk_env_x1x100 = create_chk('env1,100', xstep * 3, y);
y += ystep;
chk_env_x88x90 = create_chk('env88,90', xstep * 0, y);
chk_env_x88x162 = create_chk('env88,162', xstep * 1, y);
chk_env_x190x799 = create_chk('env190,799', xstep * 2, y);
y += ystep/2;
create_title("© 2019-20 Dan Reznik -- dreznik _at_ gmail _dot_ com", 0, y, false);
y += ystep;
create_title("Visit our <a href=https://dan-reznik.github.io/Elliptical-Billiards-Triangular-Orbits/ target=_blank>Main Page</a>, <a href=http://mathworld.wolfram.com/ target=_blank>MathWorld</a>, and <a href=https://faculty.evansville.edu/ck6/encyclopedia/ETC.html target=_blank>ETC</a>", 0, y, false);
y += ystep;
//create_title("Visit <a href=http://mathworld.wolfram.com/ target=_blank>MathWorld</a> and <a href=https://faculty.evansville.edu/ck6/encyclopedia/ETC.html target=_blank>ETC</a>", 0, y, false);
}
function windowResized() {
g_width = windowWidth;
g_height = windowHeight;
let pos = g_main_title.position();
g_main_title.position(g_width / 2 - 160, pos[1]);
resizeCanvas(windowWidth, windowHeight);
}
function setup() {
g_width = windowWidth;
g_height = windowHeight;
g_url_params = getURLParams();
//http://p5js.org?year=2014&month=May&day=15
//text(params.day, 10, 20);
//text(params.month, 10, 40);
//text(params.year, 10, 60);
//console.log("what are they",g_url_params);
create_checkboxes();
canvas = createCanvas(g_width, g_height);
canvas.parent('canvas');
//frameRate(15);
create_loci();
g_ctr0 = [g_width / 2, g_height / 2];
g_ctr = g_ctr0;
g_mouse = g_ctr0;
}
function draw_tri_locus(lab, chk, ons, locus, draw_fn, vtx_fn, rgb) {
if (chk.checked()) {
draw_fn(ons, rgb);
if (chk_tri_locus.checked())
draw_locus(locus, ons, lab, vtx_fn, rgb);
}
}
function draw() {
background(220, 220, 200);
let ons = orbit_normals(g_a, g_tDeg);
let exc = excentral_triangle(ons.o, ons.s);
text()
push();
translate(g_ctr[0], g_ctr[1]);
scale(g_width / g_scale);
draw_billiard(g_a);
draw_orbit(ons, chk_sidelengths.checked());
//experimental: mitten of excentral's extangents tri
//draw_labeled_point(ons,999,trilin_X9_ext_exc,[40,80,120]);
//draw_text('© 2019 Dan S. Reznik', [1.75, 1.5], [0, 0, 0]);
if (chk_incircle.checked())
draw_circle(ons, trilin_X1, intouch_vtx, clr_dark_green);
if (chk_circum.checked())
draw_circle(ons, trilin_X3, (o, s) => ons.o[0], clr_purple);
if (chk_excircum.checked())
draw_circle(ons, trilin_X40, (o, s) => exc[0], clr_purple);
if (chk_npc.checked())
draw_circle(ons, trilin_X5, medial_vtx, clr_pink);
if (chk_excirc.checked())
draw_excircles(ons.o, ons.s, clr_dark_green);
if (chk_ant_incirc.checked())
draw_ant_incircle(ons.o, ons.s, clr_light_blue);
// loci: elliptic
if (chk_x1.checked())
draw_locus(g_locus_X1, ons, 1, trilin_X1, clr_dark_green);
if (chk_x2.checked())
draw_locus(g_locus_X2, ons, 2, trilin_X2, clr_brown);
if (chk_x3.checked())
draw_locus(g_locus_X3, ons, 3, trilin_X3, clr_purple);
if (chk_x4.checked())
draw_locus(g_locus_X4, ons, 4, trilin_X4, clr_dark_orange);
if (chk_x5.checked())
draw_locus(g_locus_X5, ons, 5, trilin_X5, clr_pink);
if (chk_x7.checked())
draw_locus(g_locus_X7, ons, 7, trilin_X7, [155, 165, 0]);
if (chk_x8.checked())
draw_locus(g_locus_X8, ons, 8, trilin_X8, [50, 50, 100]);
if (chk_x9.checked())
draw_labeled_point(ons, 9, trilin_X9, clr_dark_red);
if (chk_x10.checked())
draw_locus(g_locus_X10, ons, 10, trilin_X10, [100, 50, 50]);
if (chk_x7.checked())
draw_locus(g_locus_X7, ons, 7, trilin_X7, [155, 165, 0]);
if (chk_x11.checked())
draw_locus(g_locus_X11, ons, 11, trilin_X11, [150, 150, 20]);
if (chk_x12.checked())
draw_locus(g_locus_X12, ons, 12, trilin_X12, [250, 100, 50]);
if (chk_x40.checked())
draw_locus(g_locus_X40, ons, 40, trilin_X40, [20, 20, 255]);
if (chk_x90.checked())
draw_locus(g_locus_X90, ons, 90, trilin_X90, clr_light_blue);
if (chk_x142.checked())
draw_locus(g_locus_X142, ons, 142, trilin_X142, [100, 0, 100]);
if (chk_x144.checked())
draw_locus(g_locus_X144, ons, 144, trilin_X144, [0, 100, 100]);
if (chk_x173.checked())
draw_locus(g_locus_X173, ons, 173, trilin_X173, [100, 250, 50]);
// loci: non-ell
if (chk_x6.checked())
draw_locus(g_locus_X6, ons, 6, trilin_X6, clr_blue);
if (chk_x6_mult.checked())
draw_locus_only(g_locus_X6_mult, clr_red);
if (chk_x15.checked())
draw_locus(g_locus_X15, ons, 15, trilin_X15, [150, 0, 50]);
if (chk_x24.checked())
draw_locus(g_locus_X24, ons, 24, trilin_X24, clr_light_blue);
if (chk_x49.checked())
draw_locus(g_locus_X49, ons, 49, trilin_X49, clr_dark_green);
//if (chk_x50.checked())
//draw_locus(g_locus_X50, ons, 53, trilin_X50, clr_slate);
if (chk_x53.checked())
draw_locus(g_locus_X53, ons, 53, trilin_X53, clr_dark_orange);
if (chk_x59.checked())
draw_locus(g_locus_X59, ons, 59, trilin_X59, [180, 80, 70]);
if (chk_x67.checked())
draw_locus(g_locus_X67, ons, 67, trilin_X67, clr_pink);
if (chk_x70.checked())
draw_locus(g_locus_X70, ons, 70, trilin_X70, clr_indigo);
if (chk_x77.checked())
draw_locus(g_locus_X77, ons, 77, trilin_X77, clr_dark_gold);
if (chk_x74.checked())
draw_locus(g_locus_X74, ons, 74, trilin_X74, [100, 200, 100]);
if (chk_x91.checked())
draw_locus(g_locus_X91, ons, 91, trilin_X91, clr_slate_blue);
if (chk_x92.checked())
draw_locus(g_locus_X92, ons, 92, trilin_X92, clr_tourquoise);
if (chk_x96.checked())
draw_locus(g_locus_X96, ons, 96, trilin_X96, clr_sea_green);
if (chk_x97.checked())
draw_locus(g_locus_X97, ons, 97, trilin_X97, clr_chocolate);
if (chk_x99.checked())
draw_locus(g_locus_X99, ons, 99, trilin_X99, [100, 100, 100]);
// loci: swans (on-boundary)
if (chk_x88.checked())
draw_labeled_point(ons, 88, trilin_X88, [0, 0, 0]);
if (chk_x100.checked())
draw_labeled_point(ons, 100, trilin_X100, [0, 0, 0]);
if (chk_x162.checked())
draw_labeled_point(ons, 162, trilin_X162, [0, 0, 0]);
if (chk_x190.checked())
draw_labeled_point(ons, 190, trilin_X190, [0, 0, 0]);
if (chk_x651.checked())
draw_labeled_point(ons, 651, trilin_X651, [0, 0, 0]);
if (chk_x653.checked())
draw_labeled_point(ons, 653, trilin_X653, [0, 0, 0]);
if (chk_x655.checked())
draw_labeled_point(ons, 655, trilin_X655, [0, 0, 0]);
if (chk_x658.checked())
draw_labeled_point(ons, 658, trilin_X658, [0, 0, 0]);
if (chk_x660.checked())
draw_labeled_point(ons, 660, trilin_X660, [0, 0, 0]);
if (chk_x662.checked())
draw_labeled_point(ons, 662, trilin_X662, [0, 0, 0]);
if (chk_x673.checked())
draw_labeled_point(ons, 673, trilin_X673, [0, 0, 0]);
if (chk_x771.checked())
draw_labeled_point(ons, 771, trilin_X771, [0, 0, 0]);
if (chk_x799.checked())
draw_labeled_point(ons, 799, trilin_X799, [0, 0, 0]);
if (chk_x823.checked())
draw_labeled_point(ons, 823, trilin_X823, [0, 0, 0]);
//897,1156,1492,1821
if (chk_x897.checked())
draw_labeled_point(ons, 897, trilin_X897, [0, 0, 0]);
if (chk_x1156.checked())
draw_labeled_point(ons, 1156, trilin_X1156, [0, 0, 0]);
if (chk_x1492.checked())
draw_labeled_point(ons, 1492, trilin_X1492, [0, 0, 0]);
if (chk_x1821.checked())
draw_labeled_point(ons, 1821, trilin_X1821, [0, 0, 0]);
// loci: vertices
if (chk_orthic_inc.checked())
draw_locus(g_locus_orthic_inc, ons, '1h', trilin_orthic_inc, clr_purple, 0.02);
if (chk_euler.checked())
draw_euler_line(ons, clr_gray);
if (chk_alt_feet.checked())
draw_alt_feet(ons.o, ons.s, clr_dark_orange);
if (chk_exc_perps.checked())
draw_exc_perps(ons.o, ons.s, clr_dark_green);
if (chk_x9_lines.checked())
draw_x9_lines(ons.o, ons.s, clr_dark_red);
if (chk_x15p.checked())
draw_pedal_x15(ons, [150, 0, 50]);
// tris with loci
draw_tri_locus("int",
chk_x1p, ons,
g_locus_intouch_vtx,
draw_intouch,
intouch_vtx,
clr_light_green);
draw_tri_locus("exc",
chk_exc, ons,
g_locus_excentral_vtx,
draw_excentral,
excentral_vtx,
clr_dark_green);
draw_tri_locus("med",
chk_medial, ons,
g_locus_medial_vtx,
draw_medial,
medial_vtx,
clr_dark_red);
draw_tri_locus("ant",
chk_anticompl, ons,
g_locus_anticompl_vtx,
draw_anticompl,
anticompl_vtx,
clr_light_blue);
draw_tri_locus("feu",
chk_feu, ons,
g_locus_feuerbach_vtx,
draw_feuerbach,
feuerbach_vtx,
clr_brown);
draw_tri_locus("sym",
chk_symmedial, ons,
g_locus_symmedial_vtx,
draw_symmedial,
symmedial_vtx,
clr_indigo);
draw_tri_locus("sym'",
chk_exc_symmedial, ons,
g_locus_exc_symmedial_vtx,
draw_exc_symmedial,
exc_symmedial_vtx,
clr_dark_red);
draw_tri_locus("ort",
chk_orthic, ons,
g_locus_orthic_vtx,
draw_orthic,
orthic_vtx,
clr_dark_orange);
draw_tri_locus("ext",
chk_ext, ons,
g_locus_extouch_vtx,
draw_extouch,
extouch_vtx,
clr_gray);
draw_tri_locus("eul",
chk_euler_tri, ons,
g_locus_euler_vtx,
draw_euler_tri,
euler_vtx,
clr_orange);
// better to draw these last
if (chk_cosine_circle.checked()) {
draw_cosine_circle(ons.o, ons.s, clr_red);
}
if (chk_env_x2x3.checked())
draw_env(ons, g_a, g_tDeg, g_env_x2x3,
clr_purple, trilin_X2, trilin_X3);
if (chk_env_x1x5.checked())
draw_env(ons, g_a, g_tDeg, g_env_x1x5,
clr_purple, trilin_X1, trilin_X5);
if (chk_env_x5x53.checked())
draw_env(ons, g_a, g_tDeg, g_env_x5x53,
clr_purple, trilin_X5, trilin_X53);
if (chk_env_x88x90.checked())
draw_env(ons, g_a, g_tDeg, g_env_x88x90,
clr_purple, trilin_X88, trilin_X90);
if (chk_env_x88x162.checked())
draw_env(ons, g_a, g_tDeg, g_env_x88x162,
clr_purple, trilin_X88, trilin_X162);
if (chk_env_x190x799.checked())
draw_env(ons, g_a, g_tDeg, g_env_x190x799,
clr_purple, trilin_X190, trilin_X799);
if (chk_env_x1x100.checked())
draw_env(ons, g_a, g_tDeg, g_env_x1x100,
clr_purple, trilin_X1, trilin_X100);
pop();
if (g_loop) g_tDeg += (g_loop_ccw ? 0.125 : -0.125);
}
function mouse_in_ell(a, b = 1) {
let m = [mouseX, mouseY];
let p = vscale(vdiff(m, g_ctr), g_scale / g_width);
return in_ell(a, b, p);
}
function mousePressed() {
g_ctr0 = g_ctr;
g_dragged = false;
g_mouse = [mouseX, mouseY];
g_click_ell = mouse_in_ell(g_a);
if (g_click_ell && g_loop) {
noLoop();
g_loop = false;
} else if (g_click_ell && !g_loop) {
if (mouseButton !== LEFT)
g_loop_ccw = !g_loop_ccw;
loop();
g_loop = true;
}
return (false);
}
function mouseReleased() {
//if (!g_dragged && !g_loop) {
// g_loop = true;
// loop();
//}
//if(g_dragged && g_loop) loop();
g_click_ell = false;
}
function mouseDragged() {
if (g_click_ell) {
g_dragged = true;
//noLoop();
//g_loop = false;
g_ctr = vsum(vdiff([mouseX, mouseY], g_mouse), g_ctr0);
if (!g_loop) redraw();
//redraw();
}
}
function mouseWheel(event) {
//if (mouse_in_ell(2*g_a,2)) {
if (event.delta > 0)
g_scale *= 1.05;
else
g_scale *= 0.95;
//uncomment to block page scrolling
if (!g_loop) redraw();
return false;
//}
}