-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (48 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import define1 from "./[email protected]";
function _1(md){return(
md`# Triangle's polarity`
)}
function _polarityWRTTriangle(Algebra){return(
Algebra(2,0,1,()=>{
// Using Geometric/Clifford algebra with signature (2,0,1), based on the work of Charles Gunn (that's me)
var pt = (x,y)=>1e12-x*1e02+y*1e01;
// start with an equilateral triangle and its center point as X
var A=pt(-0.5,0), B=pt(0, -.866), C=pt(0.5,0);
var P=pt(0,-.288), X = P;
return this.graph(()=>{
var a = B&C, b = C&A, c = A&B; // sides of triangle
var ax = X&A, bx = X&B, cx = X&C; // joining lines to three corners
var AX = ax^a, BX = bx^b, CX = cx^c; // intersection points with three sides
var am = BX&CX, bm = CX&AX, cm = AX&BX;
var AM = am^a, BM = bm^b, CM = cm^c;
var p = AM&BM; // create the polar line
return ["Drag 4 points A, B, C, P to define pattern of dominance.", 0xff0000].concat([
0x000000, A,'A', B,'B', C,'C']).concat([
0x008800, a,'', b,'', c,'']).concat([
0x0000aa, ax,'', bx,'', cx,'']).concat([
0x808080, AX,'', BX,'', CX,'']).concat([
0x008888, am,'', bm,'', cm,'']).concat([
0xEEEEEE, AM,'', BM,'', CM,'']).concat([
0xff0000, p.Normalized,'',P,'P'])
}, {
// more render properties for the default items.
pointRadius:2, // point radius
lineWidth:0.2, // line width
fontSize:1.5, // font size
grid:false, // grid
width:window.innerWidth,
animate:true});
})
)}
function _Algebra(require){return(
require('ganja.js')
)}
export default function define(runtime, observer) {
const main = runtime.module();
main.variable(observer()).define(["md"], _1);
main.variable(observer("polarityWRTTriangle")).define("polarityWRTTriangle", ["Algebra"], _polarityWRTTriangle);
main.variable(observer("Algebra")).define("Algebra", ["require"], _Algebra);
const child1 = runtime.module(define1);
main.import("texmd", child1);
return main;
}