getDefaultShape = {
const ftl = 0
const ftr = 1
const fbl = 2
const fbr = 3
const ntl = 4
const ntr = 5
const nbl = 6
const nbr = 7
const polygons = [
[ ntl, ntr, ftr, ftl ],
[ ftr, ntr, nbr, fbr ],
[ fbl, fbr, nbr, nbl ],
[ ntl, ftl, fbl, nbl ],
[ ftl, ftr, fbr, fbl ],
[ ntl, nbl, nbr, ntr ],
]
const tip = [ ntl, ntr, nbl, nbr ]
const x = 1.0
return function getDefaultShape( orbit, scale=[1,,10] )
{
const prototype = [[1,0,1]] .concat( orbit )
const eight = grmul( [8], scale )
const five = grmul( [5], scale )
const four = grmul( [4], scale )
const [y,z] = orbit .map( grfloat )
var yellow = [ four, four, four ]
// find the corner of the octant
var first, second, third
var firstNeg, secondNeg, thirdNeg
var blue, green
var swapParity = false
// TODO: clean this up; not all these cases are possible, since
// the orbit is canonicalized. There are probably only two choices,
// the first two. X should always be the greatest.
if ( x >= y ) {
if ( y >= z ) {
swapParity = true
blue = [ eight, [], [] ]
green = [ five, five, [] ]
} else if ( x >= z ) {
blue = [ eight, [], [] ]
green = [ five, [], five ]
} else {
swapParity = true
blue = [ [], eight, [] ]
green = [ five, [], five ]
}
} else {
if ( x >= z ) {
blue = [ [], eight, [] ]
green = [ five, five, [] ]
} else if ( y >= z ) {
swapParity = true
blue = [ [], eight, [] ]
green = [ [], five, five ]
} else {
blue = [ [], [], eight ]
green = [ [], five, five ]
}
}
const centroid = scalarmul( [1,,3], vectoradd( vectoradd( blue, green ), yellow ) )
const trianglePlane = planeFromPoints( blue, green, yellow )
const strutCenterline = [ [[],[],[]], prototype ]
const endCenter = linePlaneIntersection( strutCenterline, trianglePlane )
const ftl_offset = vectorsub( swapParity? green : yellow, centroid )
const fbl_offset = vectorsub( swapParity? yellow : green, centroid )
const ftl_v = vectoradd( endCenter, ftl_offset )
const fbl_v = vectoradd( endCenter, fbl_offset )
const fbr_v = vectorsub( endCenter, ftl_offset )
const ftr_v = vectorsub( endCenter, fbl_offset )
const nbr_v = ftl_v .map( grneg )
const ntr_v = fbl_v .map( grneg )
const ntl_v = fbr_v .map( grneg )
const nbl_v = ftr_v .map( grneg )
return {
prototype,
vertices: [ ftl_v, ftr_v, fbl_v, fbr_v, ntl_v, ntr_v, nbl_v, nbr_v ],
polygons,
tip,
waist: []
}
}
}