-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdm-logo2.html
More file actions
56 lines (52 loc) · 2.36 KB
/
dm-logo2.html
File metadata and controls
56 lines (52 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%%javascript
function reuleaux(i, j, k) {
//if(j==0) return reuleaux(i, 20, k-1) //flatten off edge
var rad = (j / 10.0 - 1) * Math.PI / 3.0
//using Polar equation of a curve from https://en.wikipedia.org/wiki/Polar_coordinate_system
//R=1, r0=1/sqrt(3) (2/3 height of unit sided equilateral triangle, offset of centre of reuleaux arc)
var cosr = Math.cos(rad)
var r = (Math.sqrt(4.0/3.0*cosr*cosr + 8.0/3.0) - 2.0/Math.sqrt(3.0)*cosr)/2.0
var az = i / 50.0 * Math.PI * 2.0
var rot = az*2/3
if(0<=rot && rot<Math.PI/6){
var r0 = 1-Math.cos(rot)/Math.sqrt(3.0)
}else if(1*Math.PI/6<=rot && rot<3*Math.PI/6){
var r0 = Math.cos(rot-2*Math.PI/6)/Math.sqrt(3.0)
}else if(3*Math.PI/6<=rot && rot<5*Math.PI/6){
var r0 = 1-Math.cos(rot-4*Math.PI/6)/Math.sqrt(3.0)
}else if(5*Math.PI/6<=rot && rot<7*Math.PI/6){
var r0 = Math.cos(rot-6*Math.PI/6)/Math.sqrt(3.0)
}else if(7*Math.PI/6<=rot && rot<9*Math.PI/6){
var r0 = 1-Math.cos(rot-8*Math.PI/6)/Math.sqrt(3.0)
}else if(9*Math.PI/6<=rot && rot<11*Math.PI/6){
var r0 = Math.cos(rot-10*Math.PI/6)/Math.sqrt(3.0)
}else if(11*Math.PI/6<=rot && rot<=12*Math.PI/6){
var r0 = 1-Math.cos(rot-12*Math.PI/6)/Math.sqrt(3.0)
}
var th = rad + k*Math.PI*2/3 + rot //twist it!
//based on parametric equation of a torus
var x = Math.sin(-az)* (r * Math.cos(th) - r0 - 0.5)
var y = Math.cos(-az)* (r * Math.cos(th) - r0 - 0.5)
var z = r*Math.sin(th)
return {x: x, y: z, z: y}
}
with_mathbox(element, function(mathbox) {
var view = mathbox.cartesian({scale: [0.5, 0.5, 0.5]})
.unit({scale:1000})
view.voxel({
width: 50, height: 20, depth: 3,
items: 4, channels: 3,
expr: function (emit, i, j, k, t) {
var p0 = reuleaux(i,j,k); emit(p0.x, p0.y, p0.z)
var p1 = reuleaux(i+1,j,k); emit(p1.x, p1.y, p1.z);
var p2 = reuleaux(i+1,j+1,k); emit(p2.x, p2.y, p2.z);
var p3 = reuleaux(i,j+1,k); emit(p3.x, p3.y, p3.z);
}
})
for(var i=0; i<=0; ++i)
for(var j=0; j<=0; ++j)
view.transform({position: [-j*3.5, 0, -i*3.5]})
.transform({rotation: [(0, 0, 0)]})
.face({color: (i==0 && j==0 )?0x60B0FF : 0xEEEEEE, shaded: false})
.face({color: (i==0 && j==0 )?0x60B0FF : 0xEEEEEE, shaded: true, opacity: 0.5})
})