-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (51 loc) · 2.5 KB
/
script.js
File metadata and controls
67 lines (51 loc) · 2.5 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
import { calculate_values } from "./calculate_values.js"
import { draw_plot } from "./draw_plot.js"
document.getElementById("plotBtn").addEventListener("click", () => {
const expr = document.getElementById("func").value;
const minVal = parseFloat(document.getElementById("minVal").value);
const maxVal = parseFloat(document.getElementById("maxVal").value);
const delta = parseFloat(document.getElementById("delta").value);
let values = calculate_values(expr, delta, minVal, maxVal)
let xValues = values[0]
let yValues = values[1]
draw_plot(expr, xValues, yValues)
});
document.getElementById("heartBtn").addEventListener("click", () => {
document.getElementById("func").value = "(x^2)^(1/3) + e/3 * sqrt(pi - x^2) * sin(10 * pi * x)"
document.getElementById("minVal").value = -5
document.getElementById("maxVal").value = 5
document.getElementById("delta").value = 0.001
const expr = document.getElementById("func").value;
const minVal = parseFloat(document.getElementById("minVal").value);
const maxVal = parseFloat(document.getElementById("maxVal").value);
const delta = parseFloat(document.getElementById("delta").value);
let values = calculate_values(expr, delta, minVal, maxVal)
let xValues = values[0]
let yValues = values[1]
draw_plot(expr, xValues, yValues)
});
document.getElementById("gaussBtn").addEventListener("click", () => {
document.getElementById("func").value = "1/(sqrt(2 * pi)) * e^(-1 * (x^2/2^2))"
document.getElementById("minVal").value = -5
document.getElementById("maxVal").value = 5
document.getElementById("delta").value = 0.01
const expr = document.getElementById("func").value;
const minVal = parseFloat(document.getElementById("minVal").value);
const maxVal = parseFloat(document.getElementById("maxVal").value);
const delta = parseFloat(document.getElementById("delta").value);
let values = calculate_values(expr, delta, minVal, maxVal)
let xValues = values[0]
let yValues = values[1]
draw_plot(expr, xValues, yValues)
});
document.getElementById("resetBtn").addEventListener("click", () => {
document.getElementById("func").value = "x"
const expr = document.getElementById("func").value;
document.getElementById("minVal").value = -10
document.getElementById("maxVal").value = 10
document.getElementById("delta").value = 0.01
let values = calculate_values(expr)
let xValues = values[0]
let yValues = values[1]
draw_plot(expr, xValues, yValues)
});