馃悕馃悕馃悕
at main 42 lines 1.1 kB view raw
1 2import "/code/math/complex.js"; 3 4const c = $complex.cartesian; 5 6export function projectiveShift(z, phi=0, psi=1) { 7 const xMag = c.mag(z); 8 const xAngle = c.angle(z); 9 const angleDiff = xAngle - phi; 10 const newMag = xMag + Math.cos(angleDiff); 11 return { 12 re: newMag * Math.cos(xAngle * psi), 13 im: newMag * Math.sin(xAngle * psi) 14 }; 15} 16 17 18 19// claude-generated, not yet reviewed, probably jank 20function fullThing(z, phi, psi, c_val, d_val, twist, squoosh_x, squoosh_y) { 21 const shifted = projectiveShift(z, phi, psi); 22 const halfEbb = c.of(-c_val * 0.5, -d_val * 0.5); 23 const mid = c.add(shifted, halfEbb); 24 const mids = c.of(mid.re / squoosh_x, mid.im / squoosh_y); 25 26 const cosTwist = Math.cos(twist); 27 const sinTwist = Math.sin(twist); 28 const rotated = c.of( 29 mids.re * cosTwist - mids.im * sinTwist, 30 mids.re * sinTwist + mids.im * cosTwist 31 ); 32 33 return c.add(rotated, halfEbb); 34} 35 36 37export function translatedProjectiveShift(z, t, phi=0, psi=1) { 38 const shifted = projectiveShift(z, phi, psi); 39 return c.sub(shifted, t); 40} 41 42