less copy protection, more size visualization
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

630 lignes
18 KiB

  1. math.createUnit("dalton", {
  2. definition: "1.66e-27 kg",
  3. prefixes: "long"
  4. });
  5. math.createUnit("daltons", {
  6. definition: "1.66e-27 kg",
  7. prefixes: "long"
  8. });
  9. math.createUnit("solarradii", {
  10. definition: "695990 km",
  11. prefixes: "long"
  12. });
  13. math.createUnit("solarmasses", {
  14. definition: "2e30 kg",
  15. prefixes: "long"
  16. });
  17. math.createUnit("galaxy", {
  18. definition: "105700 lightyears",
  19. prefixes: "long"
  20. });
  21. math.createUnit("galaxies", {
  22. definition: "105700 lightyears",
  23. prefixes: "long"
  24. });
  25. math.createUnit("universe", {
  26. definition: "93.016e9 lightyears",
  27. prefixes: "long"
  28. });
  29. math.createUnit("universes", {
  30. definition: "93.016e9 lightyears",
  31. prefixes: "long"
  32. });
  33. function makeObject(name, viewInfo) {
  34. views = {};
  35. Object.entries(viewInfo).forEach(([key, value]) => {
  36. views[key] = {
  37. attributes: {
  38. height: {
  39. name: "Height",
  40. power: 1,
  41. type: "length",
  42. base: value.height
  43. }
  44. },
  45. image: value.image,
  46. name: value.name,
  47. rename: value.rename
  48. }
  49. if (value.mass) {
  50. views[key].attributes.mass = {
  51. name: "Mass",
  52. power: 3,
  53. type: "mass",
  54. base: value.mass
  55. };
  56. }
  57. });
  58. return makeEntity({ name: name }, views);
  59. }
  60. SHOE_REFERENCE = 60
  61. function addShoeView(object, name, points) {
  62. object[name] = {
  63. height: math.unit(points / SHOE_REFERENCE, "inches"),
  64. image: { source: "./media/objects/shoes/shoe_" + name + ".svg" },
  65. name: name.replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  66. rename: true
  67. }
  68. }
  69. function makeHeight(info, category, prefix="", type="objects") {
  70. const views = {};
  71. info.forEach(object => {
  72. let src;
  73. // this lets us provide our own source if needed
  74. // useful for reusing existing art
  75. if (object[3]) {
  76. src = object[3];
  77. } else {
  78. src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg";
  79. }
  80. views[object[0]] = {
  81. height: math.unit(object[1], object[2]),
  82. image: { source: src },
  83. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  84. rename: true
  85. }
  86. });
  87. return {
  88. name: category,
  89. constructor: () => makeObject(
  90. category,
  91. views
  92. )
  93. }
  94. }
  95. function makeHeightWeight(info, category, prefix="", type="objects") {
  96. const views = {};
  97. info.forEach(object => {
  98. let src;
  99. // this lets us provide our own source if needed
  100. // useful for reusing existing art
  101. if (object[5]) {
  102. src = object[5];
  103. } else {
  104. src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg";
  105. }
  106. views[object[0]] = {
  107. height: math.unit(object[1], object[2]),
  108. mass: math.unit(object[3], object[4]),
  109. image: { source: src },
  110. name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()),
  111. rename: true
  112. }
  113. });
  114. return {
  115. name: category,
  116. constructor: () => makeObject(
  117. category,
  118. views
  119. )
  120. }
  121. }
  122. function makeShoes() {
  123. const views = {};
  124. [
  125. ["flip-flops", 154.239],
  126. ["knee-boots", 841.827],
  127. ["trainers", 260.607],
  128. ["stilettos", 418.839]
  129. ].forEach(shoe => {
  130. addShoeView(views, shoe[0], shoe[1])
  131. });
  132. return {
  133. name: "Shoes",
  134. constructor: () => makeObject(
  135. "Shoes",
  136. views
  137. )
  138. }
  139. }
  140. function makeObjects() {
  141. const results = [];
  142. results.push({
  143. name: "Soda Can",
  144. constructor: () => makeObject(
  145. "Soda Can",
  146. {
  147. front: {
  148. height: math.unit(4.83, "inches"),
  149. mass: math.unit(15, "grams"),
  150. image: { source: "./media/objects/soda-can.svg" },
  151. name: "Side"
  152. }
  153. }
  154. )
  155. });
  156. results.push({
  157. name: "Sewing Pin",
  158. constructor: () => makeObject(
  159. "Sewing Pin",
  160. {
  161. side: {
  162. height: math.unit(1.5, "inches"),
  163. image: { source: "./media/objects/sewing-pin.svg" },
  164. name: "Side"
  165. },
  166. top: {
  167. height: math.unit(2, "millimeters"),
  168. image: { source: "./media/objects/pin-head.svg" },
  169. name: "Head"
  170. }
  171. }
  172. )
  173. });
  174. results.push({
  175. name: "Lamp",
  176. constructor: () => makeObject(
  177. "Lamp",
  178. {
  179. lamp: {
  180. height: math.unit(30, "inches"),
  181. mass: math.unit(10, "lbs"),
  182. image: { source: "./media/objects/lamp.svg" },
  183. name: "Lamp"
  184. }
  185. }
  186. )
  187. });
  188. results.push({
  189. name: "Nail Polish",
  190. constructor: () => makeObject(
  191. "Nail Polish",
  192. {
  193. bottle: {
  194. height: math.unit(3.25, "inches"),
  195. mass: math.unit(66, "g"),
  196. image: { source: "./media/objects/nail-polish.svg" },
  197. name: "Bottle"
  198. }
  199. }
  200. )
  201. });
  202. results.push({
  203. name: "Shot Glass",
  204. constructor: () => makeObject(
  205. "Shot Glass",
  206. {
  207. glass: {
  208. height: math.unit(2 + 3/8, "inches"),
  209. mass: math.unit(75, "g"),
  210. image: { source: "./media/objects/shot-glass.svg" },
  211. name: "Bottle"
  212. }
  213. }
  214. )
  215. });
  216. results.push({
  217. name: "Beer Bottle",
  218. constructor: () => makeObject(
  219. "Beer Bottle",
  220. {
  221. longneck: {
  222. height: math.unit(9, "inches"),
  223. mass: math.unit(200, "g"),
  224. image: { source: "./media/objects/beer-bottle.svg" },
  225. name: "Longneck Bottle"
  226. }
  227. }
  228. )
  229. });
  230. results.push({
  231. name: "Coin",
  232. constructor: () => makeObject(
  233. "Coin",
  234. {
  235. penny: {
  236. height: math.unit(0.75, "inches"),
  237. mass: math.unit(2.5, "g"),
  238. image: { source: "./media/objects/circle.svg" },
  239. name: "Penny",
  240. rename: true
  241. },
  242. nickel: {
  243. height: math.unit(0.835, "inches"),
  244. mass: math.unit(5, "g"),
  245. image: { source: "./media/objects/circle.svg" },
  246. name: "Nickel",
  247. rename: true
  248. },
  249. dime: {
  250. height: math.unit(0.705, "inches"),
  251. mass: math.unit(2.268, "g"),
  252. image: { source: "./media/objects/circle.svg" },
  253. name: "Dime",
  254. rename: true
  255. },
  256. quarter: {
  257. height: math.unit(0.955, "inches"),
  258. mass: math.unit(5.67, "g"),
  259. image: { source: "./media/objects/circle.svg" },
  260. name: "Quarter",
  261. rename: true
  262. },
  263. dollar: {
  264. height: math.unit(1.043, "inches"),
  265. mass: math.unit(8.1, "g"),
  266. image: { source: "./media/objects/circle.svg" },
  267. name: "Dollar Coin",
  268. rename: true
  269. },
  270. }
  271. )
  272. });
  273. results.push({
  274. name: "Pencil",
  275. constructor: () => makeObject(
  276. "Pencil",
  277. {
  278. pencil: {
  279. height: math.unit(7.5, "inches"),
  280. mass: math.unit(7, "g"),
  281. image: { source: "./media/objects/pencil.svg" },
  282. name: "Pencil"
  283. }
  284. }
  285. )
  286. });
  287. results.push({
  288. name: "Balls",
  289. constructor: () => makeObject(
  290. "Balls",
  291. {
  292. golf: {
  293. height: math.unit(1.62, "inches"),
  294. mass: math.unit(45, "g"),
  295. image: { source: "./media/objects/circle.svg" },
  296. name: "Golfball",
  297. rename: true
  298. },
  299. tennis: {
  300. height: math.unit(2.6, "inches"),
  301. mass: math.unit(57, "g"),
  302. image: { source: "./media/objects/circle.svg" },
  303. name: "Tennisball",
  304. rename: true
  305. },
  306. baseball: {
  307. height: math.unit(2.9, "inches"),
  308. mass: math.unit(145, "g"),
  309. image: { source: "./media/objects/circle.svg" },
  310. name: "Baseball",
  311. rename: true
  312. },
  313. volleyball: {
  314. height: math.unit(8, "inches"),
  315. mass: math.unit(270, "g"),
  316. image: { source: "./media/objects/circle.svg" },
  317. name: "Volleyball",
  318. rename: true
  319. }
  320. }
  321. )
  322. });
  323. results.push({
  324. name: "Paperclip",
  325. constructor: () => makeObject(
  326. "Paperclip",
  327. {
  328. paperclip: {
  329. height: math.unit(1.834, "inches"),
  330. mass: math.unit(1, "g"),
  331. image: { source: "./media/objects/paperclip.svg" },
  332. name: "Paperclip"
  333. }
  334. }
  335. )
  336. });
  337. results.push({
  338. name: "Pebbles",
  339. constructor: () => makeObject(
  340. "Pebbles",
  341. {
  342. gravelGrain: {
  343. height: math.unit(20, "mm"),
  344. image: { source: "./media/objects/pebble.svg" },
  345. name: "Grain of gravel",
  346. rename: true
  347. },
  348. sandGrain: {
  349. height: math.unit(0.5, "mm"),
  350. image: { source: "./media/objects/pebble.svg" },
  351. name: "Grain of sand",
  352. rename: true
  353. },
  354. siltGrain: {
  355. height: math.unit(0.03, "mm"),
  356. image: { source: "./media/objects/pebble.svg" },
  357. name: "Grain of silt",
  358. rename: true
  359. },
  360. }
  361. )
  362. });
  363. results.push({
  364. name: "Credit Card",
  365. constructor: () => makeObject(
  366. "Credit Card",
  367. {
  368. creditCard: {
  369. height: math.unit(53.98, "mm"),
  370. image: { source: "./media/objects/credit-card.svg" },
  371. name: "Credit card",
  372. },
  373. creditCardVertical: {
  374. height: math.unit(85.60, "mm"),
  375. image: { source: "./media/objects/credit-card-vertical.svg" },
  376. name: "Credit card (vertical)",
  377. },
  378. }
  379. )
  380. });
  381. results.push({
  382. name: "Molecular",
  383. constructor: () => makeObject(
  384. "Molecular",
  385. {
  386. hydrogen: {
  387. height: math.unit(1.06e-10, "mm"),
  388. mass: math.unit(1, "dalton"),
  389. image: { source: "./media/objects/circle.svg" },
  390. name: "Hydrogen atom",
  391. rename: true
  392. },
  393. proton: {
  394. height: math.unit(1e-15, "mm"),
  395. mass: math.unit(1, "dalton"),
  396. image: { source: "./media/objects/circle.svg" },
  397. name: "Proton",
  398. rename: true
  399. },
  400. }
  401. )
  402. });
  403. results.push(makeShoes());
  404. results.push({
  405. name: "Flagpole",
  406. constructor: () => makeObject(
  407. "Flagpole",
  408. {
  409. residential: {
  410. height: math.unit(20, "feet"),
  411. image: { source: "./media/objects/flagpole.svg" },
  412. name: "Residential"
  413. },
  414. medium: {
  415. height: math.unit(50, "feet"),
  416. image: { source: "./media/objects/flagpole.svg" },
  417. name: "Medium"
  418. },
  419. large: {
  420. height: math.unit(100, "feet"),
  421. image: { source: "./media/objects/flagpole.svg" },
  422. name: "Large"
  423. },
  424. }
  425. )
  426. });
  427. results.push({
  428. name: "Vending Machine",
  429. constructor: () => makeObject(
  430. "Vending Machine",
  431. {
  432. object: {
  433. height: math.unit(183, "cm"),
  434. mass: math.unit(347, "kg"),
  435. image: { source: "./media/objects/vending-machine.svg" },
  436. name: "Vending Machine"
  437. }
  438. }
  439. )
  440. })
  441. results.push({
  442. name: "International Space Station",
  443. constructor: () => makeObject(
  444. "International Space Station",
  445. {
  446. object: {
  447. height: math.unit(209, "feet"),
  448. mass: math.unit(925300, "lbs"),
  449. image: { source: "./media/objects/international-space-station.svg" },
  450. name: "International Space Station"
  451. }
  452. }
  453. )
  454. })
  455. results.push(makeHeight(
  456. [
  457. ["king", 4, "inches"],
  458. ["queen", 351/407*4, "inches"],
  459. ["bishop", 340/407*4, "inches"],
  460. ["knight", 309/407*4, "inches"],
  461. ["rook", 271/407*4, "inches"],
  462. ["pawn", 197/407*4, "inches"],
  463. ],
  464. "Chess Pieces",
  465. "chess_"
  466. ));
  467. results.push({
  468. name: "Strand",
  469. constructor: () => {
  470. views = {};
  471. viewInfo = {
  472. opticalFibre: {
  473. name: "Optical Fibre",
  474. thickness: math.unit(0.375, "mm")
  475. },
  476. hair: {
  477. name: "Hair",
  478. thickness: math.unit(0.07, "mm")
  479. },
  480. spiderSilk: {
  481. name: "Spider Silk",
  482. thickness: math.unit(0.003, "mm")
  483. },
  484. suspensionCables: {
  485. name: "Suspension Bridge Cables",
  486. thickness: math.unit(3, "feet")
  487. },
  488. capillary: {
  489. name: "Capillary",
  490. thickness: math.unit(7.5, "micrometers")
  491. },
  492. vein: {
  493. name: "Vein",
  494. thickness: math.unit(10, "mm")
  495. },
  496. thread: {
  497. name: "Thread",
  498. thickness: math.unit(0.4, "mm")
  499. },
  500. powerCord: {
  501. name: "Power Cord",
  502. thickness: math.unit(0.25, "inches")
  503. },
  504. pianoWireBass: {
  505. name: "Piano Wire (Bass)",
  506. thickness: math.unit(8.5, "mm")
  507. },
  508. pianoWireTreble: {
  509. name: "Piano Wire (Treble)",
  510. thickness: math.unit(0.85, "mm")
  511. },
  512. guitarString: {
  513. name: "Guitar String",
  514. thickness: math.unit(0.03, "inches")
  515. },
  516. powerLineThin: {
  517. name: "Power Line (Thin)",
  518. thickness: math.unit(0.325, "inches")
  519. },
  520. powerLineThick: {
  521. name: "Power Line (Thick)",
  522. thickness: math.unit(0.720, "inches")
  523. },
  524. carbonNanotube: {
  525. name: "Carbon Nanotube",
  526. thickness: math.unit(4, "nm")
  527. }
  528. }
  529. Object.entries(viewInfo).forEach(([key, value]) => {
  530. views[key] = {
  531. attributes: {
  532. height: {
  533. name: "Height",
  534. power: 1,
  535. type: "length",
  536. base: math.multiply(value.thickness, 253.4385 / 5)
  537. },
  538. thickness: {
  539. name: "Thickness",
  540. power: 1,
  541. type: "length",
  542. base: value.thickness
  543. },
  544. },
  545. image: {
  546. source: "./media/objects/strand.svg"
  547. },
  548. name: value.name,
  549. rename: true
  550. }
  551. if (value.mass) {
  552. views[key].attributes.mass = {
  553. name: "Mass",
  554. power: 3,
  555. type: "mass",
  556. base: value.mass
  557. };
  558. }
  559. });
  560. return makeEntity({ name: "Strand" }, views);
  561. }
  562. })
  563. results.push(makeHeight(
  564. [
  565. ["animal-cell", 25, "micrometers"],
  566. ["plant-cell", 75, "micrometers"],
  567. ["mitochondria", 0.5, "micrometer"],
  568. ["bacteria", 0.3, "micrometer"],
  569. ["red-blood-cell", 6.5, "micrometer"],
  570. ["white-blood-cell", 13, "micrometer"],
  571. ["amoeba-proteus", 500, "micrometers"],
  572. ["chaos-carolinensis", 1500, "micrometers"]
  573. ],
  574. "Cells",
  575. "cell_"
  576. ))
  577. results.sort((b1, b2) => {
  578. e1 = b1.constructor();
  579. e2 = b2.constructor();
  580. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  581. });
  582. return results;
  583. }