You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.8 KiB
Plaintext
92 lines
2.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "689613d2",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"80.58750000000002\n",
|
|
"(array([8.97705408, 4.95 , 0. ]), array([-8.97705408, 4.95 , 0. ]))\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import numpy \n",
|
|
"from math import sqrt as square\n",
|
|
"from numpy import sqrt, dot, cross \n",
|
|
"from numpy.linalg import norm \n",
|
|
"\n",
|
|
"#rssi = [rssi, max_rssi, min_rssi, gamma]\n",
|
|
"\n",
|
|
"def dist(rssi):\n",
|
|
" rssi = list(map(float, rssi))\n",
|
|
" return square(abs(rssi[0]-rssi[1]))*rssi[3]/square(abs(rssi[0]-rssi[2]))\n",
|
|
"\n",
|
|
"def sol(x1,x2,x3,rssi1,rssi2,rssi3):\n",
|
|
" r1 = dist(rssi1)\n",
|
|
" r2 = dist(rssi2)\n",
|
|
" r3 = dist(rssi3)\n",
|
|
" x1=numpy.array(x1)\n",
|
|
" x2=numpy.array(x2)\n",
|
|
" x3=numpy.array(x3)\n",
|
|
" temp1 = x2-x1 \n",
|
|
" e_x = temp1/norm(temp1) \n",
|
|
" temp2 = x3-x1 \n",
|
|
" i = dot(e_x,temp2) \n",
|
|
" temp3 = temp2 - i*e_x \n",
|
|
" e_y = temp3/norm(temp3) \n",
|
|
" e_z = cross(e_x,e_y) \n",
|
|
" d = norm(x2-x1) \n",
|
|
" j = dot(e_y,temp2) \n",
|
|
" x = (r1*r1 - r2*r2 + d*d) / (2*d) \n",
|
|
" y = (r1*r1 - r3*r3 -2*i*x + i*i + j*j) / (2*j) \n",
|
|
" temp4 = r1*r1 - x*x - y*y \n",
|
|
" print(temp4)\n",
|
|
" if temp4<0: \n",
|
|
" return \"Нет пересечения!\"\n",
|
|
" z = sqrt(temp4) \n",
|
|
" p_12_a = x1 + x*e_x + y*e_y + z*e_z \n",
|
|
" p_12_b = x1 + x*e_x + y*e_y - z*e_z \n",
|
|
" return p_12_a,p_12_b\n",
|
|
"\n",
|
|
"\n",
|
|
"print(sol([0,0,1],[0,0,-1],[0,10,0],[50,100,0,10.3],[50,100,0,10.3],[50,100,0,10.3]))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "0a68f35a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|