Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Last active January 24, 2024 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hermann-SW/b3e85c8fe6827cd29238c14f9da346be to your computer and use it in GitHub Desktop.
Save Hermann-SW/b3e85c8fe6827cd29238c14f9da346be to your computer and use it in GitHub Desktop.
Good enough GP3D generated C36.10.fixed version
const jscad = require('@jscad/modeling')
const { colorize } = jscad.colors
const { cuboid, cube, sphere, cylinder, circle, polygon } = jscad.primitives
const { rotate, translate } = jscad.transforms
const { degToRad } = jscad.utils
const { add, normalize, length, scale, dot } = jscad.maths.vec3
const { extrudeRotate, extrudeLinear } = require('@jscad/modeling').extrusions
const { intersect, subtract, union } = require('@jscad/modeling').booleans
const { hull, hullChain } = require('@jscad/modeling').hulls
const { vectorText } = require('@jscad/modeling').text
function map_3D(c, sc) {
return [Math.cos(degToRad(c[0]))*Math.sin(degToRad(c[1]))*sc, Math.sin(degToRad(c[0]))*Math.sin(degToRad(c[1]))*sc, Math.cos(degToRad(c[1]))*sc]
}
eps = 0.000010000000000000000000000000000000000000
sc = 6.0000000000000000000000000000000000000
coords = [[105.94578365549577000000000000000000000, 89.014733792432000000000000000000000000], [129.05500192815840000000000000000000000, 107.73640651121319000000000000000000000], [122.30972392423993000000000000000000000, 127.71232355724267000000000000000000000], [180, 147.15863380965277000000000000000000000], [180, 169.05287793655090000000000000000000000], [225, 90], [245.10390936101710000000000000000000000, 71.030936286407240000000000000000000000], [270, 54.735610317245346000000000000000000000], [270, 32.841366190347210000000000000000000000], [270, 10.947122063449068000000000000000000000], [90, 10.947122063449068000000000000000000000], [90, 32.841366190347210000000000000000000000], [90, 54.735610317245346000000000000000000000], [113.18515789774465000000000000000000000, 70.534296480126410000000000000000000000], [75.597191140584300000000000000000000000, 88.773498385956340000000000000000000000], [69.533004156812780000000000000000000000, 67.450927679746330000000000000000000000], [52.788051575742460000000000000000000000, 82.282914879995500000000000000000000000], [37.211948424257540000000000000000000000, 97.717085120004500000000000000000000000], [334.41902365500374000000000000000000000, 79.064028274001700000000000000000000000], [336.04512254075354000000000000000000000, 106.63363351165339000000000000000000000], [313.71634396725690000000000000000000000, 115.57248257820386000000000000000000000], [0, 169.05287793655090000000000000000000000], [0, 147.15863380965277000000000000000000000], [57.874169844561420000000000000000000000, 128.24193035086205000000000000000000000], [51.312785609444290000000000000000000000, 109.85483368569070000000000000000000000], [20.466995843187217000000000000000000000, 112.54907232025364000000000000000000000], [0, 125.26438968275465000000000000000000000], [228.93428612206466000000000000000000000, 59.592336605822440000000000000000000000], [216.30156855049154000000000000000000000, 39.039035941107954000000000000000000000], [149.97041952940990000000000000000000000, 46.577649154052350000000000000000000000], [143.60969003773818000000000000000000000, 67.852545330701900000000000000000000000], [167.67349268606006000000000000000000000, 86.445690357926950000000000000000000000], [158.90949820473946000000000000000000000, 106.48216218396492000000000000000000000], [180, 125.26438968275465000000000000000000000], [204.89609063898290000000000000000000000, 108.96906371359275000000000000000000000], [200.50128981570253000000000000000000000, 85.002363559114030000000000000000000000]]
function vertex(_v, half=false) {
p = coords[_v]
v = map_3D(p,sc)
s = sphere({radius: 0.5, center: v})
if (half) {
la1 = degToRad(p[0])
ph1 = degToRad(90 - p[1])
return colorize([0, 0.7, 0],
subtract(s,
translate([0, 0, 0],
rotate([0, 0, la1],
rotate([0, -ph1, 0],
translate([sc+0.5, 0],
rotate([degToRad(90), 0, degToRad(90)],
translate([-0, -0, -1],
cuboid({size: [1, 1, 0.8]})
)
)
)
)
)
)
)
)
} else {
return colorize([0, 0.7, 0], s)
}
}
function txt(mesg, w) {
const lineRadius = w / 2
const lineCorner = circle({ radius: lineRadius })
const lineSegmentPointArrays = vectorText({ x: 0, y: 0, height: 0.25, input: mesg })
const lineSegments = []
lineSegmentPointArrays.forEach(function(segmentPoints) {
const corners = segmentPoints.map((point) => translate(point, lineCorner))
lineSegments.push(hullChain(corners))
})
const message2D = union(lineSegments)
return extrudeLinear({ height: w }, message2D)
}
function vtxt(_p1, num) {
str = num.toString()
p1 = coords[_p1]
la1 = degToRad(p1[0])
ph1 = degToRad(90 - p1[1])
return translate([0, 0, 0],
rotate([0, 0, la1],
rotate([0, -ph1, 0],
translate([sc+0.5, 0.15-0.25*str.length],
rotate([degToRad(90), 0, degToRad(90)],
colorize([0, 0, 0],
txt(str, 0.05)
)
)
)
)
)
)
}
function edge(_v, _w, _e) {
v = map_3D(coords[_v], sc)
w = map_3D(coords[_w], sc)
d = [0, 0, 0]
x = [0, 0, 0]
jscad.maths.vec3.subtract(d, w, v)
add(x, v, w)
scale(w, x, 0.5)
if (length(d) >= eps) {
return colorize([0, 0, 1, 1],
translate(w,
rotate([0, Math.acos(d[2]/length(d)), Math.atan2(d[1], d[0])],
cylinder({radius: 0.1, height: length(d)})
)
)
)
} else {
return cube({size: 0.01})
}
}
function edge2(_p1, _p2, _e) {
p1 = coords[_p1]
p2 = coords[_p2]
// al/la/ph: alpha/lambda/phi | lxy/sxy: delta lambda_xy/sigma_xy
// https://en.wikipedia.org/wiki/Great-circle_navigation#Course
la1 = degToRad(p1[0])
la2 = degToRad(p2[0])
l12 = la2 - la1
ph1 = degToRad(90 - p1[1])
ph2 = degToRad(90 - p2[1])
al1 = Math.atan2(Math.cos(ph2)*Math.sin(l12), Math.cos(ph1)*Math.sin(ph2)-Math.sin(ph1)*Math.cos(ph2)*Math.cos(l12))
// delta sigma_12
// https://en.wikipedia.org/wiki/Great-circle_distance#Formulae
s12 = Math.acos(Math.sin(ph1)*Math.sin(ph2)+Math.cos(ph1)*Math.cos(ph2)*Math.cos(l12))
return rotate([0, 0, la1],
rotate([0, -ph1, 0],
rotate([degToRad(90)-al1, 0, 0],
colorize([0, 0, 0.7],
extrudeRotate({segments: 32, angle: s12},
circle({radius: 0.1, center: [sc,0]})
)
)
)
)
)
}
function sp_tria2(r, tang, pang, thi, points, segments) {
const coords = []
pts2 = Math.trunc(points / 2)
for(i = 0; i<pts2; i=i+1) {
th = i*(tang/(pts2-1))
coords.push([(r-thi/2)*Math.sin(th), (r-thi/2)*Math.cos(th)])
}
for(i = pts2-1; i>=0; i=i-1) {
th = i*(tang/(pts2-1))
coords.push([(r+thi/2)*Math.sin(th), (r+thi/2)*Math.cos(th)])
}
return extrudeRotate({segments: segments, angle: pang},
polygon({points: coords})
)
}
function sp_tria(_p1, _p2, _p3, sub) {
p1 = coords[_p1]
p2 = coords[_p2]
p3 = coords[_p3]
// al/la/ph: alpha/lambda/phi | lxy/sxy: delta lambda_xy/sigma_xy
// https://en.wikipedia.org/wiki/Great-circle_navigation#Course
la1 = degToRad(p1[0])
la2 = degToRad(p2[0])
la3 = degToRad(p3[0])
l12 = la2 - la1
l13 = la3 - la1
l32 = la2 - la3
l23 = la3 - la2
l31 = la1 - la3
ph1 = degToRad(90 - p1[1])
ph2 = degToRad(90 - p2[1])
ph3 = degToRad(90 - p3[1])
al12 = Math.atan2(Math.cos(ph2)*Math.sin(l12), Math.cos(ph1)*Math.sin(ph2)-Math.sin(ph1)*Math.cos(ph2)*Math.cos(l12))
al13 = Math.atan2(Math.cos(ph3)*Math.sin(l13), Math.cos(ph1)*Math.sin(ph3)-Math.sin(ph1)*Math.cos(ph3)*Math.cos(l13))
al31 = Math.atan2(Math.cos(ph1)*Math.sin(l31), Math.cos(ph3)*Math.sin(ph1)-Math.sin(ph3)*Math.cos(ph1)*Math.cos(l31))
al32 = Math.atan2(Math.cos(ph2)*Math.sin(l32), Math.cos(ph3)*Math.sin(ph2)-Math.sin(ph3)*Math.cos(ph2)*Math.cos(l32))
// delta sigma_xy
// https://en.wikipedia.org/wiki/Great-circle_distance#Formulae
s12 = Math.acos(Math.sin(ph1)*Math.sin(ph2)+Math.cos(ph1)*Math.cos(ph2)*Math.cos(l12))
s23 = Math.acos(Math.sin(ph2)*Math.sin(ph3)+Math.cos(ph2)*Math.cos(ph3)*Math.cos(l23))
s13 = Math.acos(Math.sin(ph1)*Math.sin(ph3)+Math.cos(ph1)*Math.cos(ph3)*Math.cos(l13))
if (s13 < s12) {
if (s12 >= s23) {
return sp_tria(_p1, _p3, _p2, sub)
} else {
return sp_tria(_p2, _p1, _p3, sub)
}
} else {
if (s13 < s23) {
return sp_tria(_p2, _p1, _p3, sub)
} else if (Math.abs(s13-s12-s23) >= eps) {
function mpi(ang) { return (ang < -Math.PI) ? 2*Math.PI + ang : ((ang > Math.PI) ? ang - 2*Math.PI : ang) }
v1 = map_3D(p1, 1)
v2 = map_3D(p2, 1)
v3 = map_3D(p3, 1)
ms = [0, 0, 0]
ms2 = [0, 0, 0]
sv1=[0, 0, 0]
sv2=[0, 0, 0]
sv3=[0, 0, 0]
s1=[0, 0, 0]
s2=[0, 0, 0]
s3=[0, 0, 0]
add(ms, v1, v2)
add(ms, ms, v3)
normalize(ms2, ms)
mi = Math.min(dot(v1, ms2), dot(v2, ms2), dot(v3, ms2))
scale(sv1, v1, sc)
scale(sv2, v2, sc)
scale(sv3, v3, sc)
scale(s1, sv1, 1/mi)
scale(s2, sv2, 1/mi)
scale(s3, sv3, 1/mi)
return colorize([0.5, 0.5, 0.5],
subtract(
intersect(
union(
translate([0, 0, 0],
rotate([0, 0, la1-degToRad(180)],
rotate([0, ph1-degToRad(90), 0],
rotate([0,0,-al13],
sp_tria2(sc, s12, mpi(al13-al12), 0.1, 24, 30)
)
)
)
),
translate([0, 0, 0],
rotate([0, 0, la3-degToRad(180)],
rotate([0, ph3-degToRad(90), 0],
rotate([0, 0, -al31],
sp_tria2(sc, s23, mpi(al31-al32), 0.1, 24, 30)
)
)
)
)
),
hull(
cube({center: sv1, size: 0.01})
,cube({center: sv2, size: 0.01})
,cube({center: sv3, size: 0.01})
,cube({center: s1, size: 0.01})
,cube({center: s2, size: 0.01})
,cube({center: s3, size: 0.01})
)
)
,sub)
)
} else {
return cube({size: 0.01})
}
}
}
function main(params) {
t0=new Date().getTime()
sub = [cube({size: (params.look_inside === 'yes')?sc+0.1:0.01, center: [sc/2,-sc/2,sc/2]})]
pentagons = (params.faces !== 'Pentagons') ? [] : [[]
,sp_tria( 13 , 0 , 14 , sub)
,sp_tria( 13 , 14 , 15 , sub)
,sp_tria( 13 , 15 , 12 , sub)
,sp_tria( 2 , 1 , 32 , sub)
,sp_tria( 2 , 32 , 33 , sub)
,sp_tria( 2 , 33 , 3 , sub)
,sp_tria( 4 , 3 , 33 , sub)
,sp_tria( 4 , 33 , 34 , sub)
,sp_tria( 4 , 34 , 5 , sub)
,sp_tria( 21 , 4 , 5 , sub)
,sp_tria( 21 , 5 , 6 , sub)
,sp_tria( 21 , 6 , 20 , sub)
,sp_tria( 8 , 7 , 27 , sub)
,sp_tria( 8 , 27 , 28 , sub)
,sp_tria( 8 , 28 , 9 , sub)
,sp_tria( 10 , 9 , 28 , sub)
,sp_tria( 10 , 28 , 29 , sub)
,sp_tria( 10 , 29 , 11 , sub)
,sp_tria( 16 , 10 , 11 , sub)
,sp_tria( 16 , 11 , 12 , sub)
,sp_tria( 16 , 12 , 15 , sub)
,sp_tria( 12 , 11 , 29 , sub)
,sp_tria( 12 , 29 , 30 , sub)
,sp_tria( 12 , 30 , 13 , sub)
,sp_tria( 18 , 17 , 25 , sub)
,sp_tria( 18 , 25 , 26 , sub)
,sp_tria( 18 , 26 , 19 , sub)
,sp_tria( 20 , 19 , 26 , sub)
,sp_tria( 20 , 26 , 22 , sub)
,sp_tria( 20 , 22 , 21 , sub)
,sp_tria( 23 , 22 , 26 , sub)
,sp_tria( 23 , 26 , 25 , sub)
,sp_tria( 23 , 25 , 24 , sub)
,sp_tria( 32 , 31 , 35 , sub)
,sp_tria( 32 , 35 , 34 , sub)
,sp_tria( 32 , 34 , 33 , sub)
]
sixcol = (params.faces !== '6coloring') ? [] : [[]
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 0 , 32 , 1 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 0 , 31 , 32 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 0 , 30 , 31 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 0 , 13 , 30 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 13 , 15 , 12 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 13 , 14 , 15 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 13 , 0 , 14 , sub))
, colorize( [0, 0, 0.90000000000000000000000000000000000000] , sp_tria( 14 , 23 , 24 , sub))
, colorize( [0, 0, 0.90000000000000000000000000000000000000] , sp_tria( 14 , 2 , 23 , sub))
, colorize( [0, 0, 0.90000000000000000000000000000000000000] , sp_tria( 14 , 1 , 2 , sub))
, colorize( [0, 0, 0.90000000000000000000000000000000000000] , sp_tria( 14 , 0 , 1 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 2 , 33 , 3 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 2 , 32 , 33 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 2 , 1 , 32 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 23 , 21 , 22 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 23 , 4 , 21 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 23 , 3 , 4 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 23 , 2 , 3 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 4 , 34 , 5 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 4 , 33 , 34 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 4 , 3 , 33 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 21 , 6 , 20 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 21 , 5 , 6 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 21 , 4 , 5 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 6 , 27 , 7 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 6 , 35 , 27 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 6 , 34 , 35 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 6 , 5 , 34 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 20 , 18 , 19 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 20 , 8 , 18 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 20 , 7 , 8 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 20 , 6 , 7 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 8 , 28 , 9 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 8 , 27 , 28 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 8 , 7 , 27 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 18 , 16 , 17 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 18 , 10 , 16 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 18 , 9 , 10 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 18 , 8 , 9 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 10 , 29 , 11 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 10 , 28 , 29 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 10 , 9 , 28 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 16 , 12 , 15 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 16 , 11 , 12 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 16 , 10 , 11 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 12 , 30 , 13 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 12 , 29 , 30 , sub))
, colorize( [0.70000000000000000000000000000000000000, 0, 0.70000000000000000000000000000000000000] , sp_tria( 12 , 11 , 29 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 15 , 17 , 16 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 15 , 25 , 17 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 15 , 24 , 25 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 15 , 14 , 24 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 18 , 26 , 19 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 18 , 25 , 26 , sub))
, colorize( [0.90000000000000000000000000000000000000, 0.E-38, 0] , sp_tria( 18 , 17 , 25 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 20 , 22 , 21 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 20 , 26 , 22 , sub))
, colorize( [0, 0.70000000000000000000000000000000000000, 0.70000000000000000000000000000000000000] , sp_tria( 20 , 19 , 26 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 23 , 25 , 24 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 23 , 26 , 25 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 23 , 22 , 26 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 28 , 30 , 29 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 28 , 31 , 30 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 28 , 35 , 31 , sub))
, colorize( [0, 0.90000000000000000000000000000000000000, 0] , sp_tria( 28 , 27 , 35 , sub))
, colorize( [0, 0, 0.90000000000000000000000000000000000000] , sp_tria( 32 , 34 , 33 , sub))
, colorize( [0, 0, 0.90000000000000000000000000000000000000] , sp_tria( 32 , 35 , 34 , sub))
, colorize( [0, 0, 0.90000000000000000000000000000000000000] , sp_tria( 32 , 31 , 35 , sub))
]
white = (!params.white) ? [] : [[]
, colorize([1,1,1],
subtract(
sphere({radius: sc, segments: 30})
,sphere({radius: sc-0.1, segments: 30})
,sub
)
)
]
vtype = [ [ 0 , coords[ 0 ][1].toFixed(1), coords[ 0 ][0].toFixed(1)]
,[ 1 , coords[ 1 ][1].toFixed(1), coords[ 1 ][0].toFixed(1)]
,[ 2 , coords[ 2 ][1].toFixed(1), coords[ 2 ][0].toFixed(1)]
,[ 3 , coords[ 3 ][1].toFixed(1), coords[ 3 ][0].toFixed(1)]
,[ 4 , coords[ 4 ][1].toFixed(1), coords[ 4 ][0].toFixed(1)]
,[ 5 , coords[ 5 ][1].toFixed(1), coords[ 5 ][0].toFixed(1)]
,[ 6 , coords[ 6 ][1].toFixed(1), coords[ 6 ][0].toFixed(1)]
,[ 7 , coords[ 7 ][1].toFixed(1), coords[ 7 ][0].toFixed(1)]
,[ 8 , coords[ 8 ][1].toFixed(1), coords[ 8 ][0].toFixed(1)]
,[ 9 , coords[ 9 ][1].toFixed(1), coords[ 9 ][0].toFixed(1)]
,[ 10 , coords[ 10 ][1].toFixed(1), coords[ 10 ][0].toFixed(1)]
,[ 11 , coords[ 11 ][1].toFixed(1), coords[ 11 ][0].toFixed(1)]
,[ 12 , coords[ 12 ][1].toFixed(1), coords[ 12 ][0].toFixed(1)]
,[ 13 , coords[ 13 ][1].toFixed(1), coords[ 13 ][0].toFixed(1)]
,[ 14 , coords[ 14 ][1].toFixed(1), coords[ 14 ][0].toFixed(1)]
,[ 15 , coords[ 15 ][1].toFixed(1), coords[ 15 ][0].toFixed(1)]
,[ 16 , coords[ 16 ][1].toFixed(1), coords[ 16 ][0].toFixed(1)]
,[ 17 , coords[ 17 ][1].toFixed(1), coords[ 17 ][0].toFixed(1)]
,[ 18 , coords[ 18 ][1].toFixed(1), coords[ 18 ][0].toFixed(1)]
,[ 19 , coords[ 19 ][1].toFixed(1), coords[ 19 ][0].toFixed(1)]
,[ 20 , coords[ 20 ][1].toFixed(1), coords[ 20 ][0].toFixed(1)]
,[ 21 , coords[ 21 ][1].toFixed(1), coords[ 21 ][0].toFixed(1)]
,[ 22 , coords[ 22 ][1].toFixed(1), coords[ 22 ][0].toFixed(1)]
,[ 23 , coords[ 23 ][1].toFixed(1), coords[ 23 ][0].toFixed(1)]
,[ 24 , coords[ 24 ][1].toFixed(1), coords[ 24 ][0].toFixed(1)]
,[ 25 , coords[ 25 ][1].toFixed(1), coords[ 25 ][0].toFixed(1)]
,[ 26 , coords[ 26 ][1].toFixed(1), coords[ 26 ][0].toFixed(1)]
,[ 27 , coords[ 27 ][1].toFixed(1), coords[ 27 ][0].toFixed(1)]
,[ 28 , coords[ 28 ][1].toFixed(1), coords[ 28 ][0].toFixed(1)]
,[ 29 , coords[ 29 ][1].toFixed(1), coords[ 29 ][0].toFixed(1)]
,[ 30 , coords[ 30 ][1].toFixed(1), coords[ 30 ][0].toFixed(1)]
,[ 31 , coords[ 31 ][1].toFixed(1), coords[ 31 ][0].toFixed(1)]
,[ 32 , coords[ 32 ][1].toFixed(1), coords[ 32 ][0].toFixed(1)]
,[ 33 , coords[ 33 ][1].toFixed(1), coords[ 33 ][0].toFixed(1)]
,[ 34 , coords[ 34 ][1].toFixed(1), coords[ 34 ][0].toFixed(1)]
,[ 35 , coords[ 35 ][1].toFixed(1), coords[ 35 ][0].toFixed(1)]
]
tvtxt = (params.vtxt === 'theta') ? 1 : (params.vtxt === 'phi') ? 2 : 0
vtxts = (params.vtxt === 'None') ? [] : [
vtxt( 0 , vtype[ 0 ][tvtxt])
,vtxt( 1 , vtype[ 1 ][tvtxt])
,vtxt( 2 , vtype[ 2 ][tvtxt])
,vtxt( 3 , vtype[ 3 ][tvtxt])
,vtxt( 4 , vtype[ 4 ][tvtxt])
,vtxt( 5 , vtype[ 5 ][tvtxt])
,vtxt( 6 , vtype[ 6 ][tvtxt])
,vtxt( 7 , vtype[ 7 ][tvtxt])
,vtxt( 8 , vtype[ 8 ][tvtxt])
,vtxt( 9 , vtype[ 9 ][tvtxt])
,vtxt( 10 , vtype[ 10 ][tvtxt])
,vtxt( 11 , vtype[ 11 ][tvtxt])
,vtxt( 12 , vtype[ 12 ][tvtxt])
,vtxt( 13 , vtype[ 13 ][tvtxt])
,vtxt( 14 , vtype[ 14 ][tvtxt])
,vtxt( 15 , vtype[ 15 ][tvtxt])
,vtxt( 16 , vtype[ 16 ][tvtxt])
,vtxt( 17 , vtype[ 17 ][tvtxt])
,vtxt( 18 , vtype[ 18 ][tvtxt])
,vtxt( 19 , vtype[ 19 ][tvtxt])
,vtxt( 20 , vtype[ 20 ][tvtxt])
,vtxt( 21 , vtype[ 21 ][tvtxt])
,vtxt( 22 , vtype[ 22 ][tvtxt])
,vtxt( 23 , vtype[ 23 ][tvtxt])
,vtxt( 24 , vtype[ 24 ][tvtxt])
,vtxt( 25 , vtype[ 25 ][tvtxt])
,vtxt( 26 , vtype[ 26 ][tvtxt])
,vtxt( 27 , vtype[ 27 ][tvtxt])
,vtxt( 28 , vtype[ 28 ][tvtxt])
,vtxt( 29 , vtype[ 29 ][tvtxt])
,vtxt( 30 , vtype[ 30 ][tvtxt])
,vtxt( 31 , vtype[ 31 ][tvtxt])
,vtxt( 32 , vtype[ 32 ][tvtxt])
,vtxt( 33 , vtype[ 33 ][tvtxt])
,vtxt( 34 , vtype[ 34 ][tvtxt])
,vtxt( 35 , vtype[ 35 ][tvtxt])
]
ret = [
,vertex( 0 , params.half !== 'none')
,vertex( 1 , params.half !== 'none')
,vertex( 2 , params.half !== 'none')
,vertex( 3 , params.half === 'all')
,vertex( 4 , params.half === 'all')
,vertex( 5 , params.half === 'all')
,vertex( 6 , params.half === 'all')
,colorize([0.7, 0, 0], vertex( 7 , params.half === 'all'))
,vertex( 8 , params.half === 'all')
,vertex( 9 , params.half === 'all')
,vertex( 10 , params.half === 'all')
,vertex( 11 , params.half === 'all')
,colorize([0.7, 0, 0], vertex( 12 , params.half === 'all'))
,vertex( 13 , params.half !== 'none')
,vertex( 14 , params.half !== 'none')
,vertex( 15 , params.half === 'all')
,vertex( 16 , params.half === 'all')
,vertex( 17 , params.half === 'all')
,vertex( 18 , params.half !== 'none')
,vertex( 19 , params.half !== 'none')
,vertex( 20 , params.half !== 'none')
,vertex( 21 , params.half === 'all')
,vertex( 22 , params.half === 'all')
,vertex( 23 , params.half !== 'none')
,vertex( 24 , params.half !== 'none')
,vertex( 25 , params.half === 'all')
,colorize([0.7, 0, 0], vertex( 26 , params.half === 'all'))
,vertex( 27 , params.half !== 'none')
,vertex( 28 , params.half !== 'none')
,vertex( 29 , params.half !== 'none')
,vertex( 30 , params.half !== 'none')
,vertex( 31 , params.half !== 'none')
,vertex( 32 , params.half !== 'none')
,colorize([0.7, 0, 0], vertex( 33 , params.half === 'all'))
,vertex( 34 , params.half === 'all')
,vertex( 35 , params.half !== 'none')
,edge2( 0 , 13 , 0 )
,edge2( 0 , 14 , 0 )
,edge2( 0 , 1 , 0 )
,edge2( 1 , 2 , 0 )
,edge2( 1 , 32 , 0 )
,edge2( 2 , 23 , 0 )
,edge2( 2 , 3 , 0 )
,colorize([1,0.66666,0],edge2( 3 , 4 , 0 ))
,colorize([1,0.66666,0],edge2( 3 , 33 , 0 ))
,colorize([1,0.66666,0],edge2( 4 , 21 , 0 ))
,colorize([1,0.66666,0],edge2( 4 , 5 , 0 ))
,colorize([1,0.66666,0],edge2( 5 , 6 , 0 ))
,colorize([1,0.66666,0],edge2( 5 , 34 , 0 ))
,edge2( 6 , 20 , 0 )
,colorize([1,0.66666,0],edge2( 6 , 7 , 0 ))
,colorize([1,0.66666,0],edge2( 7 , 8 , 0 ))
,edge2( 7 , 27 , 0 )
,edge2( 8 , 18 , 0 )
,colorize([1,0.66666,0],edge2( 8 , 9 , 0 ))
,colorize([1,0.66666,0],edge2( 9 , 10 , 0 ))
,edge2( 9 , 28 , 0 )
,colorize([1,0.66666,0],edge2( 10 , 16 , 0 ))
,colorize([1,0.66666,0],edge2( 10 , 11 , 0 ))
,colorize([1,0.66666,0],edge2( 11 , 12 , 0 ))
,edge2( 11 , 29 , 0 )
,colorize([1,0.66666,0],edge2( 12 , 15 , 0 ))
,edge2( 12 , 13 , 0 )
,edge2( 13 , 30 , 0 )
,edge2( 14 , 15 , 0 )
,edge2( 14 , 24 , 0 )
,colorize([1,0.66666,0],edge2( 15 , 16 , 0 ))
,colorize([1,0.66666,0],edge2( 16 , 17 , 0 ))
,edge2( 17 , 18 , 0 )
,colorize([1,0.66666,0],edge2( 17 , 25 , 0 ))
,edge2( 18 , 19 , 0 )
,edge2( 19 , 20 , 0 )
,edge2( 19 , 26 , 0 )
,edge2( 20 , 21 , 0 )
,colorize([1,0.66666,0],edge2( 21 , 22 , 0 ))
,edge2( 22 , 23 , 0 )
,colorize([1,0.66666,0],edge2( 22 , 26 , 0 ))
,edge2( 23 , 24 , 0 )
,edge2( 24 , 25 , 0 )
,colorize([1,0.66666,0],edge2( 25 , 26 , 0 ))
,edge2( 27 , 28 , 0 )
,edge2( 27 , 35 , 0 )
,edge2( 28 , 29 , 0 )
,edge2( 29 , 30 , 0 )
,edge2( 30 , 31 , 0 )
,edge2( 31 , 32 , 0 )
,edge2( 31 , 35 , 0 )
,edge2( 32 , 33 , 0 )
,colorize([1,0.66666,0],edge2( 33 , 34 , 0 ))
,edge2( 34 , 35 , 0 )
,pentagons
,sixcol
,white
,vtxts
]
console.log("dt="+(new Date().getTime()-t0)+"ms")
return ret }
function getParameterDefinitions() {
return [
{ name: 'faces', type: 'choice', values: ['Pentagons', '6coloring', 'None'], initial: 'Pentagons', caption: 'face coloring:' },
,{ name: 'white', type: 'checkbox', checked: true, initial: '20', caption: 'surface of sphere:' },
,{ name: 'half', type: 'choice', values: ['none', 'some', 'all'], initial: 'some', caption: 'half vertex:' },
,{ name: 'vtxt', type: 'choice', values: ['Id', 'theta', 'phi', 'None'], initial: 'Id', caption: 'vtxt:' },
,{ name: 'look_inside', type: 'choice', values: ['no', 'yes'], initial: 'no', caption: 'look_inside:' }
];
}
module.exports = { main, getParameterDefinitions }
@Hermann-SW
Copy link
Author

Generated as "gp.jscad" with:

pi@raspberrypi5:~/GP3D $ name=graphs/C36.10.a gp -q < sphere_embedding.gp
pi@raspberrypi5:~/GP3D $ 

@Hermann-SW
Copy link
Author

With "surface of sphere" turned off, effect of "half vertex" for those vertices not on separating circle can be seen best:

@Hermann-SW
Copy link
Author

Hermann-SW commented Jan 24, 2024

With commit
Hermann-SW/GP3D@203b37b
render time [ms] gets logged to browser console. Updated this gist to new output created with command from two comments above.

@Hermann-SW
Copy link
Author

One hopefully last commit to sphere_embedding.gp:
Hermann-SW/GP3D@967dccb
Does change "half vertex" from checkbox to choice.
Just updated this gist with new slightly changed output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment