-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
175 lines (164 loc) · 7.15 KB
/
index.html
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<title> Principal Stresses </title>
<link rel="stylesheet" href="styles.css">
</head>
<body class="fullbody">
<h1 id="heading"> Welcome to Principal Stress Calculator </h1><hr width="50%">
<h3 class="ins">In this Calculator you will be able to Calculate Principal Stresses,Maximum Shear stress, Principal Plane angle w.r.t. given plane.</h3>
<h3 class="ins">You will be also able to visualise orientation of mohr's circle in this calculator.</h3>
<table id="mainbody">
<tbody>
<tr>
<td class="left">
<img src="images/main_diagram.png" alt="Basic Diagram" style="width: 391px; height: 385px;">
<p id="dothis">Enter Values of Stresses shown in this diagram.</p>
<form id="user_input">
<table>
<tr>
<td class="name"> σ<sub>x</sub> </td>
<td> <input class="textbox" id="stress-x" type="text"> </td>
</tr>
<tr>
<td class="name"> σ<sub>y</sub> </td>
<td> <input id="stress-y" class="textbox" type="text"> </td>
</tr>
<tr>
<td class="name"> Τ<sub>xy</sub> </td>
<td> <input id="shear" class="textbox" type="text"> </td>
</tr>
</table>
<input id="calculate_now" value="Calculate" onclick="calculate()" type="submit">
</form>
</td>
<td class="right">
<table>
<tr>
<!--for drawing circle-->
<canvas id="myCanvas" height="500px" width="900px"></canvas>
</tr>
<tr>
<!--for showing answer-->
<table class="answertable">
<tr>
<td>
<p>
Max. Principal Stress :
</p>
</td>
<td>
<p id="pstress-1"></p>
</td>
</tr>
<tr>
<td>
<p>
Min. Principal Stress :
</p>
</td>
<td>
<p id="pstress-2"></p>
</td>
</tr>
<tr>
<td>
<p>
Max. Shear Stress:
</p>
</td>
<td>
<p id="pshearmax"></p>
</td>
</tr>
<tr>
<td>
<p>
Angle of Principal planes:
</p>
</td>
<td>
<p id="pthetap"></p>
</td>
</tr>
</table>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<footer>
Made with ❤️ in India.
</footer>
<script>
var mohrradius;
var sigma1, sigma2, thetaP, thetaS, shearMax, v, a, b, c, d, e, f;
function calculate() {
event.preventDefault();
var x = document.getElementById("stress-x").value;
var y = document.getElementById("stress-y").value;
var z = document.getElementById("shear").value;
x = parseFloat(x);
y = parseFloat(y);
z = parseFloat(z);
//all fromulas here!!!
d = (x + y) / 2;
f = (x - d);
e = f * f;
a = (e + (z * z));
b = (x + y) / 2;
mohrradius = Math.sqrt(a);
v = (2 * z) / (x - y);
sigma1 = ((x + y) / 2) + mohrradius;
sigma2 = ((x + y) / 2) - mohrradius;
thetaP = (Math.atan(v)) / 2;
shearMax = (sigma1 - sigma2) / 2;
document.getElementById("pstress-1").innerHTML = sigma1 + " N/mm^2";
document.getElementById("pstress-2").innerHTML = sigma2 + " N/mm^2";
document.getElementById("pshearmax").innerHTML = shearMax + " N/mm^2";
document.getElementById("pthetap").innerHTML = radians_to_degrees(thetaP) + " degrees";
drawcirc();
drawline();
}
function drawcirc() {
var c_circ = document.getElementById("myCanvas");
var ctx_circ = c_circ.getContext("2d");
ctx_circ.clearRect(0, 0, c_circ.width, c_circ.height);
var radius = radius;
ctx_circ.beginPath();
ctx_circ.arc(450 + (sigma1 + sigma2) / 2, 250, 100, 0, 2 * Math.PI);
ctx_circ.strokeStyle = "red";
ctx_circ.stroke();
}
function drawline() {
var canvas = document.getElementById("myCanvas");
var ctx_x = canvas.getContext("2d");
ctx_x.strokeStyle = "black";
ctx_x.moveTo(450, 0);
ctx_x.lineTo(450, 900);
ctx_x.stroke();
ctx_x.moveTo(0, 250);
ctx_x.lineTo(900, 250);
ctx_x.stroke();
r = 100;
theta = thetaP * 2;
ctx_x.moveTo(450 + (sigma1 + sigma2) / 2, 250);
ctx_x.lineTo(450 + (sigma1 + sigma2) / 2 + 100 * Math.cos(theta), 250 + r * Math.sin(theta));
ctx_x.stroke();
ctx_x.moveTo(450 + (sigma1 + sigma2) / 2, 250);
ctx_x.lineTo(450 + (sigma1 + sigma2) / 2 - 100 * Math.cos(theta), 250 - r * Math.sin(theta));
ctx_x.stroke();
ctx_x.font = "30px Comic Sans MS";
ctx_x.fillStyle = "red";
ctx_x.fillText("longitudinal stress", 644, 245);
ctx_x.fillText("shear stress", 450, 100);
}
function radians_to_degrees(radians) {
var pi = Math.PI;
return radians * (180 / pi);
}
</script>
</body>
</html>