-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbounce.html
More file actions
130 lines (123 loc) · 5.42 KB
/
Copy pathbounce.html
File metadata and controls
130 lines (123 loc) · 5.42 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<div id="glowscript" class="glowscript">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type="text/css" href="https://www.glowscript.org/css/redmond/2.1/jquery-ui.custom.css" rel="stylesheet" />
<link type="text/css" href="https://www.glowscript.org/css/ide.css" rel="stylesheet" />
<script type="text/javascript" src="https://www.glowscript.org/lib/jquery/2.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.glowscript.org/lib/jquery/2.1/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="https://www.glowscript.org/package/glow.3.2.min.js"></script>
<script type="text/javascript" src="https://www.glowscript.org/package/RSrun.3.2.min.js"></script>
<script type="text/javascript"><!--//--><![CDATA[//><!--
// START JAVASCRIPT
;(function() {;
var ρσ_modules = {};
ρσ_modules.pythonize = {};
(function(){
function strings() {
var string_funcs, exclude, name;
string_funcs = set("capitalize strip lstrip rstrip islower isupper isspace lower upper swapcase center count endswith startswith find rfind index rindex format join ljust rjust partition rpartition replace split rsplit splitlines zfill".split(" "));
if (!arguments.length) {
exclude = (function(){
var s = ρσ_set();
s.jsset.add("split");
s.jsset.add("replace");
return s;
})();
} else if (arguments[0]) {
exclude = Array.prototype.slice.call(arguments);
} else {
exclude = null;
}
if (exclude) {
string_funcs = string_funcs.difference(set(exclude));
}
var ρσ_Iter0 = string_funcs;
ρσ_Iter0 = ((typeof ρσ_Iter0[Symbol.iterator] === "function") ? (ρσ_Iter0 instanceof Map ? ρσ_Iter0.keys() : ρσ_Iter0) : Object.keys(ρσ_Iter0));
for (var ρσ_Index0 of ρσ_Iter0) {
name = ρσ_Index0;
(ρσ_expr_temp = String.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name] = (ρσ_expr_temp = ρσ_str.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name];
}
};
if (!strings.__module__) Object.defineProperties(strings, {
__module__ : {value: "pythonize"}
});
ρσ_modules.pythonize.strings = strings;
})();
async function __main__() {
"use strict";
var display = canvas;
var scene = canvas();
var version, print, arange, __name__, type, ρσ_ls, side, thk, s2, s3, wallR, wallL, wallB, wallT, wallBK, ball, dt;
version = ρσ_list_decorate([ "3.2", "glowscript" ]);
Array.prototype['+'] = function(r) {return this.concat(r)}
Array.prototype['*'] = function(r) {return __array_times_number(this, r)}
window.__GSlang = "vpython";
print = GSprint;
arange = range;
__name__ = "__main__";
type = pytype;
var strings = ρσ_modules.pythonize.strings;
strings();
"2";
scene.height = 250;
"3";
scene.width = 250;
"7";
scene.caption = "Rotate camera: right drag or Ctrl-drag.\nZoom: middle or Alt/Option drag, or scroll wheel.\n";
"9";
side = 4;
"10";
thk = .3;
"11";
s2 = 2["*"](side)["-"](1["*"](thk));
"12";
s3 = 2["*"](side)["+"](thk);
"14";
wallR = ρσ_interpolate_kwargs.call(this, box, [ρσ_desugar_kwargs({pos: vector(side, 0, 0), size: vector(thk, s2, s3), color: color.red})]);
"15";
wallL = ρσ_interpolate_kwargs.call(this, box, [ρσ_desugar_kwargs({pos: vector(1["-u"]()["*"](side), 0, 0), size: vector(thk, s2, s3), color: color.red})]);
"16";
wallB = ρσ_interpolate_kwargs.call(this, box, [ρσ_desugar_kwargs({pos: vector(0, 1["-u"]()["*"](side), 0), size: vector(s3, thk, s3), color: color.blue})]);
"17";
wallT = ρσ_interpolate_kwargs.call(this, box, [ρσ_desugar_kwargs({pos: vector(0, side, 0), size: vector(s3, thk, s3), color: color.blue})]);
"18";
wallBK = ρσ_interpolate_kwargs.call(this, box, [ρσ_desugar_kwargs({pos: vector(0, 0, 1["-u"]()["*"](side)), size: vector(s2, s2, thk), color: color.gray(.7)})]);
"20";
ball = ρσ_interpolate_kwargs.call(this, sphere, [ρσ_desugar_kwargs({color: color.green, radius: .4, make_trail: true, retain: 200})]);
"21";
ball.mass = 1;
"22";
ball.p = vector(1["-u"]()["*"](.15), 1["-u"]()["*"](.23), .27);
"24";
side = side["-"](1["*"](thk)["*"](.5))["-"](1["*"](ball.radius));
"26";
dt = .3;
"27";
while (true) {
"28";
(await rate(200));
"29";
ball.pos = ball.pos["+"](ball.p["/"](ball.mass)["*"](dt));
"30";
if (!((side[">"](ρσ_cond_temp = ball.pos.x) && ρσ_cond_temp[">"](1["-u"]()["*"](side))))) {
"31";
ball.p.x = 1["-u"]()["*"](ball.p.x);
"32";
}
if (!((side[">"](ρσ_cond_temp = ball.pos.y) && ρσ_cond_temp[">"](1["-u"]()["*"](side))))) {
"33";
ball.p.y = 1["-u"]()["*"](ball.p.y);
"34";
}
if (!((side[">"](ρσ_cond_temp = ball.pos.z) && ρσ_cond_temp[">"](1["-u"]()["*"](side))))) {
"35";
ball.p.z = 1["-u"]()["*"](ball.p.z);
}
}
};
if (!__main__.__module__) Object.defineProperties(__main__, {
__module__ : {value: null}
});
;$(function(){ window.__context = { glowscript_container: $("#glowscript").removeAttr("id") }; __main__() })})()
// END JAVASCRIPT
//--><!]]></script>
</div>