Skip to content

Commit

Permalink
Update find_cross_point_between_parabolas
Browse files Browse the repository at this point in the history
  • Loading branch information
nghia-vo committed Nov 13, 2024
1 parent e92da77 commit 08ec8dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion discorpy/losa/loadersaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"""

import os
import platform
from pathlib import Path
import h5py
Expand All @@ -55,6 +54,7 @@ def __correct_path(file_path):
'\r': r'\r',
'\t': r'\t',
'\v': r'\v',
'\0': r'\0',
}
for char, escaped in escape_sequences.items():
if char in file_path:
Expand Down
22 changes: 5 additions & 17 deletions discorpy/proc/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,24 +780,12 @@ def _find_cross_point_between_parabolas(para_coef_hor, para_coef_ver):
"""
a1, b1, c1 = para_coef_hor[0:3]
a2, b2, c2 = para_coef_ver[0:3]
# coefs = [a1 ** 2 * a2, 2 * a1 * a2 * b1,
# a2 * b1 ** 2 + a1 * b2 + 2 * a1 * a2 * c1,
# -1 + b1 * b2 + 2 * a2 * b1 * c1,
# b2 * c1 + a2 * c1 ** 2 + c2]
# xvals = np.float32(np.real(np.roots(coefs)))
# if len(xvals) == 0:
# raise ValueError("Can't find a cross point between two parabolas")
# if len(xvals) > 1:
# x = xvals[np.argmin(np.abs(xvals - c2))]
# else:
# x = xvals[0]
# y = a1 * x ** 2 + b1 * x + c1

def equations(p):
x, y = p

def __equations(vals):
x, y = vals
return a1 * x ** 2 + b1 * x + c1 - y, a2 * y ** 2 + b2 * y + c2 - x
solution = optimize.fsolve(equations, (0, 0))
x, y = solution

x, y = optimize.fsolve(__equations, (0, 0))
return x, y


Expand Down

0 comments on commit 08ec8dc

Please sign in to comment.