-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparabola2.js
86 lines (80 loc) · 2.01 KB
/
parabola2.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(function () {
let w = 350,
h = 450;
let sim = new Sim("#beaming_parabola", h, w);
let x1 = 100,
y1 = -25,
x2 = -70,
y2 = -25;
let para1 = new Parabola(w/2, 50, 0.01, 100);
let para1_id = sim.add_thin(
para1.shape(), {
reflective: true,
style: "thick hollow mirror",
reflectance: 1.0
});
let slider1 = new Slider({
x: w/2 - 65,
y: 15,
length: 130,
angle: 0,
style: "slider",
handle_style: "slider-handle handle",
value: 0.005,
num_decimals: 4,
min: 0.002,
max: 0.01,
text_dx: 0,
text_dy: 25,
callback: function(value){
para1.a = value;
para1.recalc();
sim.update_shape_geometry(para1_id, para1.shape())
return `Focal Length: ${(1/(4*value)).toFixed(0)} px`
}
})
sim.add_ui(slider1);
let para2 = new Parabola(w/2, 450 - 50, -0.01, 100);
let para2_id = sim.add_thin(
para2.shape(),
{
reflective: true,
style: "thick hollow mirror",
reflectance: 1.0
}
)
let slider2 = new Slider({
x: w / 2 + 65,
y: h - 30,
length: 130,
angle: Math.PI,
style: "slider",
handle_style: "slider-handle handle",
value: -0.005,
num_decimals: 4,
min: -0.01,
max: -0.002,
text_dx: -130,
text_dy: 25,
callback: function (value) {
para2.a = value;
para2.recalc();
sim.update_shape_geometry(para2_id, para2.shape())
return `Focal Length: ${(-1/(4*value)).toFixed(0)} px`
}
})
sim.add_ui(slider2);
let cone = new ConeLamp({
x: 175.66,
y: 99.5,
angle: -Math.PI/2,
width: 2 * Math.PI / 3,
handle_gap: 30,
max_bounce: 3,
ui: {
max_x: w,
max_y: h
}
})
sim.add_light(cone);
})();