Skip to content

Instantly share code, notes, and snippets.


Jim B d3x0r

  • Las Vegas
View GitHub Profile
d3x0r /
Last active Jul 8, 2020
Discussion regarding matrix composition from angle-angle-angle vectors

This is an alternative method to get a basis from a quaternion (log quaternion)... or from angle/angle/angle. This is built by rotating the constant vectors (1,0,0), (0,1,0), (0,0,1) via standard quaternion rotation, and reducing common factors. The 0s and 1s collapse out a lot of the terms of apply. It ends up being less work to get the 3 vector basis than to rotate a single point; although if you USE the basis to multiply with the point; that increases the work to excess of just rotating a vector directly...

This is the base form... the steps will be broken out for phases of substitution. As implemented here

d3x0r / twist.js
Last active Jul 1, 2020
Twist JS Function combined
View twist.js
// this = { x: xAngle, y:yAngle, z:zAngle, nL: |x|+|y|+|z|, nR:sqrt( xx+yy+zz ) }
// nR = normRectangular
// nL = normLinear
function twistQuaternion(theta) {
// function getBasis() { // computes xyz basis vectors (matrix)
// this is angle-angle-angle log-quaternion
d3x0r /
Last active Jun 19, 2020
a^2 + b^2 / c^2 <=M (=1)
 a^2 + b^2    (1)

Law of cosines, replace C in terms of A and B and Theta...

View PathTest.js
//const JSOX = require( "./jsox.js" );
let nodes = 0;
function node() {
nodes++; = nodes;
this.mates = [];
node.prototype.add = function(n) { this.mates.push(n) }
node.prototype.isEdge = function(x) { return this.mates.find(m=>m===x) }
d3x0r / lnQuat.js
Last active Jun 11, 2020
compute initial log quaternion
View lnQuat.js
// theta - angle in radians, d = {x, y, z } direction/unnormalized
function lnQuat( theta, d ){
// if no rotation, then nothing.
const dl = 1/Math.sqrt( d.x*d.x + d.y*d.y + d.z*d.z ); // 1/ d length = normalize d
const t = theta/2;
const ct2 = Math.cos( t ); // sqrt( 1/2(1 + cos theta)) - half angle subst
const st2 = Math.sin( t ); // sqrt( 1/2(1 - cos theta)) - half angle subst
const w = ct2;
const x = dl * d.x * st2;
d3x0r /
Created Jun 8, 2020
Node BackingStore Debug Crash

You can download this gist as a single repository.


node-gyp configure --debug
node-gyp build --debug
d3x0r / ComplexNumberTest.html
Last active May 26, 2020
Testing/Learning DualComplex numbers...
View ComplexNumberTest.html
<CANVAS WIDTH=1000 height=1000 ID="testSurface" style="width:500px;height:500px"></CANVAS>
<p> for (A+Be)+(C+De)i
<p> for (<SPAN ID="Aval">A</SPAN>+<SPAN ID="Bval">A</SPAN>e)+(<SPAN ID="Cval">A</SPAN>+<SPAN ID="Dval">D</SPAN>e)i
<p> A <input type="range" min="-100" max="100" id="A"></input>
<p> B <input type="range" min="-100" max="100" id="B"></input>
<p> C <input type="range" min="-100" max="100" id="C"></input>
<p> D <input type="range" min="-100" max="100" id="D"></input>
d3x0r / test.c
Last active May 18, 2020
Trust in the Optimizer ???
View test.c
// test available here
// This is the basic function
int upTree( int N ) {
int n;
for( n = 0; n < 32; n++ ) if( !(N&(1<<n)) ) break;
return (N & ~((0x1)<<(n+1))) | ( 0x01 << n );
d3x0r /
Last active May 10, 2020
Get the preferred folding direction for a quad; assuming 'best' is 'contains most inner space'

Determining the fold direction of a quadrilateral.

Fold Comparison

This function calculat(ed) the lengths of the diagonals of the quad p1 -> p3 and p2 -> p4, and resulted with a fold on the shortest of the diagonals. That works in some cases.

The function now calculates the nearest points on the two crossing lines of the quad and picks the line furthest along the normal passed in; this might be called 'the choice enclosing the most area'. The other

You can’t perform that action at this time.