a^2 + b^2 (1)
---------
c^2
Law of cosines, replace C in terms of A and B and Theta...
// best version | |
// would like to do CreateEvent in static initializer; but that's not a constant expression. | |
#define PTHREAD_ONCE_INIT { 0, 0 } | |
struct pthread_once { | |
HANDLE event; | |
volatile LONG inited; | |
}; | |
typedef struct pthread_once pthread_once_t; |
a^2 + b^2 (1)
---------
c^2
Law of cosines, replace C in terms of A and B and Theta...
//const JSOX = require( "./jsox.js" ); | |
let nodes = 0; | |
function node() { | |
nodes++; | |
this.id = nodes; | |
this.mates = []; | |
} | |
node.prototype.add = function(n) { this.mates.push(n) } | |
node.prototype.isEdge = function(x) { return this.mates.find(m=>m===x) } |
// 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; |
MASK Sets are arrays of bit-fields of some bit-width (5, 3, ... ) they are set/returned as unsigned integer values. They are stored-in/accessed via a uint8_t which gives byte-offset calculations. they return their value as uintmax_t from the offset memory address directly; Some platforms(Arm) may SIGBUS because of wide offset accesses spanning word boundaries. This issue may be fixed by rounding, grabbing the word aligned values and shifting manually Declarataion/Instantiation of a mask set is done with MASKSET macro below
Deprecated; please see https://github.com/d3x0r/BloomNHash
The associated code in this does not work 100%.
<HTML> | |
<BODY> | |
<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> |
// test available here | |
// https://godbolt.org/z/EiXxwW | |
// 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 ); | |
} |
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